The class provides continues access to XIMEA cameras.

The video source class is aimed to provide continues access to XIMEA camera, when images are continuosly acquired from camera and provided throw the NewFrame event. It just creates a background thread and gets new images from XIMEA camera keeping the specified time interval between image acquisition. Essentially it is a wrapper class around XimeaCamera providing IVideoSource interface.

Sample usage:

// create video source for the XIMEA camera with ID 0 XimeaVideoSource videoSource = new XimeaVideoSource( 0 ); // set event handlers videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame ); // start the video source videoSource.Start( ); // set exposure time to 10 milliseconds videoSource.SetParam( CameraParameter.Exposure, 10 * 1000 ); // ... // New frame event handler, which is invoked on each new available video frame private void video_NewFrame( object sender, NewFrameEventArgs eventArgs ) { // get new frame Bitmap bitmap = eventArgs.Frame; // process the frame }
Inheritance: IVideoSource
Exemple #1
0
        // On "Connect" button click
        private void connectButton_Click( object sender, EventArgs e )
        {
            // set busy cursor
            this.Cursor = Cursors.WaitCursor;

            // close whatever is open now
            CloseCamera( );

            if ( videoSource == null )
            {
                try
                {
                    videoSource = new XimeaVideoSource( deviceCombo.SelectedIndex );
                    
                    // start the camera
                    videoSource.Start( );

                    // get some parameters
                    nameBox.Text = videoSource.GetParamString( CameraParameter.DeviceName );
                    snBox.Text   = videoSource.GetParamString( CameraParameter.DeviceSerialNumber );
                    typeBox.Text = videoSource.GetParamString( CameraParameter.DeviceType);

                    // width
                    widthUpDown.Minimum = videoSource.GetParamInt( CameraParameter.WidthMin );
                    widthUpDown.Maximum = videoSource.GetParamInt( CameraParameter.WidthMax );
                    widthUpDown.Value = videoSource.GetParamInt( CameraParameter.WidthMax );

                    // height
                    heightUpDown.Minimum = videoSource.GetParamInt( CameraParameter.HeightMin );
                    heightUpDown.Maximum = videoSource.GetParamInt( CameraParameter.HeightMax );
                    heightUpDown.Value = videoSource.GetParamInt( CameraParameter.HeightMax );

                    // exposure
                    exposureUpDown.Minimum = videoSource.GetParamInt( CameraParameter.ExposureMin ) / 1000;
                    exposureUpDown.Maximum = videoSource.GetParamInt( CameraParameter.ExposureMax ) / 1000;
                    exposureUpDown.Value = 0;
                    exposureUpDown.Value = 10;

                    // gain
                    gainUpDown.Minimum = new Decimal( videoSource.GetParamFloat( CameraParameter.GainMin ) );
                    gainUpDown.Maximum = new Decimal( videoSource.GetParamFloat( CameraParameter.GainMax ) );
                    gainUpDown.Value = new Decimal( videoSource.GetParamFloat( CameraParameter.Gain ) );
                    
                    videoSourcePlayer.VideoSource = videoSource;

                    EnableConnectionControls( false );

                    // reset stop watch
                    stopWatch = null;

                    // start timer
                    timer.Start( );
                }
                catch ( Exception ex )
                {
                    MessageBox.Show( "Failed openning XIMEA camera:\n\n" + ex.Message, "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error );
                    CloseCamera( );
                }
            }

            this.Cursor = Cursors.Default;
        }
Exemple #2
0
        // Close currently open camera if any
        private void CloseCamera( )
        {
            timer.Stop( );

            if ( videoSource != null )
            {
                videoSourcePlayer.VideoSource = null;

                videoSource.SignalToStop( );
                videoSource.WaitForStop( );
                videoSource = null;
            }
        }