create_frame_listener()
  • 1 Minute to read

create_frame_listener()


Article summary

Create a listener triggered each time that the camera generates a new frame. You can only create one listener per camera.

Reference

Arguments

ArgumentsTypeDefault value
camera_namestrCamera name, see the list of cameras
callbackCallable objectCallback
compressedbooleanFalseWhen True, the listener sends a jpeg compressed image to the callback

Important: Camera must be previously enabled with the enable_color_camera() method.

Return

None

Exceptions

ExceptionCondition
RayaInvalidCameraNameInvalid camera name.
RayaCameraNotEnabledSelected camera is not currently enabled.
RayaListenerAlreadyCreatedProvided listener name already used to create another listener.
RayaInvalidCallbackInvalid or not callable callback.

See the Full List of Exceptions.

Callback Arguments

Callback must receive the following arguments.

ArgumentsType
frameNumpy arrayCaptured frame with shape (height, width, 3) when compressed == False, and unidimensional (jpeg) when compressed == True

Examples

1. Continuously show the 'chest' camera image

...
    async def setup(self):
        ....
        self.cameras = self.enable_controller('cameras')
        self.cameras.enable_camera('chest')
        self.cameras.create_color_frame_listener(camera_name=self.camera_name, callback = self.camera_frame_callback)

    async def loop(self):
        # Do other stuff

    def camera_frame_callback(self, img):
        cv2.imshow('Gary\'s chest camera', img)
        cv2.waitKey(1)


Was this article helpful?

What's Next