Herror ::append_ocr_trainf (
    Hobject Character,
    Hobject Image,
    const HTuple &Class,
    const HTuple &FileName
)
void HRegion::AppendOcrTrainf (
    const HImage &Image,
    const HTuple &Class,
    const HTuple &FileName
) const
void HRegionArray::AppendOcrTrainf (
    const HImage &Image,
    const HTuple &Class,
    const HTuple &FileName
) const

Adding characters to a training file.

The operator ::append_ocr_trainf serves to prepare the training with the operator ::trainf_ocr_class_box. Hereby regions, representing characters, including their grayvalues (region and pixel) and the corresponding classname will be written into a file. An arbitrary number of regions within one image is supported. For each character (region) in Character the corresponding class name must be specified in Class. The grayvalues are passed via the parameter Image. The file name can be chosen at will. In contrast to ::write_ocr_trainf the characters are appended to the file. If the file does not exist a new file is generated.


Parameters

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

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

Class (input_control)
string(-array) -> HTuple.char *
Class (name) of the characters.

FileName (input_control)
filename -> HTuple.char *
Name of the training file.
Default value: ''train_ocr''


Example
char       name[128];
char       class[128];

read_image(&Image,"character.tiff");
bin_threshold(Image,&Dark);
connection(Dark,&Character);
count_obj(Character,&num);
create_tuple(&Class,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",class);
  append_ocr_trainf(Character,Image,name,class);
}

Result

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


Possible Predecessors

::threshold, ::connection, ::create_ocr_class_box, ::read_ocr


Possible Successors

::trainf_ocr_class_box, ::info_ocr_class_box, ::write_ocr, ::do_ocr_multi, ::do_ocr_single


Alternatives

::write_ocr_trainf, ::write_ocr_trainf_image


Module

Optical character recognition



Copyright © 1996-2002 MVTec Software GmbH