Skip to content

create_ocr_class_boxCreateOcrClassBoxCreateOcrClassBoxcreate_ocr_class_boxT_create_ocr_class_box🔗

Short description🔗

create_ocr_class_boxCreateOcrClassBoxCreateOcrClassBoxcreate_ocr_class_boxT_create_ocr_class_box — Create a new OCR-classifier.

Warning🔗

create_ocr_class_boxCreateOcrClassBox 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( integer WidthPattern, integer HeightPattern, integer Interpolation, string Features, string Character, out ocr_box OcrHandle )void CreateOcrClassBox( const HTuple& WidthPattern, const HTuple& HeightPattern, const HTuple& Interpolation, const HTuple& Features, const HTuple& Character, HTuple* OcrHandle )static void HOperatorSet.CreateOcrClassBox( HTuple widthPattern, HTuple heightPattern, HTuple interpolation, HTuple features, HTuple character, out HTuple ocrHandle )def create_ocr_class_box( width_pattern: int, height_pattern: int, interpolation: int, features: MaybeSequence[str], character: Sequence[str] ) -> HHandle

Herror T_create_ocr_class_box( 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)

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

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 )

Description🔗

The operator create_ocr_class_boxCreateOcrClassBox creates a new OCR classifier. This classifier must then be trained with the help of the operators traind_ocr_class_boxTraindOcrClassBox or trainf_ocr_class_boxTrainfOcrClassBox.

The parameters WidthPatternwidthPatternwidth_pattern and HeightPatternheightPatternheight_pattern indicate the size of the input-layer of the network. This size is used for the features 'projection_horizontal'"projection_horizontal", 'projection_vertical'"projection_vertical", 'pixel'"pixel", 'pixel_invar'"pixel_invar", and '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 Interpolationinterpolationinterpolation 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_imageAffineTransImage. The value 00 results in the same interpolation as 'nearest_neighbor'"nearest_neighbor" in affine_trans_imageAffineTransImage, i.e., no interpolation is performed. For 11, the same behavior as 'constant'"constant" in affine_trans_imageAffineTransImage is obtained, i.e., equally weighted interpolation between adjacent pixels is used. Finally, 22 results in the same interpolation as 'weighted'"weighted", i.e., Gaussian interpolation between adjacent pixels is used. The parameter Interpolationinterpolationinterpolation must be chosen such that no aliasing occurs when the character is scaled to the standard size. Typically, this means that Interpolationinterpolationinterpolation should be set to 11, except in cases where the characters are scaled down by a large amount, in which case Interpolationinterpolationinterpolation = 22 should be chosen. Interpolationinterpolationinterpolation = 00 should only be chosen if the characters will not be scaled.

The parameter Charactercharactercharacter 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 Charactercharactercharacter) is limited to 20482048.

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

The following features are available:

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

  • 'ratio'"ratio" Ratio of the character.

  • 'width'"width" Width of the character (not invariant to scaling).

  • 'height'"height" Height of the character (not invariant to scaling).

  • 'zoom_factor'"zoom_factor" Difference in size between the current character and the values of WidthPatternwidthPatternwidth_pattern and HeightPatternheightPatternheight_pattern (not invariant to scaling).

  • 'foreground'"foreground" Relative number of pixels in the foreground.

  • '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" Relative number of foreground pixels in a 4x4 grid within the surrounding rectangle of the character.

  • 'anisometry'"anisometry" Form feature anisometry.

  • 'compactness'"compactness" Form feature compactness.

  • 'convexity'"convexity" Form feature convexity.

  • 'moments_region_2nd_invar'"moments_region_2nd_invar" Normed 2nd geometric moments of the region. See also moments_region_2nd_invarMomentsRegion2ndInvar.

  • 'moments_region_2nd_rel_invar'"moments_region_2nd_rel_invar" Normed 2nd relative geometric moments of the region. See also moments_region_2nd_rel_invarMomentsRegion2ndRelInvar.

  • 'moments_region_3rd_invar'"moments_region_3rd_invar" Normed 3rd geometric moments of the region. See also moments_region_3rd_invarMomentsRegion3rdInvar.

  • 'moments_central'"moments_central" Normed central geometric moments of the region. See also moments_region_centralMomentsRegionCentral.

  • 'phi'"phi" Sine and cosine of the orientation (angle) of the character.

  • 'num_connect'"num_connect" Number of connecting components.

  • 'num_holes'"num_holes" Number of holes.

  • 'projection_horizontal'"projection_horizontal" Horizontal projection of the gray values.

  • 'projection_horizontal_invar'"projection_horizontal_invar" Horizontal projection of the gray values with are automatically scaled to maximum range.

  • 'projection_vertical'"projection_vertical" Vertical projection of the gray values.

  • 'projection_vertical_invar'"projection_vertical_invar" Vertical projection of the gray values with are automatically scaled to maximum range.

  • 'cooc'"cooc" Values of the binary co-occurrence matrix.

  • 'moments_gray_plane'"moments_gray_plane" Normed gray value moments and the angles of the gray value level.

  • 'num_runs'"num_runs" Number of chords in the region normed to the height.

  • 'chord_histo'"chord_histo" Frequency of the chords per row (not scale-invariant).

  • 'pixel'"pixel" Gray value of the character.

  • 'pixel_invar'"pixel_invar" Gray values of the character with automatic maximal scaling of the gray values.

  • 'pixel_binary'"pixel_binary" Region of the character as a binary image zoomed to a size of WidthPatternwidthPatternwidth_pattern x HeightPatternheightPatternheight_pattern.

  • '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🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

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🔗

WidthPatternwidthPatternwidth_pattern (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of the input layer of the network.

Default: 88
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 201, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20
Value range: 1 ≤ WidthPattern ≤ 100

HeightPatternheightPatternheight_pattern (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of the input layer of the network.

Default: 1010
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 201, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20
Value range: 1 ≤ HeightPattern ≤ 100

Interpolationinterpolationinterpolation (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Interpolation mode concerning scaling of characters.

Default: 11
List of values: 0, 1, 20, 1, 2

Featuresfeaturesfeatures (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Additional features.

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

Charactercharactercharacter (input_control) string-array → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

All characters of a set.

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

OcrHandleocrHandleocr_handle (output_control) ocr_box → (handle)HTuple (HHandle)HOCRBox, HTuple (IntPtr)HHandleHtuple (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_boxCreateOcrClassBox returns the value 2 (H_MSG_TRUE). Otherwise an exception will be raised.

Combinations with other operators🔗

Combinations

Possible predecessors

reset_obj_dbResetObjDb

Possible successors

traind_ocr_class_boxTraindOcrClassBox, trainf_ocr_class_boxTrainfOcrClassBox, info_ocr_class_boxInfoOcrClassBox, write_ocrWriteOcr, ocr_change_charOcrChangeChar

Alternatives

create_ocr_class_mlpCreateOcrClassMlp, create_ocr_class_svmCreateOcrClassSvm

See also

affine_trans_imageAffineTransImage, ocr_change_charOcrChangeChar, moments_region_2nd_invarMomentsRegion2ndInvar, moments_region_2nd_rel_invarMomentsRegion2ndRelInvar, moments_region_3rd_invarMomentsRegion3rdInvar, moments_region_centralMomentsRegionCentral

Module🔗

OCR/OCV