Example #1
0
        /// <summary>
        /// Frame Process Function called on Image Grabbed Event
        /// </summary>
        protected override void ProcessFrame(object sender, EventArgs e)
        {
            //Unsubscribe to stop receiving events
            _capture.ImageGrabbed -= ProcessFrame;
            try
            {
                Mat f = new Mat();
                _capture.Retrieve(f, 0);

                //Get frame from camera
                Frame frame = new Frame();
                frame.Timestamp = DateTime.Now;
                frame.Image = new Image<Gray, byte>(f.Bitmap);

                Data = frame;
                NotifyAll();
            }
            catch (Exception ex)
            {
                Log.Print(String.Format("Failed to deal with frame. Reason: {0}", ex.Message), eCategory.Error, LogTag.IMAGE);
            }
            finally
            {
                //Subscribe back to receive events
                _capture.ImageGrabbed += ProcessFrame;
            }
        }
Example #2
0
 /// <summary>
 /// Create exact copy of current frame
 /// </summary>
 /// <returns>Cloned Frame</returns>
 public IFrame Clone()
 {
     IFrame frameCopy = new Frame();
     frameCopy.Timestamp = this.Timestamp;
     frameCopy.Image = this.Image.Clone();
     return frameCopy;
 }
Example #3
0
        /// <summary>
        /// Generate Empty frames in rate of FrameRate set
        /// in loop with timestamp and notify observers
        /// </summary>
        /// <param name="sender">Irrelevant Pamater</param>
        /// <param name="e">Irrelevant Pamater</param>
        protected override void ProcessFrame(object sender, EventArgs e)
        {
            while (true)
            {
                try
                {
                    Thread.Sleep(TimeSpan.FromSeconds(1 / (double)FrameRate));
                    Frame frame = new Frame();
                    frame.Timestamp = DateTime.Now;

                    Data = frame;
                    NotifyAll();
                }
                catch (Exception ex)
                {
                    Log.Print(String.Format(
                        "Error generating frame in demo streamer. Reason: {0}", ex.Message), eCategory.Error, LogTag.IMAGE);
                }
            }
        }