Skip to content

Commit f1f44a7

Browse files
authored
[RDK-6642] Add examples to Camera component (#537)
Co-authored-by: Ale Paredes <[email protected]>
1 parent 68d08ac commit f1f44a7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/viam/components/camera/camera.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ async def get_image(
4343
NOTE: If the mime type is ``image/vnd.viam.dep`` you can use :func:`viam.media.video.ViamImage.bytes_to_depth_array`
4444
to convert the data to a standard representation.
4545
46+
::
47+
48+
my_camera = Camera.from_robot(robot=robot, name="my_camera")
49+
50+
# Assume "frame" has a mime_type of "image/vnd.viam.dep"
51+
frame = await my_camera.get_image(mime_type = CameraMimeType.VIAM_RAW_DEPTH)
52+
53+
# Convert "frame" to a standard 2D image representation.
54+
# Remove the 1st 3x8 bytes and reshape the raw bytes to List[List[Int]].
55+
standard_frame = frame.bytes_to_depth_array()
56+
4657
Args:
4758
mime_type (str): The desired mime type of the image. This does not guarantee output type
4859
@@ -56,6 +67,14 @@ async def get_images(self, *, timeout: Optional[float] = None, **kwargs) -> Tupl
5667
"""Get simultaneous images from different imagers, along with associated metadata.
5768
This should not be used for getting a time series of images from the same imager.
5869
70+
::
71+
72+
my_camera = Camera.from_robot(robot=robot, name="my_camera")
73+
74+
images, metadata = await my_camera.get_images()
75+
img0 = images[0].image
76+
timestamp = metadata.captured_at
77+
5978
Returns:
6079
Tuple[List[NamedImage], ResponseMetadata]:
6180
- List[NamedImage]:
@@ -102,6 +121,12 @@ async def get_properties(self, *, timeout: Optional[float] = None, **kwargs) ->
102121
"""
103122
Get the camera intrinsic parameters and camera distortion parameters
104123
124+
::
125+
126+
my_camera = Camera.from_robot(robot=robot, name="my_camera")
127+
128+
properties = await my_camera.get_properties()
129+
105130
Returns:
106131
Properties: The properties of the camera
107132
"""

0 commit comments

Comments
 (0)