robokudo.annotators.cluster_color

Classes

Color

Generic enumeration.

ClusterColorAnnotator

Calculate the semantic color for every Object Hypothesis (cluster) that has a RGB ROI and

Module Contents

class robokudo.annotators.cluster_color.Color

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

RED = (0,)
YELLOW = (1,)
GREEN = (2,)
CYAN = (3,)
BLUE = (4,)
MAGENTA = (5,)
WHITE = (6,)
BLACK = (7,)
GREY = (8,)
class robokudo.annotators.cluster_color.ClusterColorAnnotator(name='ClusterColorAnnotator', descriptor=Descriptor())

Bases: robokudo.annotators.core.BaseAnnotator

Calculate the semantic color for every Object Hypothesis (cluster) that has a RGB ROI and a Mask

class Descriptor

Bases: robokudo.annotators.core.BaseAnnotator.Descriptor

class Parameters
num_of_colors = 6
color_range = 42.666666666666664
jit_compile_on_init = False
min_value_color = 60
min_saturation_color = 60
max_value_black = 60
min_value_white = 120
ratio_annotation_threshold = 0.2
analysis_scope
parameters
color_name_to_bgr_values
color_hue_positions
cluster_color_info = []
cluster_rois = []
count_colors_numba(hsv_image: numpy.typing.NDArray, mask: numpy.typing.NDArray)

Wrapper function for the numba version of the count colors method. The wrapper handles the pythonic/object style data and prepares everything for the requirements of the numba method.

Parameters:
  • hsv_image

  • mask

Returns:

A tuple with the number of analyzed pixels (given by the mask) as well as a dict with the counted

colors. The key is a Color enum from this module.

static count_colors_numba_impl(hsv_image: numpy.typing.NDArray, mask: numpy.typing.NDArray, total_amount_of_colors: int, min_saturation_color: int, min_value_color: int, max_value_black: int, min_value_white: int, number_of_colors: int, color_range: float)

Iterate over the masked pixels on a given hsv image to count how many pixels can be assigned to the defined color ranges. Requires the numba library and passes the required parameters to avoid class access and object-mode from numba.

Parameters:
  • hsv_image

  • mask

  • total_amount_of_colors

  • min_saturation_color

  • min_value_color

  • max_value_black

  • min_value_white

  • number_of_colors

  • color_range

Returns:

A tuple with the number of analyzed pixels (given by the mask) as well as a numpy array with the counted

colors. The id refers the indices of the Color enum from this module.

count_colors(hsv_image: numpy.typing.NDArray, mask: numpy.typing.NDArray)

Non-numba version of the count_colors_numba_impl method. Use only if you can’t use numba. Warning: Seems to contain a bug in color counting.

Parameters:
  • hsv_image

  • mask

Returns:

update()
create_color_annotations(color)
draw_visualization(visualization_img)