AForge.Video.Ximea.XimeaCamera.StopAcquisition C# (CSharp) Метод

StopAcquisition() публичный Метод

End camera's work cycle and stops data acquisition.
An error occurred while communicating with a camera. See error /// message for additional information. No camera was opened, so can not access its methods.
public StopAcquisition ( ) : void
Результат void
        public void StopAcquisition( )
        {
            lock ( sync )
            {
                CheckConnection( );

                try
                {
                    int errorCode = XimeaAPI.xiStopAcquisition( deviceHandle );
                    HandleError( errorCode );
                }
                finally
                {
                    isAcquisitionStarted = false;
                }
            }
        }

Usage Example

Пример #1
0
        // Worker thread
        private void WorkerThread()
        {
            var reasonToStop = ReasonToFinishPlaying.StoppedByUser;

            try
            {
                camera.StartAcquisition();

                // while there is no request for stop
                while (!stopEvent.WaitOne(0, false))
                {
                    // start time
                    var start = DateTime.Now;

                    // get next frame
                    var bitmap = camera.GetImage(15000, false);

                    framesReceived++;
                    bytesReceived += bitmap.Width * bitmap.Height * (Bitmap.GetPixelFormatSize(bitmap.PixelFormat) >> 3);

                    if (NewFrame != null)
                    {
                        NewFrame(this, new NewFrameEventArgs(bitmap));
                    }

                    // free image
                    bitmap.Dispose();

                    // wait for a while ?
                    if (frameInterval > 0)
                    {
                        // get frame duration
                        var span = DateTime.Now.Subtract(start);

                        // miliseconds to sleep
                        var msec = frameInterval - (int)span.TotalMilliseconds;

                        if ((msec > 0) && (stopEvent.WaitOne(msec, false)))
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                reasonToStop = ReasonToFinishPlaying.VideoSourceError;
                // provide information to clients
                if (VideoSourceError != null)
                {
                    VideoSourceError(this, new VideoSourceErrorEventArgs(exception.Message));
                }
            }
            finally
            {
                try
                {
                    camera.StopAcquisition();
                }
                catch
                {
                }
            }

            if (PlayingFinished != null)
            {
                PlayingFinished(this, reasonToStop);
            }
        }