get_next_frame()
- 1 Minute to read
get_next_frame()
- 1 Minute to read
Article summary
Did you find this summary helpful?
Thank you for your feedback
Take a image frame from the selected camera.
Reference
Arguments
Argument | Type | Default value | |
---|---|---|---|
camera_name | str | - | Name of the camera. |
compressed | bool | False | When True , this method returns a jpeg compressed image |
get_timestamp | bool | False | When True , this method returns a returns a timestamp with the frame. |
time_out | float | -0.1 | The maximum time to wait for a frame, in seconds. |
Important note!
- Camera must be previously enabled with the enable_color_camera() method.
Return
- When
compressed == False
:- A Numpy array with shape
(height, width, 3)
, where3
represents RGB channels.height
andwidth
depend on the selected camera.
- A Numpy array with shape
- When
compressed == True
:- An uni dimensional Numpy array with
jpeg
RGB compressed image.
- An uni dimensional Numpy array with
- When
get_timestamp == True
:Tuple (image, timestamp),
timestamp in tuple (second, milliseconds).
Exceptions
RayaCameraInvalidName
RayaCameraNotEnabled
RayaCameraNotFrameReceived
See the complete list of cameras exceptions.
Usage Example
1. Take a image frame and show it
This example takes a image frame and show it for 3 seconds.
from raya.application_base import RayaApplicationBase
from raya.tools.image import show_image
class RayaApplication(RayaApplicationBase):
async def setup(self):
self.cameras = await self.enable_controller('cameras')
await self.cameras.enable_color_camera('chest')
async def loop(self):
img = await self.cameras.get_next_frame('chest')
show_image(img=img, title='Chedfs')
await self.sleep(3.0)
self.finish_app()
from raya.application_base import RayaApplicationBase
from raya.tools.image import show_image
class RayaApplication(RayaApplicationBase):
async def setup(self):
self.cameras = await self.enable_controller('cameras')
await self.cameras.enable_color_camera('chest')
async def loop(self):
img, timestamp = await self.cameras.get_next_frame(camera_name='chest', get_timestamp=True)
print('Timestamp: ', timestamp)
show_image(img=img, title='Chedfs')
await self.sleep(3.0)
self.finish_app()
Was this article helpful?