CVideoOFTask#

class ikomia.dataprocess.pydataprocess.CVideoOFTask#

Add optical flow specific features for methods based on OpenCV framework. This class handles the persistent data required to compute classical optical flow algorithms. It also offers a way to display the computed flow as a color map.

Derived from CVideoTask.

Import

from ikomia.dataprocess import CVideoOFTask

Methods

__init__(arg1)

__init__( (object)self) -> None :

draw_opt_flow_map(self, flow, vectors, step)

Draw optical flow vectors in the optical flow map (image).

flow_to_display(self, flow)

Generate a displayable image of the optical flow color map.

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 CVideoTask.begin_task_run().

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

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

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().

end_task_run(self)

See end_task_run().

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(arg1, selfis_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.

notify_video_end(self)

Notify that the end of the video is reached.

notify_video_start(self, frame_count)

Notify that the video has started.

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 CVideoOFTask object with the given name. Same inputs and outputs as CVideoTask.

Args:

name (str): task name, must be unique

add_input((CWorkflowTask)self, (CWorkflowTaskIO)input) None :#

Add new input to the task.

Args:

input (CWorkflowTaskIO based object): input object

add_input( (CWorkflowTask)self, (CWorkflowTaskIO)input) -> None

add_output((CWorkflowTask)self, (CWorkflowTaskIO)output) None :#

Add new output to the task.

Args:

output (CWorkflowTaskIO based object): output object

add_output( (CWorkflowTask)self, (CWorkflowTaskIO)output) -> None

apply_graphics_mask((C2dImageTask)self, (object)origin, (object)processed, (int)index) object :#

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

Parameters:
  • origin (Numpy array) – input image of the task

  • processed (Numpy array) – result image of the task

  • index (int) – zero-based index of the mask

Returns:

result image

Return type:

Numpy array

apply_graphics_mask_to_binary((C2dImageTask)self, (object)origin, (object)processed, (int)index) object :#

Apply the mask generated from graphics to the binary source image. Only white areas on both image and mask are kept in the result image.

Parameters:
  • origin (Numpy array) – input image of the task

  • processed (Numpy array) – result image of the task

  • index (int) – zero-based index of the mask

Returns:

result image

Return type:

Numpy array

begin_task_run((CVideoOFTask)self) None :#

See CVideoTask.begin_task_run().

begin_task_run( (CVideoOFTask)self) -> None

create_graphics_mask((C2dImageTask)self, (int)width, (int)height, (CGraphicsInput)graphics) None :#

Generate a binary mask image from the given graphics input object. The new mask is appended to the internal mask list. Use get_graphics_mask() to retrieve the mask.

Parameters:
  • width (int) – mask width (should be the width of the source image)

  • height (int) – mask height (should be the height of the source image)

  • graphics (CGraphicsInput) – graphics items become white blobs in the black background mask

draw_opt_flow_map((CVideoOFTask)self, (object)flow, (object)vectors, (int)step) object :#

Draw optical flow vectors in the optical flow map (image).

Parameters:
  • flow (Numpy array) – source optical flow (store vector coordinates of the optical flow)

  • map (flow) – color map of the optical flow

  • step (int) – sampling step

Returns:

full visualization image (color map + vectors)

Return type:

Numpy array

emit_add_sub_progress_steps((CVideoOFTask)self, (int)count) None :#

See emit_add_sub_progress_steps().

emit_graphics_context_changed((CVideoOFTask)self) None :#

See emit_graphics_context_changed().

emit_output_changed((CVideoOFTask)self) None :#

See emit_output_changed().

emit_step_progress((CVideoOFTask)self) None :#

See emit_step_progress().

end_task_run((CVideoOFTask)self) None :#

See end_task_run().

end_task_run( (CVideoOFTask)self) -> None

execute_actions((CVideoOFTask)self, (int)action) None :#

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

Args:

action (int): action code

execute_actions( (CVideoOFTask)self, (int)action) -> None

flow_to_display((CVideoOFTask)self, (object)flow) object :#

Generate a displayable image of the optical flow color map.

Parameters:

flow (Numpy array) – source optical flow color map

Returns:

displayable color image (3 channels)

Return type:

Numpy array

forward_input_image((C2dImageTask)self, (int)input_index, (int)output_index) None :#

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

Parameters:
  • input_index (int) – zero-based index of the input

  • output_index (int) – zero-based index of the output

get_elapsed_time((CWorkflowTask)self) float :#

Get the time of the last execution in milliseconds.

Returns:

elapsed time in ms

Return type:

float

get_graphics_mask((C2dImageTask)self, (int)index) object :#

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

Parameters:

index (int) – zero-based index of the mask

Returns:

binary mask (8 bits - 1 channel)

Return type:

Numpy array

get_input((CWorkflowTask)self, (int)index) CWorkflowTaskIO :#

Get input at position index.

Parameters:

index (int) – zero-based input index

Returns:

input object

Return type:

CWorkflowTaskIO based object

get_input_count((CWorkflowTask)self) int :#

Get the number of inputs.

Returns:

inputs count

Return type:

int

get_input_data_type((CWorkflowTask)self, (int)index) IODataType :#

Get input data type at position index. This data type can differ from the original type because it can change at runtime according to the data source.

Parameters:

index (int) – zero-based input index

Returns:

input data type

Return type:

IODataType

get_inputs((CWorkflowTask)self) object :#

Get the whole list of inputs.

Returns:

input objects

Return type:

list of CWorkflowTaskIO based objects

get_output((CWorkflowTask)self, (int)index) CWorkflowTaskIO :#

Get output at position index.

Parameters:

index (int) – zero-based output index

Returns:

output object

Return type:

CWorkflowTaskIO based object

get_output_count((CWorkflowTask)self) int :#

Get the number of outputs.

Returns:

outputs count

Return type:

int

get_output_data_type((CWorkflowTask)self, (int)index) IODataType :#

Get output data type at position index. This data type can differ from the original type because it can change at runtime according to the data source.

Parameters:

index (int) – zero-based output index

Returns:

output data type

Return type:

IODataType

get_outputs((CWorkflowTask)self) object :#

Get the whole list of outputs.

Returns:

output objects

Return type:

list of CWorkflowTaskIO based objects

get_parameters((CWorkflowTask)self) object :#

Get values of task parameters.

Returns:

string pairs (parameter name, value)

Return type:

dict

get_progress_steps((CVideoOFTask)self) int :#

See get_progress_steps().

get_progress_steps( (CVideoOFTask)self) -> int

global_input_changed((CVideoOFTask)arg1, (bool)selfis_new_sequence) None :#

See global_input_changed().

global_input_changed( (CVideoOFTask)arg1, (bool)selfis_new_sequence) -> None

graphics_changed((CVideoOFTask)self) None :#

See graphics_changed().

graphics_changed( (CVideoOFTask)self) -> None

is_graphics_changed_listening((CWorkflowTask)self) bool :#

Check whether the task is listening to graphics changed event.

Returns:

bool: True or False

is_graphics_changed_listening( (CWorkflowTask)self) -> bool

is_mask_available((C2dImageTask)self, (int)index) bool :#

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

Parameters:

index (int) – zero-based index of the mask

Returns:

True if mask is available, False otherwise

Return type:

bool

notify_video_end((CVideoOFTask)self) None :#

Notify that the end of the video is reached.

notify_video_end( (CVideoOFTask)self) -> None

notify_video_start((CVideoOFTask)self, (int)frame_count) None :#

Notify that the video has started.

Args:

frame_count (int): total number of frames

notify_video_start( (CVideoOFTask)self, (int)frame_count) -> None

parameters_modified((CWorkflowTask)self) None :#

Notify that the task parameters have changed. This method can be overriden to implement custom actions when this event happens. The method does nothing in this base class.

parameters_modified( (CWorkflowTask)self) -> None

remove_input((CWorkflowTask)self, (int)index) None :#

Remove input at the given position.

Parameters:

index (int) – zero-based input index

run((CVideoOFTask)self) None :#

See run().

run( (CVideoOFTask)self) -> None

set_action_flag((CWorkflowTask)self, (ActionFlag)action, (bool)is_enable) None :#

Enable or disable the given action. If the action does not exist, it is added to the list.

Parameters:
  • action (ActionFlag) – action to enable or disable

  • is_enable (bool) – True or False

set_active((CVideoOFTask)self, (bool)is_active) None :#

See set_active().

set_active( (CVideoOFTask)self, (bool)is_active) -> None

set_input((CWorkflowTask)self, (CWorkflowTaskIO)input, (int)index) None :#

Set input at position index with the given one. If the input at position index does not exist, the function creates as many generic inputs to reach the number of index+1 and sets the input at position index.

Args:

input_tot (CWorkflowTaskIO based object)

index (int): zero-based input index

set_input( (CWorkflowTask)self, (CWorkflowTaskIO)input, (int)index) -> None

set_input_data_type((CWorkflowTask)self, (IODataType)data_type, (int)index) None :#

Set the data type for the input at position index. If the input at position index does not exist, the function creates as many generic inputs to reach the number of index+1 and sets the data type for the input at position index.

Args:

data_type (IODataType): input data type

index (int): zero-based input index

set_input_data_type( (CWorkflowTask)self, (IODataType)data_type, (int)index) -> None

set_inputs((CWorkflowTask)self, (object)inputs) None :#

Set the whole list of inputs with the given one.

Args:

inputs (list of CWorkflowTaskIO based objects)

set_inputs( (CWorkflowTask)self, (object)inputs) -> None

set_output((CWorkflowTask)self, (CWorkflowTaskIO)output, (int)index) None :#

Set output at position index with the given one. If the output at position index does not exist, the function creates as many generic outputs to reach the number of index+1 and sets the output at position index.

Args:

output (CWorkflowTaskIO based object)

index (int): zero-based output index

set_output( (CWorkflowTask)self, (CWorkflowTaskIO)output, (int)index) -> None

set_output_color_map((C2dImageTask)self, (int)index, (int)mask_index, (object)colors, (bool)reserve_zero) None :#

Bind a display color map to an image output. The color mask is generated from an output mask generated by the task itself (binary or labelled image).

Parameters:
  • index (int) – zero-based index of the output to be displayed with the color map. The output must be a CImageIO or derived.

  • mask_index (int) – zero-based index of the output representing the mask used to generate the color overlay.

  • colors (list) – list of tuples (r,g,b values) for the color map. If empty, the system generates random colors.

  • reserve_zero (bool) – reserve zero pixels of the mask for background so that it will appear transparent in Ikomia Studio.

set_output_data_type((CWorkflowTask)self, (IODataType)data_type, (int)index) None :#

Set the data type for the output at position index. If the output at position index does not exist, the function creates as many generic outputs to reach the number of index+1 and sets the data type for the output at position index.

Args:

data_type (IODataType): output data type

index (int): zero-based output index

set_output_data_type( (CWorkflowTask)self, (IODataType)data_type, (int)index) -> None

set_outputs((CWorkflowTask)self, (object)outputs) None :#

Set the whole list of outputs with the given one.

Args:

outputs (list of CWorkflowTaskIO based objects)

set_outputs( (CWorkflowTask)self, (object)outputs) -> None

set_parameters((CWorkflowTask)self, (object)values) None :#

Set values of task parameters.

Parameters:

values (dict) – string pairs (parameter name, value)

stop((CVideoOFTask)self) None :#

See stop().

stop( (CVideoOFTask)self) -> None

update_static_outputs((CVideoOFTask)self) None :#

Determine output data type automatically from input data types. Don’t forget to call this method in overriden methods. See update_static_outputs().

update_static_outputs( (CVideoOFTask)self) -> None