Exemplo n.º 1
0
        void _bw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bw     = sender as BackgroundWorker;
            Camera           camera = _camera;

            // Note: the image is disposed once the camera gets disposed.
            // Therefore you should copy the image if needed in another
            // thread or make sure the camera is not disposed.
            Image <Bgr, byte> img;

            while (!bw.CancellationPending)
            {
                img = camera.Frame();
                if (img != null)
                {
                    lock (_lock_event) {
                        if (_on_frame != null)
                        {
                            _on_frame(this, img);
                        }
                    }
                    img.Dispose();
                }
                _fts.UpdateAndWait();
            }

            e.Cancel = true;
            _stopped.Set();
        }
Exemplo n.º 2
0
        void _bw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bw = sender as BackgroundWorker;

            while (!bw.CancellationPending)
            {
                lock (_event_lock) { if (_before_render != null)
                                     {
                                         _before_render(this);
                                     }
                }
                lock (_v) { _v.Frame(); }
                lock (_event_lock) { if (_after_render != null)
                                     {
                                         _after_render(this);
                                     }
                }
                _fts.UpdateAndWait();
            }
            e.Cancel = true;
            _stopped.Set();
        }