Use the provided example scripts to develop your application.
Make sure that you have installed the CHR-Python-SDK on your PC.
If not follow the steps in the Installation article.
Activate your virtual environment if used.
<venv>\Scripts\activate.bat
Run the example Script.
example_code_GenICamCamera
10.09 KB
Start writing your application!
Example code for GenICam cameras
The file "example_code_GenICamCamera" provides 3 examples functions for Chromasens GenIcam cameras.
camera_communication Example program how to set and get features and how to download and upload files from the camera.
example_grab_images_sync Example program for synchronized image acquisition. With synchronous image acquisition, a single image is acquired in series with the program flow. The function configures the camera grabs 3 images and prints the imageID, the image counter, and the (BGR) value of the first pixel for each image.
example_grab_images_async Example programm for asynchon image acquisition. For asynchronous image acquisition, the API writes in a separate thread asynchon to the image processing the camera images in a FIFO buffer. The images in the buffer can be accessed with the function 'grab_image_async'.The function configures the camera grabs 10 images, prints the imageID, the image counter, and the (BGR) value of the first pixel for each image.
Before the example script can be used, ensure that the camera is connected and accessible. Connect with GCT to ensure that.
If you set “tl_path = None”, all transport layers in the system path “GENICAM_GENTL64_PATH“ are used to search for cameras. Also, a single transport layer file that matches your system can be specified. Therefore uncommend the variable “tl_path“ that matches your interface. If none of these options match the used transport layer specify the path to the transport layer file (.cti) that shall be used.
The transport layer file (.cti) is provided by Chromasens in case of a system without a framegrabber.
Only necessary if the GCT installation path is not default (≠ C:\Program Files\Chromasens\GCT2) Specify the path where the Chromasens SDK file (CSI.dll) is located.
GenICamCamera(dll_dir_path = r'<Installation dir GCT>\bin')
def main(tl_path: str, function: object, n_cam: int = 1):
txt = f' START Example: {function.__name__} '
print(f'{txt:#^80}\n')
cam_list = []
for i in range (n_cam):
cam_list.append(GenICamCamera(dll_dir_path = r'<Installation dir GCT>\bin'))
retval = cam_list[i].open_connection(tl_path, num_buffers = 15, device_number = i+1)
if retval[0] != 0:
return retval
Generic programming interface for industrial cameras administered by the European Machine Vision Association