create_color_frame_listener()
- 1 Minute to read
create_color_frame_listener()
- 1 Minute to read
Article summary
Did you find this summary helpful?
Thank you for your feedback
Create a listener triggered each time that the camera generates a new frame. You can only create one listener per camera.
Reference
Arguments
Arguments | Type | Default value | |
---|---|---|---|
camera_name | str | - | Camera name, see the list of cameras |
callback | callable | None | Callback |
callback_async | callable | None | An asynchronous callback to be executed when a color frame is received (if callback_async is defined, callback is ignored). Allows a callback that can use ‘await’, which is useful for non-blocking operations and concurrent tasks. |
compressed | bool | False | When True, the listener sends a jpeg compressed image to the callback |
Important note!
- Camera must be previously enabled with the enable_color_camera() method.
- If callback_async is defined, callback is ignored.
- One of the callbacks must be defined.
Return
None
Exceptions
RayaCameraInvalidName
RayaCameraNotEnabled
RayaNeedCallback
See the complete list of cameras exceptions.
Callback Arguments
Callback must receive the following arguments.
Arguments | Type | |
---|---|---|
frame | Numpy array | Captured frame with shape (height, width, 3) when compressed == False , and unidimensional (jpeg) when compressed == True |
Usage Example
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?