Getting started
    • 19 Sep 2024
    • 2 Minutes to read
    • PDF

    Getting started

    • PDF

    Article summary

    General usage

    Use the provided example scripts to develop your application.

    1. Make sure that you have installed the CHR-Python-SDK on your PC.

      If not follow the steps in the Installation article.

    1. Activate your virtual environment if used.

    <venv>\Scripts\activate.bat
    1. Run the example Script.

    example_code_GenICamCamera
    10.09 KB

    1. Start writing your application!

    Example code for GenICam cameras

    The file "example_code_GenICamCamera" provides 3 examples functions for Chromasens GenIcam cameras.

    1. camera_communication
      Example program how to set and get features and how to download and upload files from the camera.

    2. 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.

    3. 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.

    1. Before the example script can be used, ensure that the camera is connected and accessible. Connect with GCT to ensure that.

    1. 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.

      • S2I       - r'C:\Program Files\Chromasens\GCT2\GenTL\s2i\GEVTLS2I.cti'

      • Kithara  - r'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'

      Example paths valid for the default installation.

    2. Specify the number of cameras "n_cams" that shall be used.

    if __name__ == '__main__':
        
        tl_path = None
        # tl_path = r'C:\Program Files\Chromasens\GCT2\GenTL\s2i\GEVTLS2I.cti'
        # tl_path = r'C:\Program Files\Chromasens\GCT2\GenTL\Kithara\tkh_tl_gev_kithara.cti'
        # tl_path = r'C:\Program Files\Euresys\eGrabber\cti\x86_64\coaxlink.cti'
        
        n_cams = 1
        
        
        retval = main(tl_path, camera_communication, n_cams)
        print(f'{retval}\n\n')
        
        retval = main(tl_path, example_grab_images_sync, n_cams)
        print(f'{retval}\n\n')
        
        retval = main(tl_path, example_grab_images_async, n_cams)
        print(f'{retval}\n\n')
    1. 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 


    Was this article helpful?

    What's Next
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence