C# Class AForge.Video.Ximea.XimeaCamera

The class provides access to XIMEA cameras.

The class allows to perform image acquisition from XIMEA cameras. It wraps XIMEA'a xiAPI, which means that users of this class will also require m3api.dll and a correct TM file for the camera model connected to the system (both are provided with XIMEA API software package).

Sample usage:

XimeaCamera camera = new XimeaCamera( ); // open camera and start data acquisition camera.Open( 0 ); camera.StartAcquisition( ); // set exposure time to 10 milliseconds camera.SetParam( CameraParameter.Exposure, 10 * 1000 ); // get image from the camera Bitmap bitmap = camera.GetImage( ); // process the image // ... // dispose the image when it is no longer needed bitmap.Dispose( ); // stop data acquisition and close the camera camera.StopAcquisition( ); camera.Close( );
Show file Open project: holisticware-admin/MonoVersal.AForgeNET

Public Methods

Method Description
Close ( ) : void

Close opened camera (if any) and release allocated resources.

The method also calls StopAcquisition method if it was not done by user.

GetImage ( ) : Bitmap

Get image from the opened XIMEA camera.

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

GetImage ( int timeout ) : Bitmap

Get image from the opened XIMEA camera.

The method calls GetImage(int,bool) method specifying the makeCopy parameter.

GetImage ( int timeout, bool makeCopy ) : Bitmap

Get image from the opened XIMEA camera.

If the makeCopy is set to , then the method creates a managed copy of the camera's image, so the managed image stays valid even when the camera is closed. However, setting this parameter to creates a managed image which is just a wrapper around camera's unmanaged image. So if camera is closed and its resources are freed, the managed image becomes no longer valid and accessing it will generate an exception.

GetParamFloat ( string parameterName ) : float

Get camera's parameter as float value.

See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

GetParamInt ( string parameterName ) : int

Get camera's parameter as integer value.

See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

GetParamString ( string parameterName ) : string

Get camera's parameter as string value.

See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

Open ( int deviceID ) : void

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.

SetParam ( string parameterName, float value ) : void

Set camera's parameter.

The method allows to control different camera's parameters, like exposure time, gain value, etc. See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

SetParam ( string parameterName, int value ) : void

Set camera's parameter.

The method allows to control different camera's parameters, like exposure time, gain value, etc. See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

StartAcquisition ( ) : void

Begin camera's work cycle and start data acquisition from it.

The IsAcquisitionStarted property can be used at any time to find if the acquisition was started or not.

StopAcquisition ( ) : void

End camera's work cycle and stops data acquisition.

Private Methods

Method Description
CheckConnection ( ) : void
HandleError ( int errorCode ) : void

Method Details

Close() public method

Close opened camera (if any) and release allocated resources.

The method also calls StopAcquisition method if it was not done by user.

An error occurred while communicating with a camera. See error /// message for additional information.
public Close ( ) : void
return void

GetImage() public method

Get image from the opened XIMEA camera.

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

public GetImage ( ) : Bitmap
return System.Drawing.Bitmap

GetImage() public method

Get image from the opened XIMEA camera.

The method calls GetImage(int,bool) method specifying the makeCopy parameter.

public GetImage ( int timeout ) : Bitmap
timeout int Maximum time to wait in milliseconds till image becomes available.
return System.Drawing.Bitmap

GetImage() public method

Get image from the opened XIMEA camera.

If the makeCopy is set to , then the method creates a managed copy of the camera's image, so the managed image stays valid even when the camera is closed. However, setting this parameter to creates a managed image which is just a wrapper around camera's unmanaged image. So if camera is closed and its resources are freed, the managed image becomes no longer valid and accessing it will generate an exception.

An error occurred while communicating with a camera. See error /// message for additional information. No camera was opened, so can not access its methods. Time out value reached - no image is available within specified time value.
public GetImage ( int timeout, bool makeCopy ) : Bitmap
timeout int Maximum time to wait in milliseconds till image becomes available.
makeCopy bool Make a copy of the camera's image or not.
return System.Drawing.Bitmap

GetParamFloat() public method

Get camera's parameter as float value.

See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

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 GetParamFloat ( string parameterName ) : float
parameterName string Parameter name to get from camera.
return float

GetParamInt() public method

Get camera's parameter as integer value.

See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

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 GetParamInt ( string parameterName ) : int
parameterName string Parameter name to get from camera.
return int

GetParamString() public method

Get camera's parameter as string value.

See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

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 GetParamString ( string parameterName ) : string
parameterName string Parameter name to get from camera.
return string

Open() public method

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.
return void

SetParam() public method

Set camera's parameter.

The method allows to control different camera's parameters, like exposure time, gain value, etc. See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

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 SetParam ( string parameterName, float value ) : void
parameterName string Parameter name.
value float Float parameter value.
return void

SetParam() public method

Set camera's parameter.

The method allows to control different camera's parameters, like exposure time, gain value, etc. See CameraParameter class for the list of some possible configuration parameters. See XIMEA documentation for the complete list of supported parameters.

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 SetParam ( string parameterName, int value ) : void
parameterName string Parameter name.
value int Integer parameter value.
return void

StartAcquisition() public method

Begin camera's work cycle and start data acquisition from it.

The IsAcquisitionStarted property can be used at any time to find if the acquisition was started or not.

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 StartAcquisition ( ) : void
return void

StopAcquisition() public method

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
return void