- 29 Jul 2024
- 5 Minutes to read
- Print
- PDF
Class reference GeniCamCamera
- Updated on 29 Jul 2024
- 5 Minutes to read
- Print
- PDF
Class description
This class is intended to represent Chromasens GenICam devices that have the property "streamable".
This applies to the following devices:
allPIXA evo
allPIXA neo
Class instantiation
__init__()
__init__(self, dll_dir_path = r'C:\Program Files\Chromasens\GCT2\bin')
Create an instance of a GenIcam device.
Args:
dll_dir_path (str, optional): The path to the folder that contains the CSI file. The CSI file represents the Chromasens SDK and provides functions to set up the camera and grab images. For default installation, the default parameter value can be used.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
Class methods
discover_devices()
discover_devices(self, tl_producer_file_name)
Finds all devices with the specified transport layer. Returns a device info dict. The length of the dict corresponds to the number of devices found. If no devices are found, the dict is empty.
Args:
tl_producer_file_name (Union(str, list, type(None)), optional): Path to the transport layer producer file (.cti) or a list with multiple paths to producer files. If not specified the system environment path list GENICAM_GENTL64_PATH is used.
Returns:
tuple (int, dict, str): (0, device info dict, 'Error Message')
open_connection()
open_connection(self, tl_producer_file_name, device_number = 1)
Opens the connection to the GenIcam device via the transport layer.
The transport layer file (.cti) is provided by Chromasens in case of a system without a framegrabber.
S2I - 'C:\Program Files\Chromasens\GCT2\GenTL\s2i\GEVTLS2I.cti'
Kithara - 'C:\Program Files\Chromasens\GCT2\GenTL\Kithara\tkh_tl_gev_kithara.cti'
For systems with a framegrabber, the .cti file is provided by the framegrabber manufacturer. The following is an example of an Euresys CXP12 grabber.
Euresys CXP12 - r'C:\Program Files\Euresys\eGrabber\cti\x86_64\coaxlink.cti'
Args:
tl_producer_file_name (Union(str, list, type(None)), optional): Path to the transport layer producer file (.cti) or a list with multiple paths to producer files. If not specified the system environment path list GENICAM_GENTL64_PATH is used.
device_number (int, optional): Device number. For multiple devices for the same TL the device number must be incremented. The count starts at 1.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
close_connection()
close_connection(self)
Closes the camera connection.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
set_feature()
set_feature(self, feature_name, feature_value, module = 3)
Sets a Genicam feature of the system. To set a camera feature the value of the parameter module must be CSI_DEVICE_MODULE (3).
Module type list:
CSI_TRANSPORTLAYER_MODULE = 1
CSI_INTERFACE_MODULE = 2
CSI_DEVICE_MODULE = 3
CSI_LOCAL_DEVICE_MODULE = 4
CSI_STREAM_MODULE = 5
CSI_BUFFER_MODULE = 6
Args:
feature_name (str): Feature name
feature_value (Union[bool, int, float, str, bytes]): Feature value
module (int, optional): CSI Module. Use 3 to address the camera.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
get_feature()
get_feature(self, feature_name, module = 3)
Readout a Genicam feature of the system. To get a camera feature the value of the parameter module must be CSI_DEVICE_MODULE (3).
Module type list:
CSI_TRANSPORTLAYER_MODULE = 1
CSI_INTERFACE_MODULE = 2
CSI_DEVICE_MODULE = 3
CSI_LOCAL_DEVICE_MODULE = 4
CSI_STREAM_MODULE = 5
CSI_BUFFER_MODULE = 6
Args:
feature_name (str): Feature name
module (int, optional): CSI Module. Use 3 to address the camera.
Returns:
tuple (int, Union[bool, int, float, str], str): (0, Value, 'OK') or (Error Code, None, 'Error Message')
set_register()
set_register(self, address, val)
Set a single register value. WARNING: This feature is only for experienced users.
Args:
address (str): Register address
val (str): Register value
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
get_register()
get_register(self, address, mask)
Get the actual register value represented as a string. WARNING: This feature is only for experienced users.
Args:
address (str): Register address
mask (str, optional): Bitmask
Returns:
tuple (int, str, str): (0, Register value, 'OK') or (Error Code, Register value, 'Error Message')
get_feature_parameter()
get_feature_parameter(self, feature_name, module = 3)
Returns the feature info dict of the requested feature. The dict contains information about the parameter.
Args:
feature_name (str): Feature name
module (int, optional): Module
Returns:
tuple (int, dict, str): (0, param info dict, 'OK') or (Error Code, 0, 'Error Message')
get_feature_dict()
get_feature_dict(self)
Get all features from the device and return them as a dictionary.
Returns:
tuple (int, dict, str): (0, Feature, 'OK') or (Error Code, Empty Dict, 'Error Message')
upload_file()
upload_file(self,dfs)
Uploads a file from the PC to the device.
Supported feature name list:
UserSet1 … UserSet8
DSNULUT1, DSNULUT2
PRNULUT1, PRNULUT2
Application
Bitstream
Xml
PackageDescriptionFile
Args:
file_name (str): file path of the file which is to be loaded to the device
file_type (str): name of the filetype, must match to the file. Check supported feature name list
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
upload_package()
upload_package(self, file_name)
Upload a (firmware) package to the camera.
Args:
file_name (str): file path of the "listfile" which describes the package components.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
download_file()
download_file(self, file_name, file_type)
Downloads a file from the device to the PC.
Supported feature name list:
UserSet1 … UserSet8
DSNULUT1, DSNULUT2
PRNULUT1, PRNULUT2
Application
Bitstream
Xml
PackageDescriptionFile
Args:
file_name (str): save file path of the file which is to be downloaded from the device.
file_type (str): name of the filetype.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
grab_image_sync()
grab_image_sync(self, timeout_ms = 5000)
This function acquires a single image. grab_image_sync is the complete sequence of the "grab_image_async" procedure. In the background, it starts the following methods.
start_grab_image_async (in single frame mode)
grab_image_async
stop_grab_image_async
Also sets the camera genicam parameter "AcquisitionMode" to "SingleFrame"
Args:
timeout_ms (int, optional): If the function has to wait longer than the "timeout_ms" for a new image, an error is generated.
Returns:
tuple (int, tuple(np.ndarray, dict), str): (0, (image, image metadata dict), 'OK') or (Error Code, '', 'Error Message')
start_grab_image_async()
start_grab_image_async(self, grab_single_img = False)
This function starts an continious image acquisiton thread. After the acquisition thread is started, images can be acessed from the buffer with "grab_image_async". If all buffers are filled with images, new images are are rejected (buffer overflow).
Args:
grab_single_img(bool, optional): This function can be used to acquire a single image. With 'grab_single_img' = True only a single image can be grabbed with "grab_img_acync". After this, the stream has to be closed and reopened.
Returns:
tuple (int, tuple(np.ndarray, dict), str): (0, (image, image metadata dict), 'OK') or (ErrorCode, '', 'Error Message')
grab_image_async()
grab_image_async(self, timeout_ms = 5000, raise_buffer_overflow_error = False)
This function starts an continious image acquisiton thread if it is not already started. As soon a image is in the image buffer this function grabs the first image in the buffer (FIFO). The function provides the buffer content as np.array + metadata and releases the buffer allocation. If all buffers are filled with images, new images are are rejected (buffer overflow).
Args:
timeout_ms (int, optional): If the function has to wait longer than the "timeout_ms" for a new image, an error is generated.
raise_buffer_overflow_error (bool, optional): If frames are lost (buffer overflow) the function raises an error if "True".
Returns:
tuple (int, tuple(np.ndarray, dict), str): (0, (image, image metadata dict), 'OK') or (Error Code, '', 'Error Message')
stop_grab_image_async()
stop_grab_image_async(self)
This function stops the camera image acquisition after the complete acquisition of the current image.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
abort_grab_image_async()
stop_grab_image_async(self)
This function stops the camera image acquisition immediately.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
set_num_of_stream_buffers()
set_num_of_stream_buffers(self, num_buffers)
Closes and unregisters a camera datastream and open and register it again with a new number of buffers.
Args:
num_buffers (int): number of buffers in the image FIFO buffer. A lage number consumes a large amout of RAM.
Returns:
tuple (int, type(None), str): (0, None, 'OK') or (Error Code, None, 'Error Message')
CSI Typedefs
Most important typedefs:
Module type list:
CSI_TRANSPORTLAYER_MODULE = 1
CSI_INTERFACE_MODULE = 2
CSI_DEVICE_MODULE = 3
CSI_LOCAL_DEVICE_MODULE = 4
CSI_STREAM_MODULE = 5
CSI_BUFFER_MODULE = 6
Feature type list:
CSI_UNKNOWN_TYPE = 0
CSI_BOOLEAN_TYPE = 1
CSI_INT_TYPE = 2
CSI_FLOAT_TYPE = 3
CSI_STRING_TYPE = 4
CSI_ENUMERATION_TYPE = 5
CSI_ENUMENTRY_TYPE = 6
CSI_CATEGORY = 7
CSI_COMMAND = 8
CSI_REGISTER = 9
CSI_PORT = 10
Access mode list:
CSI_ACCESS_UNKNOWN = 0
CSI_ACCESS_NOT_AVAILABLE = 1
CSI_ACCESS_READ_ONLY = 2
CSI_ACCESS_READ_WRITE = 3
CSI_ACCESS_WRITE_ONLY = 4
To check all typedefs check the API description:
C:\Program Files\Chromasens\GCT2\CSGenICamSDK