CTextIO

class ikomia.dataprocess.pydataprocess.CTextIO

Define input or output managing common information extracted by OCR task. Such task are able to automatically detect text fields in image and get class label, text value, confidence and polygon for each one. For each field, information are stored in a CTextField instance.

Import

from ikomia.dataprocess import CTextIO

Methods

__init__(arg1)

__init__( (object)self) -> None :

add_text_field(self, id, label, text, ...)

Add detected text fields with bounding box.

finalize(self)

Method to call after all fields are added.

get_graphics_io(self)

Get internal graphics output instance.

get_text_field_count(self)

Get the number of detected text fields.

get_text_field(self, index)

Get text field information at a given index.

get_text_fields(self)

Get all detected text fields.

init(self, task_name, ref_image_index)

Initialisation step to set associated task (name) and reference image.

Overridden methods

clear_data(self)

See clear_data().

is_data_available(self)

See is_data_available().

load(self, path)

Load text field detection input/output from JSON file.

save(self, path)

Save text field detection input/output to JSON file.

to_json(self)

Return input/output data in JSON formatted string (compact mode).

from_json(self, json_str)

Set input/output data from JSON formatted string.

Inherited methods

copy_static_data(self, io)

Copy the static data from the given input or ouput.

get_unit_element_count(self)

Get the number of unit elements in terms of processing scheme.

Attributes

auto_save

Auto-save status

data_type

I/O data type

dim_count

Number of dimensions

description

Custom description to explain input/output type and use

displayable

Displayable status (Ikomia Studio)

name

I/O name

source_file_path

Path to the source file used as workflow input (if any)

Details

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

Default constructor

__init__( (object)arg1, (CTextIO)arg2) -> None :

Copy constructor

add_text_field((CTextIO)self, (int)id, (str)label, (str)text, (float)confidence, (float)box_x, (float)box_y, (float)box_width, (float)box_height, (object)color) None :

Add detected text fields with bounding box.

Args:

id (int): object identifier

label (str): class label

text (str): field value

confidence (double): prediction confidence

box_x (double): left coordinate of object bounding box

box_y (double): top coordinate of object bounding box

box_width (double): width of object bounding box

box_height (double): height of object bounding box

color (int list - rgba): display color

add_text_field( (CTextIO)self, (int)id, (str)label, (str)text, (float)confidence, (object)polygon, (object)color) -> None :

Add detected text fields with polygon.

Args:

id (int): object identifier

label (str): class label

text (str): field value

confidence (double): prediction confidence

polygon (list of CPointF): polygon points coordinates

color (int list - rgba): display color

clear_data((CTextIO)self) None :

See clear_data().

clear_data( (CTextIO)self) -> None

finalize((CTextIO)self) None :

Method to call after all fields are added. It will compute data output that will be shown as table in Ikomia Studio.

get_graphics_io((CTextIO)self) CGraphicsOutput :

Get internal graphics output instance. It stores graphics items representing polygon, labels and value of detected text fields in image.

Returns:

graphics output instance

Return type:

CGraphicsOutput

get_text_field_count((CTextIO)self) int :

Get the number of detected text fields.

Returns:

object count

Return type:

int

get_text_field((CTextIO)self, (int)index) CTextField :

Get text field information at a given index.

Parameters:

index (int) – field index

Returns:

field information instance

Return type:

CTextField

get_text_fields((CTextIO)self) object :

Get all detected text fields.

Returns:

detected fields

Return type:

CTextField list

init((CTextIO)self, (str)task_name, (int)ref_image_index) None :

Initialisation step to set associated task (name) and reference image. The reference image is the task output index where the graphics information (label, box) will be displayed as an overlay layer.

Parameters:
  • task_name (str) – task that contains the output

  • ref_image_index (int) – zero-based index of the output containing the reference image

is_data_available((CTextIO)self) bool :

See is_data_available().

is_data_available( (CTextIO)self) -> bool

load((CTextIO)self, (str)path) None :

Load text field detection input/output from JSON file.

Args:

path (str): path to JSON file

load( (CTextIO)self, (str)path) -> None

save((CTextIO)self, (str)path) None :

Save text field detection input/output to JSON file.

Args:

path (str): path to JSON file

save( (CTextIO)self, (str)path) -> None

to_json((CTextIO)self) str :

Return input/output data in JSON formatted string (compact mode).

Returns:

string: JSON formatted string

to_json( (CTextIO)self) -> str

to_json( (CTextIO)self, (object)options) -> str :

Return input/output data in JSON formatted string. JSON format options can be set, possible values are:

  • [‘json_format’, ‘compact’] (default)

  • [‘json_format’, ‘indented’]

Args:

list of str: format-specific options encoded as pairs [option_name, option_value]

Returns:

string: JSON formatted string

to_json( (CTextIO)self, (object)options) -> str

from_json((CTextIO)self, (str)json_str) None :

Set input/output data from JSON formatted string.

Args:

str: data as JSON formatted string

from_json( (CTextIO)self, (str)json_str) -> None