Video3DFrame

class quanser.multimedia.video.Video3DFrame(frame)

A Python wrapper for a video3d frame. You should not need to create an instance of this class yourself.

get_data(data)

Gets the frame data in the specified image format and data type.

Parameters

data (array_like) – An array to hold the frame data. data must point to memory large enough to hold the image in the specified format and data type (HxWx3 or HxW).

Raises

MediaError – On non-zero return code. A suitable error message may be retrieved using get_error_message.

Example

Get the frame data of the first 1000 frames from the color stream.

>>> import numpy as np
>>> from quanser.multimedia import Video3D, ImageDataType, ImageFormat, Video3DStreamType
>>> stream_index = 0
>>> frame_width = 1920
>>> frame_height = 1080
>>> frame_rate = 30.0
>>> video3d = Video3D("0")
>>> stream = video3d.stream_open(Video3DStreamType.DEPTH, stream_index,
...                              frame_rate, frame_width, frame_height,
...                              ImageFormat.ROW_MAJOR_INTERLEAVED_BGR, ImageDataType.UINT8)
...
>>> image_data = np.zeros((frame_height, frame_width, 3), dtype=np.uint8)
>>> video3d.start_streaming()
>>> for i in range(1000):
...     frame = stream.get_frame()
...     frame.get_data(image_data)
...     frame.release()
...     # ...
...
>>> video3d.stop_streaming()
>>> stream.close()
>>> video3d.close()
get_meters(data)

Gets the frame data in meters (only valid for depth streams).

Parameters

data (array_like) – An array to hold the frame data. data must point to memory large enough to hold the image (HxW array of singles).

Raises

MediaError – On non-zero return code. A suitable error message may be retrieved using get_error_message.

Example

Get the frame data in meters of the first 1000 frames from the depth stream.

>>> import numpy as np
>>> from quanser.multimedia import Video3D, ImageDataType, ImageFormat, Video3DStreamType
>>> stream_index = 0
>>> frame_width = 1280
>>> frame_height = 720
>>> frame_rate = 30.0
>>> video3d = Video3D("0")
>>> stream = video3d.stream_open(Video3DStreamType.DEPTH, stream_index,
...                              frame_rate, frame_width, frame_height,
...                              ImageFormat.ROW_MAJOR_GREYSCALE, ImageDataType.UINT8)
...
>>> image_data = np.zeros((frame_height, frame_width), dtype=np.float32)
>>> video3d.start_streaming()
>>> for i in range(1000):
...     frame = stream.get_frame()
...     frame.get_meters(image_data)
...     frame.release()
...     # ...
...
>>> video3d.stop_streaming()
>>> stream.close()
>>> video3d.close()
get_number()

Gets the frame number.

Raises

MediaError – On non-zero return code. A suitable error message may be retrieved using get_error_message.

Returns

The frame number.

Return type

int

Example

Get the frame number of the first 1000 frames from the depth stream.

>>> from quanser.multimedia import Video3D, ImageDataType, ImageFormat, Video3DStreamType
>>> video3d = Video3D("0")
>>> stream = video3d.stream_open(Video3DStreamType.DEPTH, 0, 30.0, 1280, 720,
...                              ImageFormat.ROW_MAJOR_GREYSCALE, ImageDataType.UINT8)
...
>>> video3d.start_streaming()
>>> for i in range(1000):
...     frame = stream.get_frame()
...     number = frame.get_number()
...     # ...
...     frame.release()
...
>>> video3d.stop_streaming()
>>> stream.close()
>>> video3d.close()
get_timestamp()

Gets the frame number.

Raises

MediaError – On non-zero return code. A suitable error message may be retrieved using get_error_message.

Returns

The timestamp in fractional seconds since January 1, 1970.

Return type

float

Example

Get the frame timestamp of the first 1000 frames from the depth stream.

>>> from quanser.multimedia import Video3D, ImageDataType, ImageFormat, Video3DStreamType
>>> video3d = Video3D("0")
>>> stream = video3d.stream_open(Video3DStreamType.DEPTH, 0, 30.0, 1280, 720,
...                              ImageFormat.ROW_MAJOR_GREYSCALE, ImageDataType.UINT8)
...
>>> video3d.start_streaming()
>>> for i in range(1000):
...     frame = stream.get_frame()
...     timestamp = frame.get_timestamp()
...     # ...
...     frame.release()
...
>>> video3d.stop_streaming()
>>> stream.close()
>>> video3d.close()
release()

Releases the frame so that a new frame may be captured.

Raises

MediaError – On non-zero return code. A suitable error message may be retrieved using get_error_message.

Example

Capture and process 1000 frames from the depth stream.

>>> from quanser.multimedia import Video3D, ImageDataType, ImageFormat, Video3DStreamType
>>> video3d = Video3D("0")
>>> stream = video3d.stream_open(Video3DStreamType.DEPTH, 0, 30.0, 1280, 720,
...                              ImageFormat.ROW_MAJOR_GREYSCALE, ImageDataType.UINT8)
...
>>> video3d.start_streaming()
>>> for i in range(1000):
...     frame = stream.get_frame()
...     # Process...
...     frame.release()
...
>>> video3d.stop_streaming()
>>> stream.close()
>>> video3d.close()