create_frame_listener()
- 1 Minute to read
create_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 object | Callback | |
compressed | boolean | False | When 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
Exception | Condition |
---|---|
RayaInvalidCameraName | Invalid camera name. |
RayaCameraNotEnabled | Selected camera is not currently enabled. |
RayaListenerAlreadyCreated | Provided listener name already used to create another listener. |
RayaInvalidCallback | Invalid or not callable callback. |
See the Full List of 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 |
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?