CInstanceSegmentationTask

class ikomia.dataprocess.pydataprocess.CInstanceSegmentationTask

Base class for instance segmentation task in Computer Vision. It consists in detecting object instances of various classes and compute pixel mask of each instance. Common outputs for such task are bounding boxes and binary masks for each instance and color labelled image for visualization. It defines a task with the following properties:

Inputs:

Outputs:

Derived from C2dImageTask.

Import

from ikomia.dataprocess import CInstanceSegmentationTask

Methods

__init__(arg1)

__init__( (object)self) -> None :

add_object(self, id, type, class_index, ...)

Add segmented instance result localized in image through regular bounding box and mask.

get_names(self)

Get class names.

get_results(self)

Get instance segmentation results as a CInstanceSegmentationIO instance.

get_image_with_graphics(self)

Get visualization image where all extracted information are embedded (graphics items).

get_image_with_mask(self)

Get a visualization image composed by original input image and colored segmentation mask.

get_image_with_mask_and_graphics(self)

Get a visualization image composed by original input image, colored segmentation mask and embedded graphics (object detection).

read_class_names(self, path)

Populate class names from the given text file (one line per class).

set_colors(self, colors)

Set colors associated with class names.

set_names(self, names)

Set class names.

emit_add_sub_progress_steps(self, count)

See emit_add_sub_progress_steps().

emit_graphics_context_changed(self)

See emit_graphics_context_changed().

emit_output_changed(self)

See emit_output_changed().

emit_step_progress(self)

See emit_step_progress().

Overridden methods

Inherited methods

add_input(self, input)

Add new input to the task.

add_output(self, output)

Add new output to the task.

apply_graphics_mask(self, origin, processed, ...)

Apply the mask generated from graphics to the result image so that only masked areas seems to be processed.

apply_graphics_mask_to_binary(self, origin, ...)

Apply the mask generated from graphics to the binary source image.

begin_task_run(self)

See begin_task_run().

create_input_graphics_mask(self, index, ...)

Generate a binary mask image from the task graphics input at the specified index.

create_graphics_mask(self, width, height, ...)

Generate a binary mask image from the given graphics input object.

execute_actions(self, action)

Method called when a specific action is requested from the associated widget (see emit_send_process_action()).

forward_input_image(self, input_index, ...)

Forward input image at position input_index to output at position output_index.

get_elapsed_time(self)

Get the time of the last execution in milliseconds.

get_graphics_mask(self, index)

Get the binary mask generated from graphics input at position index.

get_input(self, index)

Get input at position index.

get_input_count(self)

Get the number of inputs.

get_input_data_type(self, index)

Get input data type at position index.

get_inputs(self)

Get the whole list of inputs.

get_output(self, index)

Get output at position index.

get_output_count(self)

Get the number of outputs.

get_output_data_type(self, index)

Get output data type at position index.

get_outputs(self)

Get the whole list of outputs.

get_parameters(self)

Get values of task parameters.

get_progress_steps(self)

See get_progress_steps().

global_input_changed(self, is_new_sequence)

See global_input_changed().

graphics_changed(self)

See graphics_changed().

is_graphics_changed_listening(self)

Check whether the task is listening to graphics changed event.

is_mask_available(self, index)

Check whether a binary mask from graphics input is available at position index.

parameters_modified(self)

Notify that the task parameters have changed.

remove_input(self, index)

Remove input at the given position.

run(self)

See run().

set_action_flag(self, action, is_enable)

Enable or disable the given action.

set_active(self, is_active)

See set_active().

set_input(self, input, index)

Set input at position index with the given one.

set_input_data_type(self, data_type, index)

Set the data type for the input at position index.

set_inputs(self, inputs)

Set the whole list of inputs with the given one.

set_output(self, output, index)

Set output at position index with the given one.

set_output_color_map(self, index, ...)

Bind a display color map to an image output.

set_output_data_type(self, data_type, index)

Set the data type for the output at position index.

set_outputs(self, outputs)

Set the whole list of outputs with the given one.

set_parameters(self, values)

Set values of task parameters.

stop(self)

See stop().

update_static_outputs(self)

Determine output data type automatically from input data types.

Attributes

name

Task name (must be unique)

type

Main purpose or data type on which the task is dedicated to.

Details

__init__((object)arg1) None
__init__( (object)self) -> None :

Default constructor

__init__( (object)self, (str)name) -> None :

Construct CInstanceSegmentationTask object with the given name.

Args:

name (str): task name, must be unique

add_object((CInstanceSegmentationTask)self, (int)id, (int)type, (int)class_index, (float)confidence, (float)x, (float)y, (float)width, (float)height, (object)mask) None :

Add segmented instance result localized in image through regular bounding box and mask.

Parameters:
  • id (int) – instance identifier

  • type (int) – segmentation instance type (0:THING - 1:STUFF)

  • class_index (int) – index of the associated class

  • confidence (float) – confidence of the prediction

  • x (float) – left coordinate of object bounding box

  • y (float) – top coordinate of object bounding box

  • width (float) – width of object bounding box

  • height (float) – height of object bounding box

  • mask (numpy array) – binary mask

get_names((CInstanceSegmentationTask)self) object :

Get class names. Call read_class_names() to populate names from text file.

Returns:

class names

Return type:

str list

get_results((CInstanceSegmentationTask)self) CInstanceSegmentationIO :

Get instance segmentation results as a CInstanceSegmentationIO instance.

Returns:

semantic segmentation data

Return type:

CInstanceSegmentationIO

get_image_with_graphics((CInstanceSegmentationTask)self) object :

Get visualization image where all extracted information are embedded (graphics items).

Returns:

visualization image

Return type:

2D Numpy array

get_image_with_mask((CInstanceSegmentationTask)self) object :

Get a visualization image composed by original input image and colored segmentation mask. A transparency factor is applied to see both information.

Returns:

color mask image

Return type:

2D numpy array (3 channels)

get_image_with_mask_and_graphics((CInstanceSegmentationTask)self) object :

Get a visualization image composed by original input image, colored segmentation mask and embedded graphics (object detection). A transparency factor is applied between original image and mask.

Returns:

visualization image

Return type:

2D numpy array (3 channels)

read_class_names((CInstanceSegmentationTask)self, (str)path) None :

Populate class names from the given text file (one line per class).

Parameters:

path (str) – path to class names definition file

set_colors((CInstanceSegmentationTask)self, (object)colors) None :

Set colors associated with class names. The given list must have the same size as names list. If not provided, random colors are generated while populating the name list (read_class_names()).

Parameters:

list (colors (list of) – r, g, b integer values in range [0, 255])

set_names((CInstanceSegmentationTask)self, (object)names) None :

Set class names. The function generate associated random colors if none is defined.

Parameters:

names (list of str)

emit_add_sub_progress_steps((CInstanceSegmentationTask)self, (int)count) None :

See emit_add_sub_progress_steps().

emit_graphics_context_changed((CInstanceSegmentationTask)self) None :

See emit_graphics_context_changed().

emit_output_changed((CInstanceSegmentationTask)self) None :

See emit_output_changed().

emit_step_progress((CInstanceSegmentationTask)self) None :

See emit_step_progress().

end_task_run((CInstanceSegmentationTask)self) None :

See end_task_run().

end_task_run( (CInstanceSegmentationTask)self) -> None