Ejemplo n.º 1
0
        private void VideoStreamWnd_Shown(object sender, EventArgs e)
        {
            try
            {
                project = ((MainForm)this.MdiParent).Project;
                VideoDataLine startDataLine = (VideoDataLine)dataStream.DataLines[0];
                OpenVideo(startDataLine);
                trackBar.Minimum = 0;
                trackBar.Maximum = Convert.ToInt32(dataStream.Length * reader.FrameRate);

                SetFrameByTime(dataStream.StartTime);
                this.Text = "Video Stream: " + dataStream.ShortName;
                Refresh();
            }
            catch (Exception ex)
            {
                reader = null;
                logger.WriteLineError(ex.ToString());
                MessageBox.Show("Error during opening the file: " + ex.Message, "Error during opening video file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult result = MessageBox.Show("Do you want to reload stream for appropriate video format?", "Reloading stream!", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                if (result == DialogResult.OK)
                {
                    dataStream.WriteMetadata(logger);
                    MessageBox.Show("Stream reloaded! Open stream again!", "Open stream again!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void listFiles_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            VideoDataLine videoDataLine = listFiles.Items[e.Index] as VideoDataLine;

            e.DrawBackground();
            Graphics g = e.Graphics;

            if ((currentDataLine != null) && (currentDataLine == videoDataLine))
            {
                g.FillRectangle(new SolidBrush(Color.Red), e.Bounds);
            }
            else
            {
                g.FillRectangle(new SolidBrush(Color.White), e.Bounds);
            }

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                g.DrawString(videoDataLine.ToString(), e.Font, new SolidBrush(Color.Blue), new PointF(e.Bounds.X, e.Bounds.Y));
            }
            else
            {
                g.DrawString(videoDataLine.ToString(), e.Font, new SolidBrush(Color.Black), new PointF(e.Bounds.X, e.Bounds.Y));
            }

            e.DrawFocusRectangle();
        }
Ejemplo n.º 3
0
        public void SetFrameByTime(DateTime time)
        {
            lblStatus.Text = "Req.: " + time.ToString("yyyy-MM-dd HH:mm:ss.fff");

            VideoDataLine bestDataLine = null;

            foreach (var dataLine in dataStream.DataLines)
            {
                VideoDataLine videoDataLine = dataLine as VideoDataLine;
                if ((time >= dataLine.TimeStamp) && (time < dataLine.TimeStamp.Add(videoDataLine.Length)))
                {
                    bestDataLine = videoDataLine;
                }
            }

            if (bestDataLine != null)
            {
                lblStatus.Text += "File: " + bestDataLine.VideoFileName;

                if (currentDataLine != bestDataLine)
                {
                    OpenVideo(bestDataLine);
                    currentFrame = -1;
                }

                double dt    = new TimeSpan((time.Ticks - bestDataLine.TimeStamp.Ticks)).TotalSeconds;
                int    frame = Convert.ToInt32(dt * reader.FrameRate);
                SetFrame(frame);
            }
            else
            {
                frameBox.Image = null;
            }
        }
Ejemplo n.º 4
0
 public TimeFeature(DataStream stream, VideoDataLine dataLine, DateTime currentTime, HotFrame hotFrame)
 {
     this.DataStream   = stream;
     this.OriginalTime = currentTime;
     this.FileTime     = dataLine.FileTimeStamp;
     this.FileName     = dataLine.VideoFileName;
     this.GlobalTime   = hotFrame.Timestamp;
 }
Ejemplo n.º 5
0
        private void updateFileList()
        {
            listFiles.Items.Clear();
            foreach (DataLine dataLine in dataStream.DataLines)
            {
                VideoDataLine videoDataLine = dataLine as VideoDataLine;
                listFiles.Items.Add(videoDataLine);
            }

            listFiles.Refresh();
        }
Ejemplo n.º 6
0
        private void OpenVideo(VideoDataLine dataLine)
        {
            if (this.currentDataLine != null)
            {
                reader.Close();
            }

            try
            {
                reader = new FileCapture(project.Folder + "\\" + dataStream.SubFolder + "\\" + dataLine.VideoFileName);
                reader.Open();
                timer.Interval  = Convert.ToInt32((1 / reader.FrameRate) * 1000);
                currentDataLine = dataLine;
                lblStatus.Text += "Current file: " + dataLine.VideoFileName;
            }
            catch (Exception ex)
            {
                lblStatus.Text = "Error: " + ex.Message;
                logger.WriteLineError("Error occured: " + ex.Message);
                throw ex;
            }
        }