Name
write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainf — Storing of training characters into a file.
The operator write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf serves to prepare
the training with the operator trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlp or
trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmTrainfOcrClassSvm.
Hereby regions, representing characters, including their
gray values (region and pixel) and the corresponding class name
will be written into a file. An arbitrary number of regions within one
image is supported. For each character (region) in CharacterCharacterCharacterCharactercharacter
the corresponding class name must be specified in ClassClassClassClassclassVal.
The gray values are passed via the parameter ImageImageImageImageimage.
If no file extension is specified in TrainingFileTrainingFileTrainingFileTrainingFiletrainingFile the extension
'.trf' is appended to the file name. The version of the file format
used for writing data can be defined by the parameter
'ocr_trainf_version'"ocr_trainf_version""ocr_trainf_version""ocr_trainf_version""ocr_trainf_version" of the operator set_systemset_systemSetSystemSetSystemSetSystem.
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Characters to be trained.
Gray values of the characters.
Class (name) of the characters.
Name of the training file.
Default value:
'train_ocr'
"train_ocr"
"train_ocr"
"train_ocr"
"train_ocr"
File extension: .trf
char name[128];
HTuple Class,Name;
read_image(&Image,"character.tiff");
binary_threshold(Image,&Dark, 'otsu', 'dark', &UsedThreshold);
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",name);
set_s(Class,name,i);
}
create_tuple(&Name,1);
set_s(Class,Name,"trainfile");
T_write_ocr_trainf(Character,Image,Class,Name);
If the parameters are correct, the operator
write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf returns the value 2 (H_MSG_TRUE).
Otherwise an exception will be raised.
thresholdthresholdThresholdThresholdThreshold,
connectionconnectionConnectionConnectionConnection,
read_ocr_trainfread_ocr_trainfReadOcrTrainfReadOcrTrainfReadOcrTrainf
trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlp,
trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmTrainfOcrClassSvm
OCR/OCV