Skip to content

DOCS-3284: Add simpler get_image example #844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/viam/components/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,9 @@ async def get_image(

::

from viam.media.video import CameraMimeType

my_camera = Camera.from_robot(robot=machine, name="my_camera")

# Assume "frame" has a mime_type of "image/vnd.viam.dep"
frame = await my_camera.get_image(mime_type = CameraMimeType.VIAM_RAW_DEPTH)

# Convert "frame" to a standard 2D image representation.
# Remove the 1st 3x8 bytes and reshape the raw bytes to List[List[Int]].
standard_frame = frame.bytes_to_depth_array()
my_camera = Camera.from_robot(machine, "my_camera")
frame = await my_camera.get_image()
print(f"Frame: {frame}")

Args:
mime_type (str): The desired mime type of the image. This does not guarantee output type
Expand Down