An instance of the ‘camera’ class is created by calling:
camera.camera(camera_id='GIGE_VISION', resolution=(1280, 720), pixel_format='YUV', pixel_format_description='YUYV', layout='PLANAR')
This returns a camera object, to be used with the vid_pipeline module.
Multiple instances of the ‘camera’ class can be created. A camera object can be erased using the standard MicroPython ‘del’ function.
camera_id
The unique identifier of the camera to be used. Can be ‘GIGE_VISION’, ‘REALSENSE_D435’ or ‘EXTERNAL_IMAGE‘.
Note:The value ‘EXTERNAL_IMAGE’ has to be used in combination with vid_pipeline.set_Image() for manual input of images into the vid_pipeline. This can be used for testing the inference on TM NPU, for example by loading an image from the SD Card and checking the expected results of the inference.
Note:Apart from the configuration in the MicroPython script (main.py), the corresponding ports of the TM NPU must be activated to enable access to the connected camera. This is done in the engineering by enabling or disabling the USB and Ethernet interface. For detailed information on the module configuration, please refer to the TM NPU User Manual.
To use a USB camera, select:
Engineering: Enable USB interface and camera
main.py: camera_id = REALSENSE_D435’ and pixel_format_description = ‘YUYV’
To use a GIGE camera, select:
Engineering: Enable Ethernet interface and the underlying ‘GigE Vision’ service
main.py: camera_id = ‘GIGE_VISION’ and pixel_format_description = ‘UYVY’
If the engineering and MicroPython user application do not match in the camera selection, frames received from the vid_pipeline.read_processed() will misshappen and with color coding (green/violet).
resolution
The desired output resolution for the camera, and must be a tuple of (width, height).
The supported resolutions are:
GIGE_VISION: (1280, 1024), (1280, 720), (640, 480)
REALSENSE_D435: (1280, 720)
EXTERNAL_IMAGE: (1280, 1024), (1280, 720), (640, 480)
Note:If the resolution for the camera object of this module differs from the configuration of the physical camera the initialization of vid_pipeline will fail. This error can not be caught by an exception. The module is forced to make an app error that can only be solved by applying the power cycle.
pixel_format
The pixel format of the images delivered from the camera. Can be ‘YUV’.
Note:‘RGB’ and ‘MONO’ are not supported.
pixel_format_description
Further specifies the pixel format of the images delivered from the camera. Can be ‘YUYV’ or ‘UYVY’.
layout
Defines how the image data should be arranged in the memory. Can be ‘PLANAR’.
Note:‘ROWMAJOR’ and ‘INTERLEAVED’ are currently not implemented.