sim2bot.CameraFrame.image¶
image() -> Any
¶
Decode the frame to a NumPy BGR image.
JPEG and raw RGBA frames are supported. Raw WebGL frames are vertically flipped and converted from RGBA to BGR. H.264 decoding is reserved for a future implementation.
Returns:
-
Any–A
height × width × 3uint8 BGR NumPy array. A truncated raw frame -
Any–returns
None.
Raises:
-
RuntimeError–If the optional OpenCV/NumPy dependencies are absent.
-
NotImplementedError–If the frame uses the reserved H.264 codec.
Examples:
Install sim2bot[cv2], then decode a received frame::
frame = stream.read(timeout=2.0)
if frame is not None:
image_bgr = frame.image()
Source code in sim2bot/client.py
Practical examples¶
Examples use objects discovered from the current scene rather than hard-coded robot metadata.
Decode for OpenCV
Save a frame
Guidance¶
Usage tip
OpenCV uses BGR channel order. Convert to RGB before passing pixels to libraries that expect RGB.
Common error
H.264 decoding is not implemented yet; subscribe with codec="jpeg" or codec="raw".