cozmo.camera¶
Support for Cozmo’s camera.
Cozmo has a built-in camera which he uses to observe the world around him.
The Camera
class defined in this module is made available as
cozmo.world.World.camera
and can be used to enable/disable image
sending, enable/disable color images, modify various camera settings,
read the robot’s unique camera calibration settings, as well as observe
raw unprocessed images being sent by the robot.
Generally, however, it is more useful to observe
cozmo.world.EvtNewCameraImage
events, which include the raw camera
images along with annotated images, which can illustrate objects the robot
has identified.
Classes
Camera (robot, **kw) |
Represents Cozmo’s camera. |
CameraConfig (focal_length_x, focal_length_y, …) |
The fixed properties for Cozmo’s Camera |
EvtNewRawCameraImage (**kwargs) |
Dispatched when a new raw image is received from the robot’s camera. |
EvtRobotObservedMotion (**kwargs) |
Generated when the robot observes motion. |
-
class
cozmo.camera.
EvtNewRawCameraImage
(**kwargs)¶ Dispatched when a new raw image is received from the robot’s camera.
See also
EvtNewCameraImage
which provides access to both the raw image and a scaled and annotated version.-
image
= 'A PIL.Image.Image object'¶
-
-
class
cozmo.camera.
EvtRobotObservedMotion
(**kwargs)¶ Generated when the robot observes motion.
-
ground_area
= 'Area of the supporting region for the point, as a fraction of the ground ROI'¶
-
ground_pos
= 'Approximate coordinates of observed motion on the ground, relative to robot, in mm'¶
-
has_left_movement
= "Movement detected near the left edge of the robot's view"¶
-
has_right_movement
= "Movement detected near the right edge of the robot's view"¶
-
has_top_movement
= "Movement detected near the top of the robot's view"¶
-
img_area
= 'Area of the supporting region for the point, as a fraction of the image'¶
-
img_pos
= 'Centroid of observed motion, relative to top-left corner'¶
-
left_img_pos
= 'Coordinates of the centroid of observed motion, relative to top-left corner'¶
-
right_img_pos
= 'Coordinates of the centroid of observed motion, relative to top-left corner'¶
-
timestamp
= 'Robot timestamp for when movement was observed'¶
-
top_img_pos
= 'Coordinates of the centroid of observed motion, relative to top-left corner'¶
-
-
class
cozmo.camera.
CameraConfig
(focal_length_x: float, focal_length_y: float, center_x: float, center_y: float, fov_x_degrees: float, fov_y_degrees: float, min_exposure_time_ms: int, max_exposure_time_ms: int, min_gain: float, max_gain: float)¶ The fixed properties for Cozmo’s Camera
A full 3x3 calibration matrix for doing 3D reasoning based on the camera images would look like:
focal_length.x 0 center.x 0 focal_length.y center.y 0 0 1 -
center
¶ The focal center of the camera.
This is the position of the optical center of projection within the image. It will be close to the center of the image, but adjusted based on the calibration of the lens at the factory. It is in floating point pixel values e.g. <155.11, 111.40>.
Type: cozmo.util.Vector2
-
focal_length
¶ The focal length of the camera.
This is focal length combined with pixel skew (as the pixels aren’t perfectly square), so there are subtly different values for x and y. It is in floating point pixel values e.g. <288.87, 288.36>.
Type: cozmo.util.Vector2
-
fov_x
¶ The x (horizontal) field of view.
Type: cozmo.util.Angle
-
fov_y
¶ The y (vertical) field of view.
Type: cozmo.util.Angle
-
-
class
cozmo.camera.
Camera
(robot, **kw)¶ Represents Cozmo’s camera.
The Camera object receives images from Cozmo’s camera and emits EvtNewRawCameraImage events.
The
cozmo.world.World
instance observes the camera and provides more useful methods for accessing the camera images.Important
The camera will not receive any image data unless you explicitly enable it by setting
Camera.image_stream_enabled
toTrue
-
config
¶ The read-only config/calibration for the camera
Type: cozmo.camera.CameraConfig
-
enable_auto_exposure
(enable_auto_exposure=True)¶ Enable auto exposure on Cozmo’s Camera.
Enable auto exposure on Cozmo’s camera to constantly update the exposure time and gain values based on the recent images. This is the default mode when any SDK program starts.
Parameters: enable_auto_exposure (bool) – whether the camera should automcatically adjust exposure
-
is_auto_exposure_enabled
¶ True if auto exposure is currently enabled
If auto exposure is enabled the gain and exposure_ms values will constantly be updated by Cozmo.
Type: bool
-
set_manual_exposure
(exposure_ms, gain)¶ Set manual exposure values for Cozmo’s Camera.
Disable auto exposure on Cozmo’s camera and force the specified exposure time and gain values.
Parameters: - exposure_ms (int) – The desired exposure time in milliseconds.
Must be within the robot’s
config
exposure range frommin_exposure_time_ms
tomax_exposure_time_ms
- gain (float) – The desired gain value.
Must be within the robot’s
camera_config
gain range frommin_gain
tomax_gain
Raises: ValueError
if supplied an out-of-range exposure or gain.- exposure_ms (int) – The desired exposure time in milliseconds.
Must be within the robot’s
-