create_ocr_class_boxT_create_ocr_class_boxCreateOcrClassBoxCreateOcrClassBoxcreate_ocr_class_box (Operator)

Name

create_ocr_class_boxT_create_ocr_class_boxCreateOcrClassBoxCreateOcrClassBoxcreate_ocr_class_box — Create a new OCR-classifier.

Warning

create_ocr_class_boxcreate_ocr_class_boxCreateOcrClassBoxCreateOcrClassBoxCreateOcrClassBoxcreate_ocr_class_box is obsolete and is only provided for reasons of backward compatibility. New applications should use the MLP, SVM or CNN based operators instead.

Signature

create_ocr_class_box( : : WidthPattern, HeightPattern, Interpolation, Features, Character : OcrHandle)

Herror T_create_ocr_class_box(const Htuple WidthPattern, const Htuple HeightPattern, const Htuple Interpolation, const Htuple Features, const Htuple Character, Htuple* OcrHandle)

void CreateOcrClassBox(const HTuple& WidthPattern, const HTuple& HeightPattern, const HTuple& Interpolation, const HTuple& Features, const HTuple& Character, HTuple* OcrHandle)

void HOCRBox::HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HTuple& Features, const HTuple& Character)

void HOCRBox::HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HString& Features, const HTuple& Character)

void HOCRBox::HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const char* Features, const HTuple& Character)

void HOCRBox::HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const wchar_t* Features, const HTuple& Character)   (Windows only)

void HOCRBox::CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HTuple& Features, const HTuple& Character)

void HOCRBox::CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HString& Features, const HTuple& Character)

void HOCRBox::CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const char* Features, const HTuple& Character)

void HOCRBox::CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const wchar_t* Features, const HTuple& Character)   (Windows only)

static void HOperatorSet.CreateOcrClassBox(HTuple widthPattern, HTuple heightPattern, HTuple interpolation, HTuple features, HTuple character, out HTuple ocrHandle)

public HOCRBox(int widthPattern, int heightPattern, int interpolation, HTuple features, HTuple character)

public HOCRBox(int widthPattern, int heightPattern, int interpolation, string features, HTuple character)

void HOCRBox.CreateOcrClassBox(int widthPattern, int heightPattern, int interpolation, HTuple features, HTuple character)

void HOCRBox.CreateOcrClassBox(int widthPattern, int heightPattern, int interpolation, string features, HTuple character)

def create_ocr_class_box(width_pattern: int, height_pattern: int, interpolation: int, features: MaybeSequence[str], character: Sequence[str]) -> HHandle

Description

The operator create_ocr_class_boxcreate_ocr_class_boxCreateOcrClassBoxCreateOcrClassBoxCreateOcrClassBoxcreate_ocr_class_box creates a new OCR classifier. For a description of this classifier see operator learn_class_boxlearn_class_boxLearnClassBoxLearnClassBoxLearnClassBoxlearn_class_box. This classifier must then be trained with the help of the operators traind_ocr_class_boxtraind_ocr_class_boxTraindOcrClassBoxTraindOcrClassBoxTraindOcrClassBoxtraind_ocr_class_box or trainf_ocr_class_boxtrainf_ocr_class_boxTrainfOcrClassBoxTrainfOcrClassBoxTrainfOcrClassBoxtrainf_ocr_class_box.

The parameters WidthPatternWidthPatternWidthPatternWidthPatternwidthPatternwidth_pattern and HeightPatternHeightPatternHeightPatternHeightPatternheightPatternheight_pattern indicate the size of the input-layer of the network. This size is used for the features 'projection_horizontal'"projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal", 'projection_vertical'"projection_vertical""projection_vertical""projection_vertical""projection_vertical""projection_vertical", 'pixel'"pixel""pixel""pixel""pixel""pixel", 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar", and 'pixel_binary'"pixel_binary""pixel_binary""pixel_binary""pixel_binary""pixel_binary" to transform the character to a standard size. The bigger the standard size is, the more characters can be distinguished. Hereby the amount of time necessary for the training (as well as the number of training random samples) and the time necessary for the recognition, however, will increase as well. The parameter InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation indicates the interpolation mode concerning the adaptation of characters in the image to the network. For more detailed information on this parameter see also affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image. The value 0 results in the same interpolation as 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor" in affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image, i.e., no interpolation is performed. For 1, the same behavior as 'constant'"constant""constant""constant""constant""constant" in affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image is obtained, i.e., equally weighted interpolation between adjacent pixels is used. Finally, 2 results in the same interpolation as 'weighted'"weighted""weighted""weighted""weighted""weighted", i.e., Gaussian interpolation between adjacent pixels is used. The parameter InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation must be chosen such that no aliasing occurs when the character is scaled to the standard size. Typically, this means that InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation should be set to 1, except in cases where the characters are scaled down by a large amount, in which case InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 2 should be chosen. InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 0 should only be chosen if the characters will not be scaled.

The parameter CharacterCharacterCharacterCharactercharactercharacter determines all the characters which have to be recognized. Normally the transmitted strings consist of one character (e.g. alphabet). But also strings of any length can be learned. The number of distinguishable characters (number of strings in CharacterCharacterCharacterCharactercharactercharacter) is limited to 2048.

The parameter FeaturesFeaturesFeaturesFeaturesfeaturesfeatures helps to chose additional features besides gray values in order to recognize characters.

The following features are available:

'default'"default""default""default""default""default"

'ratio'"ratio""ratio""ratio""ratio""ratio" and 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar" are selected.

'ratio'"ratio""ratio""ratio""ratio""ratio"

Ratio of the character.

'width'"width""width""width""width""width"

Width of the character (not invariant to scaling).

'height'"height""height""height""height""height"

Height of the character (not invariant to scaling).

'zoom_factor'"zoom_factor""zoom_factor""zoom_factor""zoom_factor""zoom_factor"

Difference in size between the current character and the values of WidthPatternWidthPatternWidthPatternWidthPatternwidthPatternwidth_pattern and HeightPatternHeightPatternHeightPatternHeightPatternheightPatternheight_pattern (not invariant to scaling).

'foreground'"foreground""foreground""foreground""foreground""foreground"

Relative number of pixels in the foreground.

'foreground_grid_9'"foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9"

Relative number of foreground pixels in a 3x3 grid within the surrounding rectangle of the character.

'foreground_grid_16'"foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16"

Relative number of foreground pixels in a 4x4 grid within the surrounding rectangle of the character.

'anisometry'"anisometry""anisometry""anisometry""anisometry""anisometry"

Form feature anisometry.

'compactness'"compactness""compactness""compactness""compactness""compactness"

Form feature compactness.

'convexity'"convexity""convexity""convexity""convexity""convexity"

Form feature convexity.

'moments_region_2nd_invar'"moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar"

Normed 2nd geometric moments of the region. See also moments_region_2nd_invarmoments_region_2nd_invarMomentsRegion2ndInvarMomentsRegion2ndInvarMomentsRegion2ndInvarmoments_region_2nd_invar.

'moments_region_2nd_rel_invar'"moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar"

Normed 2nd relative geometric moments of the region. See also moments_region_2nd_rel_invarmoments_region_2nd_rel_invarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvarmoments_region_2nd_rel_invar.

'moments_region_3rd_invar'"moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar"

Normed 3rd geometric moments of the region. See also moments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvarMomentsRegion3rdInvarmoments_region_3rd_invar.

'moments_central'"moments_central""moments_central""moments_central""moments_central""moments_central"

Normed central geometric moments of the region. See also moments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentralMomentsRegionCentralmoments_region_central.

'phi'"phi""phi""phi""phi""phi"

Sine and cosine of the orientation (angle) of the character.

'num_connect'"num_connect""num_connect""num_connect""num_connect""num_connect"

Number of connecting components.

'num_holes'"num_holes""num_holes""num_holes""num_holes""num_holes"

Number of holes.

'projection_horizontal'"projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal"

Horizontal projection of the gray values.

'projection_horizontal_invar'"projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar"

Horizontal projection of the gray values with are automatically scaled to maximum range.

'projection_vertical'"projection_vertical""projection_vertical""projection_vertical""projection_vertical""projection_vertical"

Vertical projection of the gray values.

'projection_vertical_invar'"projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar"

Vertical projection of the gray values with are automatically scaled to maximum range.

'cooc'"cooc""cooc""cooc""cooc""cooc"

Values of the binary cooccurrence matrix.

'moments_gray_plane'"moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane"

Normed gray value moments and the angles of the gray value level.

'num_runs'"num_runs""num_runs""num_runs""num_runs""num_runs"

Number of chords in the region normed to the height.

'chord_histo'"chord_histo""chord_histo""chord_histo""chord_histo""chord_histo"

Frequency of the chords per row (not scale-invariant).

'pixel'"pixel""pixel""pixel""pixel""pixel"

Gray value of the character.

'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar"

Gray values of the character with automatic maximal scaling of the gray values.

'pixel_binary'"pixel_binary""pixel_binary""pixel_binary""pixel_binary""pixel_binary"

Region of the character as a binary image zoomed to a size of WidthPatternWidthPatternWidthPatternWidthPatternwidthPatternwidth_pattern x HeightPatternHeightPatternHeightPatternHeightPatternheightPatternheight_pattern.

'gradient_8dir'"gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir"

Gradients are computed on the character image. The gradient directions are discretized into 8 directions. The amplitude image is decomposed into 8 channels according to these discretized directions. 25 samples on a 5x5 grid are extracted from each channel. These samples are used as features.

Execution Information

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters

WidthPatternWidthPatternWidthPatternWidthPatternwidthPatternwidth_pattern (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Width of the input layer of the network.

Default value: 8

Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20

Typical range of values: 1 ≤ WidthPattern WidthPattern WidthPattern WidthPattern widthPattern width_pattern ≤ 100

HeightPatternHeightPatternHeightPatternHeightPatternheightPatternheight_pattern (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of the input layer of the network.

Default value: 10

Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20

Typical range of values: 1 ≤ HeightPattern HeightPattern HeightPattern HeightPattern heightPattern height_pattern ≤ 100

InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Interpolation mode concerning scaling of characters.

Default value: 1

List of values: 0, 1, 2

FeaturesFeaturesFeaturesFeaturesfeaturesfeatures (input_control)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Additional features.

Default value: 'default' "default" "default" "default" "default" "default"

List of values: 'anisometry'"anisometry""anisometry""anisometry""anisometry""anisometry", 'chord_histo'"chord_histo""chord_histo""chord_histo""chord_histo""chord_histo", 'compactness'"compactness""compactness""compactness""compactness""compactness", 'convexity'"convexity""convexity""convexity""convexity""convexity", 'cooc'"cooc""cooc""cooc""cooc""cooc", 'default'"default""default""default""default""default", 'foreground'"foreground""foreground""foreground""foreground""foreground", 'foreground_grid_16'"foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16", 'foreground_grid_9'"foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9", 'gradient_8dir'"gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir", 'height'"height""height""height""height""height", 'moments_central'"moments_central""moments_central""moments_central""moments_central""moments_central", 'moments_gray_plane'"moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane", 'moments_region_2nd_invar'"moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar", 'moments_region_2nd_rel_invar'"moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar", 'moments_region_3rd_invar'"moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar", 'num_connect'"num_connect""num_connect""num_connect""num_connect""num_connect", 'num_holes'"num_holes""num_holes""num_holes""num_holes""num_holes", 'num_runs'"num_runs""num_runs""num_runs""num_runs""num_runs", 'phi'"phi""phi""phi""phi""phi", 'pixel'"pixel""pixel""pixel""pixel""pixel", 'pixel_binary'"pixel_binary""pixel_binary""pixel_binary""pixel_binary""pixel_binary", 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar", 'projection_horizontal'"projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal", 'projection_horizontal_invar'"projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar", 'projection_vertical'"projection_vertical""projection_vertical""projection_vertical""projection_vertical""projection_vertical", 'projection_vertical_invar'"projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar", 'ratio'"ratio""ratio""ratio""ratio""ratio", 'width'"width""width""width""width""width", 'zoom_factor'"zoom_factor""zoom_factor""zoom_factor""zoom_factor""zoom_factor"

CharacterCharacterCharacterCharactercharactercharacter (input_control)  string-array HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

All characters of a set.

Default value: ['a','b','c'] ["a","b","c"] ["a","b","c"] ["a","b","c"] ["a","b","c"] ["a","b","c"]

OcrHandleOcrHandleOcrHandleOcrHandleocrHandleocr_handle (output_control)  ocr_box HOCRBox, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

ID of the created OCR classifier.

Example (C)

HTuple     WidthPattern,HeightPattern,Interpolation,
           Features,OcrHandle;
create_tuple(&WidthPattern,1);
set_i(WidthPattern,8,0);
create_tuple(&HeightPattern,1);
set_i(HeightPattern,10,0);
create_tuple(&Interpolation,1);
set_i(Interpolation,1,0);
create_tuple(&Features,1);
set_s(Features,"default",0);
create_tuple(&Character,26+26+10);
set_s(Character,"a",0);
set_s(Character,"b",1);
/* ... */
set_s(Character,"A",27);
set_s(Character,"B",28);
/* ... */
set_s(Character,"1",53);
set_s(Character,"2",54);
/* ... */
T_create_ocr_class_box(WidthPattern,HeightPattern,Interpolation,
                       Features,Character,&OcrHandle);

Result

If the parameters are correct, the operator create_ocr_class_boxcreate_ocr_class_boxCreateOcrClassBoxCreateOcrClassBoxCreateOcrClassBoxcreate_ocr_class_box returns the value TRUE. Otherwise an exception will be raised.

Possible Predecessors

reset_obj_dbreset_obj_dbResetObjDbResetObjDbResetObjDbreset_obj_db

Possible Successors

traind_ocr_class_boxtraind_ocr_class_boxTraindOcrClassBoxTraindOcrClassBoxTraindOcrClassBoxtraind_ocr_class_box, trainf_ocr_class_boxtrainf_ocr_class_boxTrainfOcrClassBoxTrainfOcrClassBoxTrainfOcrClassBoxtrainf_ocr_class_box, info_ocr_class_boxinfo_ocr_class_boxInfoOcrClassBoxInfoOcrClassBoxInfoOcrClassBoxinfo_ocr_class_box, write_ocrwrite_ocrWriteOcrWriteOcrWriteOcrwrite_ocr, ocr_change_charocr_change_charOcrChangeCharOcrChangeCharOcrChangeCharocr_change_char

Alternatives

create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp, create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm

See also

affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image, ocr_change_charocr_change_charOcrChangeCharOcrChangeCharOcrChangeCharocr_change_char, moments_region_2nd_invarmoments_region_2nd_invarMomentsRegion2ndInvarMomentsRegion2ndInvarMomentsRegion2ndInvarmoments_region_2nd_invar, moments_region_2nd_rel_invarmoments_region_2nd_rel_invarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvarmoments_region_2nd_rel_invar, moments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvarMomentsRegion3rdInvarmoments_region_3rd_invar, moments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentralMomentsRegionCentralmoments_region_central

Module

OCR/OCV