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

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

Get image from the opened XIMEA camera.

The method calls GetImage(int) method specifying 5000 as the timeout value.

public GetImage ( ) : Bitmap
Результат System.Drawing.Bitmap
        public unsafe Bitmap GetImage( )
        {
            return GetImage( 5000 );
        }

Same methods

XimeaCamera::GetImage ( int timeout ) : Bitmap
XimeaCamera::GetImage ( int timeout, bool makeCopy ) : Bitmap

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);
            }
        }