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

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

Open XIMEA camera.

Opens the specified XIMEA camera preparing it for starting video acquisition which is done using StartAcquisition method. The IsDeviceOpen property can be used at any time to find if a camera was opened or not.

An error occurred while communicating with a camera. See error /// message for additional information.
public Open ( int deviceID ) : void
deviceID int Camera ID to open.
Результат void
        public void Open( int deviceID )
        {
            lock ( sync )
            {
                IntPtr deviceHandle;
                int errorCode = XimeaAPI.xiOpenDevice( deviceID, out deviceHandle );
                HandleError( errorCode );
                // save the device handle is everything is fine
                this.deviceHandle = deviceHandle;
                this.isAcquisitionStarted = false;
                this.deviceID = deviceID;
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Start video source.
        /// </summary>
        ///
        /// <remarks>Starts video source and returns execution to caller. Video camera will be started
        /// and will provide new video frames through the <see cref="NewFrame"/> event.</remarks>
        ///
        /// <exception cref="ArgumentException">There is no XIMEA camera with specified ID connected to the system.</exception>
        /// <exception cref="VideoException">An error occurred while communicating with a camera. See error
        /// message for additional information.</exception>
        ///
        public void Start()
        {
            if (IsRunning)
            {
                return;
            }

            lock (sync)
            {
                if (thread == null)
                {
                    // check source
                    if (deviceID >= XimeaCamera.CamerasCount)
                    {
                        throw new ArgumentException("There is no XIMEA camera with specified ID connected to the system.");
                    }

                    // prepare the camera
                    camera.Open(deviceID);

                    framesReceived = 0;
                    bytesReceived  = 0;

                    // create events
                    stopEvent = new ManualResetEvent(false);

                    // create and start new thread
                    thread = new Thread(new ThreadStart(WorkerThread))
                    {
                        Name = Source
                    };
                    thread.Start();
                }
            }
        }