robokudo.annotators.image_cluster_extractor

Image-based object cluster extraction.

This module provides functionality for extracting object clusters from color images using HSV color segmentation. The main class ImageClusterExtractor implements color-based segmentation and contour detection to identify object clusters in RGB images.

Key features:

  • HSV color space thresholding

  • Contour detection and filtering

  • 3D point cloud generation from depth data

  • ROI and mask generation

  • Query-based color parameter adjustment

  • Visualization of detected clusters

Classes

ImageClusterExtractor

Extract object clusters from images using color segmentation.

Functions

Module Contents

robokudo.annotators.image_cluster_extractor.on_trackbar(x)
class robokudo.annotators.image_cluster_extractor.ImageClusterExtractor(name='ImageClusterExtractor', descriptor=Descriptor())

Bases: robokudo.annotators.core.BaseAnnotator

Extract object clusters from images using color segmentation.

This annotator performs the following steps:

  • Converts RGB image to HSV color space

  • Applies HSV thresholding based on configured parameters

  • Detects and filters contours based on size

  • Generates point clouds from depth data for each contour

  • Creates ObjectHypothesis annotations with ROIs and masks

  • Provides visualization of detected clusters

The HSV thresholds can be adjusted dynamically based on color queries.

Variables:
  • color – Input RGB color image

  • depth – Input depth image

  • hsv – HSV converted color image

  • cam_intrinsics – Camera intrinsic parameters

  • query – Current color query if any

  • display_mode – Current visualization mode

class ViewMode

Visualization modes for the annotator output.

Variables:
  • masked_object – Show masked RGB image of detected objects

  • depth_mask – Show depth mask of detected objects

masked_object = 1
depth_mask = 2
class Descriptor

Bases: robokudo.annotators.core.BaseAnnotator.Descriptor

Configuration descriptor for ImageClusterExtractor.

Parameters:

  • HSV thresholding ranges

  • Contour filtering parameters

  • Point cloud generation settings

  • Color name to HSV range mappings

  • Outlier removal parameters

class Parameters

Parameter class containing all configurable settings.

hsv_min = (150, 130, 85)
hsv_max = (200, 255, 255)
erosion_iterations = 2
contour_min_size = 1000
color_name_to_hsv_range
outlier_removal = True
outlier_removal_nb_neighbors = 20
outlier_removal_std_ratio = 2.0
num_of_objects = 2
min_points_threshold = 62
parameters
dyn_rec_callback(config, level)
color = None
display_mode = 1
adjust_hsv_threshold_to_query() None

Adjust HSV thresholds based on color query.

Checks for a color query in the CAS and updates the HSV thresholding parameters if a matching color is found in the color_name_to_hsv_range mapping.

Returns:

None

update()

Process input images to detect and annotate object clusters.

The method:

  • Scales color image to match depth image

  • Converts to HSV and applies thresholding

  • Detects and filters contours

  • Generates point clouds for each contour

  • Creates ObjectHypothesis annotations

  • Generates visualization output

Returns:

SUCCESS if clusters found, FAILURE if no clusters

Return type:

py_trees.Status

Raises:

Exception – If no contours found or processing fails

send_empty_query_answer()

Send empty query result when no objects are found.

Creates and sets an empty QueryResult message on the blackboard.

Returns:

None

key_callback(key)

Handle keyboard input to change visualization mode.

Parameters:

key (int) – ASCII value of pressed key

Returns:

None