Class: Camera

TM NPU MicroPython

Portfolio
Industrial AI
Product
SIMACTIC S7-1500 TM NPU 2.0
Language
en-US

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 resolution for using the Intel RealSENSE camera is fixed. For using a GigE Vision Camera or an external image the resolution can be set freely within the range of 640 x 480 pixels to 2MP. As the max. supported resolution for 2MP cameras can be either 1920 x 1080 pixels or 1600 x 1200 pixel, the limiting factor of the used resolution is the multiplication of width and height (X x Y) which must be equal or lower than 2.073.600 pixels (=1920 x 1080 pixels). The output resolution can therefor be set as follows:

    • GIGE_VISION: (X, Y), with 640 <= x <= 1920, 480 <= Y <= 1200 and X*Y <= 1920*1080

    • REALSENSE_D435: (1280, 720)

    • EXTERNAL_IMAGE: (X, Y), with 640 <= x <= 1920, 480 <= Y <= 1200 and X*Y <= 1920*1080

    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.