Herror ::traind_ocr_class_box (
    Hobject Character,
    Hobject Image,
    const HTuple &OcrHandle,
    const HTuple &Class,
    double *AvgConfidence
)
HTuple HRegion::TraindOcrClassBox (
    const HImage &Image,
    const HTuple &OcrHandle,
    const HTuple &Class
) const
HTuple HRegionArray::TraindOcrClassBox (
    const HImage &Image,
    const HTuple &OcrHandle,
    const HTuple &Class
) const

Training of an OCR classifier by the input of regions.

The operator ::traind_ocr_class_box trains the classifier directly via the input of regions in an image. Any number of regions of an image can be passed. For each character (region) in Character the corresponding name (class) Class must be specified. The grayvalues are passed in Image. When the procedure has finished the parameter AvgConfidence provides information about the success of the training: It contains the average confidence of the trained characters measured by a re-classification. The confidence of mismatched characters is set to 0 (thus, the average confidence will be decreased significantly).


Parameters

Character (input_object)
region(-array) -> Hobject: HRegion(Array)
Characters to be trained.

Image (input_object)
image -> Hobject: HImage
Grayvalues for the characters.

OcrHandle (input_control)
ocr -> HTuple.long
ID of the desired OCR-classifier.

Class (input_control)
string(-array) -> HTuple.char *
Class (name) of the characters.
Default value: ''a''

AvgConfidence (output_control)
real -> double *
Average confidence during a re-classification of the trained characters.


Example
char name[128];
long orc_handle;

read_ocr("testnet",&orc_handle);
read_image(&Image,"character.tiff");
bin_threshold(Image,&Dark);
connection(Dark,&Character);
count_obj(Character,&num);
open_window(0,0,-1,-1,0,"","",&WindowHandle);
set_color(WindowHandle,"red");
for (i=0; i<num; i++) {
  select_obj(Character,&SingleCharacter,i);
  clear_window(WindowHandle);
  disp_region(SingleCharacter,WindowHandle);
  printf("class of character %d ?\n",i);
  scanf("%s\n",name);
  traind_ocr_class_box(SingleCharacter,Image,OcrHandle,name,&AvgConfidence);
}

Result

If the parameters are correct, the operator ::traind_ocr_class_box returns the value H_MSG_TRUE. Otherwise an exception will be raised.


Possible Predecessors

::create_ocr_class_box, ::read_ocr


Possible Successors

::traind_ocr_class_box, ::write_ocr, ::do_ocr_multi, ::do_ocr_single


Alternatives

::trainf_ocr_class_box


Module

Optical character recognition



Copyright © 1996-2002 MVTec Software GmbH