get_next_frame()
  • 1 Minute to read

get_next_frame()


Article summary

Take a image frame from the selected camera.

Reference

Arguments

ArgumentTypeDefault value
camera_namestr
-
Name of the camera.
compressedbool
False
When True, this method returns a jpeg compressed image
get_timestampbool
False
When True, this method returns a returns a timestamp with the frame.
time_outfloat
-0.1
The maximum time to wait for a frame, in seconds.
Important note!

Return

  • When compressed == False:
    • A Numpy array with shape (height, width, 3), where 3 represents RGB channels. height and width depend on the selected camera.
  • When compressed == True:
    • An uni dimensional Numpy array with jpeg RGB compressed image.
  • 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?