C# Класс 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( );
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
CheckConnection ( ) : void
HandleError ( int errorCode ) : void

Описание методов

Close() публичный метод

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
Результат void

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

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

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.
Результат System.Drawing.Bitmap

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

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.
Результат System.Drawing.Bitmap

GetParamFloat() публичный метод

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.
Результат float

GetParamInt() публичный метод

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.
Результат int

GetParamString() публичный метод

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.
Результат string

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

SetParam() публичный метод

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.
Результат void

SetParam() публичный метод

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.
Результат void

StartAcquisition() публичный метод

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
Результат void

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