Herror ::create_ocr_class_box (
    const HTuple &WidthPattern,
    const HTuple &HeightPattern,
    const HTuple &Interpolation,
    const HTuple &Features,
    const HTuple &Character,
    long *OcrHandle
)

Creating a new OCR-classifier.

The operator ::create_ocr_class_box creates a new OCR classifier. For a description of this classifier see operator ::learn_class_box. This classifier must then be trained with the help of the operators ::traind_ocr_class_box or ::trainf_ocr_class_box.

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

The parameter Character 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 Character) is limited to 2048.

The parameter Features helps to chose additional features besides grayvalues in order to recognize characters. By using 'default' the features 'ratio' ans 'pixel_invar' will be set.

The following features are available:

  'ratio'
      Ratio of the character.

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

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

  'zoom_factor' 
      Difference in size between the current character and the
      values of WidthPattern and HeightPattern
      (not invariant to scaling).

  'foreground'
      Relative number of pixels in the foreground. 
	
  'foreground_grid_9'
      Relative number of foreground pixels in a 3 by 3 grid within
      the surrounding rectangle of the character.
  
  'foreground_grid_16'
      Relative number of foreground pixels in a 4 by 4 grid within
      the surrounding rectangle of the character.

  'anisometry'
      Form feature anisometry.

  'compactness']
      Form feature compactness.

  'convexity'
      Form feature convexity.

  'moments_region_2nd_invar'
      Normed 2nd geometric moments of the region. See also
      ::moments_region_2nd_invar. 
	
  'moments_region_2nd_rel_invar'
      Normed 2nd relativ geometric moments of the region. See also
      ::moments_region_2nd_rel_invar.
	
  'moments_region_3rd_invar'
      Normed 3rd geometric moments of the region. See also
      ::moments_region_3rd_invar.
	
  'moments_central'
      Normed central geometric moments of the region. See also
      ::moments_region_central.

  'phi'
      Orientation (angle) of the character.

  'num_connect'
      Number of connected components. 

  'num_holes'
      Number of holes.

  'projection_horizontal'
      Horizontal projection of the grayvalues.

  'projection_horizontal_invar'
      Horizontal projection of the grayvalues with are automatically
	scaled to maximum range.

  'projection_vertical'
      Vertical projection of the grayvalues.

  'projection_vertical_invar'
      Vertical projection of the grayvalues with are automatically
      scaled to maximum range.

  'cooc'
      Values of the binary cooccurrence matrix.

  'moments_gray_plane']
      Normed grayvalue moments and the angles of the grayvalue level. 

  'num_runs'
      Number of chords in the region normed to the area. 

  'chord_histo'
      Frequency of the chords per row. 

  'pixel'
      Grayvalues of the character. 

  'pixel_invar'
      Grayvalues of the character with automatic maximal scaling
	of the gray values. 


Parameters

WidthPattern (input_control)
integer -> HTuple.long
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 <= 100

HeightPattern (input_control)
integer -> HTuple.long
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 <= 100

Interpolation (input_control)
integer -> HTuple.long
Interpolation mode concerning scaling of characters.
Default value: 1
List of values: 0, 1, 2

Features (input_control)
string(-array) -> HTuple.char *
Additional features.
Default value: 'default'
List of values: 'default', 'zoom_factor', 'ratio', 'width', 'height', 'foreground', 'foreground_grid_9', 'foreground_grid_16', 'anisometry', 'compactness', 'convexity', 'moments_region_2nd_invar', 'moments_region_2nd_rel_invar', 'moments_region_3rd_invar', 'moments_central', 'phi', 'num_connect', 'num_holes', 'projection_horizontal', 'projection_vertical', 'projection_horizontal_invar', 'projection_vertical_invar', 'chord_histo', 'num_runs', 'pixel', 'pixel_invar', 'cooc', 'moments_gray_plane'

Character (input_control)
string-array -> HTuple.char *
All characters of a set.
Default value: '['a','b','c']'

OcrHandle (output_control)
ocr -> long *
ID of the created OCR classifier.


Example
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_box returns the value H_MSG_TRUE. Otherwise an exception will be raised.


Possible Predecessors

::reset_obj_db


Possible Successors

::traind_ocr_class_box, ::trainf_ocr_class_box, ::info_ocr_class_box, ::write_ocr, ::ocr_change_char


See also

::affine_trans_image, ::ocr_change_char, ::moments_region_2nd_invar, ::moments_region_2nd_rel_invar, ::moments_region_3rd_invar, ::moments_region_central


Module

Optical character recognition



Copyright © 1996-2002 MVTec Software GmbH