vision_system.camera moduleο
- class vision_system.camera.Camera(color_image_topic: str = '/camera/color/image_raw', depth_image_topic: str = '/camera/depth/image_raw', camera_info_topic: str = '/camera/depth/camera_info', frames_approx_sync: bool = False, depth_frame_encoding: str = '32FC1')ο
Bases:
Node
Camera class for acquiring images (color and depth) from an RGBD-camera.
This class is responsible for subscribing to the image and depth topics making it easy to access to camera frames, converting the images using cv_bridge, and optionally applying post-processing.
Parametersο
- color_image_topicstr, optional
The topic for color images (default is β/camera/color/image_rawβ).
- depth_image_topicstr, optional
The topic for depth images (default is β/camera/depth/image_rawβ).
- camera_info_topicstr, optional
The topic for camera information (default is β/camera/depth/camera_infoβ).
- frames_approx_syncbool, optional
Whether to use approximate time synchronization (default is False).
- depth_frame_encodingstr, optional
The encoding of the depth frame (default is β32FC1β).
- acquire_color_frame_once() ndarray | None ο
Acquires a single color frame waiting for the topic.
- Returns:
The acquired color frame as a cv2 image as NumPy array, or None if acquisition fails.
- acquire_frames_once() Tuple[ndarray | None, ndarray | None] ο
Acquires a single pair of color and depth frames.
- Returns:
A tuple of (color_frame, depth_frame) as NumPy arrays, or (None, None) if acquisition fails.
- get_camera_info() CameraInfo | None ο
Retrieves the camera info.
- Returns:
The camera info as a CameraInfo object, or None if it has not been retrieved.
- get_color_frame() ndarray | None ο
Retrieves the most recently acquired color frame.
- Returns:
The color frame as a NumPy array, or None if no frame is available.
- get_distance_frame() ndarray | None ο
Retrieves the most recently acquired depth frame.
- Returns:
The depth frame as a NumPy array, or None if no frame is available.
- get_frame_id() str | None ο
Retrieves the frame ID from the camera info.
- Returns:
The frame ID as a string, or None if camera info is not available.
- get_frames() Tuple[ndarray, ndarray] | None ο
Retrieves the most recently acquired color and depth frames.
- Returns:
A tuple of (color_frame, depth_frame) as NumPy arrays, or None if frames are not available.
- process_once() ndarray | None ο
Processes a single pair of color and depth frames using the provided post-processing function.
- Returns:
Processed frames or None if acquisition or processing fails.
- retrieve_camera_info() bool ο
Retrieves the camera info waiting for the topic and stores it in the class.
- Returns:
True if camera info is successfully retrieved, False otherwise.
- set_processing_function(package_name: str, module_name: str, class_name: str) None ο
Dynamically loads and sets the post-processing function.
- Parameters:
package_name β The name of the package containing the post-processing module.
module_name β The name of the module containing the post-processing class.
class_name β The name of the post-processing class.
- Raises:
Exception if loading fails or if the class is not an instance of PostProcessing.
- start_acquire() None ο
Starts the acquisition of synchronized color and depth frames, with post-processing.
- start_acquire_only_color() None ο
Starts the acquisition of color frames only, with post-processing (is necessary to spin the node).