get_next_frame()¶
Take a image frame from the selected camera.
Reference¶
Arguments¶
Argument |
Type |
Default value |
|
|---|---|---|---|
camera_name |
|
Name of the camera. |
|
compressed |
|
|
When |
get_timestamp |
|
|
When |
time_out |
|
|
The maximum time to wait for a frame, in seconds. |
Important
Camera must be previously enabled with the enable_color_camera() method.
Return¶
When
compressed == False:A Numpy array with shape
(height, width, 3), where3represents RGB channels.heightandwidthdepend on the selected camera.
When
compressed == True:An uni dimensional Numpy array with
jpegRGB compressed image.
When
get_timestamp == True:Tuple (image, timestamp),timestamp in tuple (second, milliseconds).
Exceptions¶
RayaCameraInvalidNameRayaCameraNotEnabledRayaCameraNotFrameReceived
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()