append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainf (Operator)

Name

append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainf — Add characters to a training file.

Signature

append_ocr_trainf(Character, Image : : Class, TrainingFile : )

Herror append_ocr_trainf(const Hobject Character, const Hobject Image, const char* Class, const char* TrainingFile)

Herror T_append_ocr_trainf(const Hobject Character, const Hobject Image, const Htuple Class, const Htuple TrainingFile)

void AppendOcrTrainf(const HObject& Character, const HObject& Image, const HTuple& Class, const HTuple& TrainingFile)

void HRegion::AppendOcrTrainf(const HImage& Image, const HTuple& Class, const HString& TrainingFile) const

void HRegion::AppendOcrTrainf(const HImage& Image, const HString& Class, const HString& TrainingFile) const

void HRegion::AppendOcrTrainf(const HImage& Image, const char* Class, const char* TrainingFile) const

void HRegion::AppendOcrTrainf(const HImage& Image, const wchar_t* Class, const wchar_t* TrainingFile) const   (Windows only)

static void HOperatorSet.AppendOcrTrainf(HObject character, HObject image, HTuple classVal, HTuple trainingFile)

void HRegion.AppendOcrTrainf(HImage image, HTuple classVal, string trainingFile)

void HRegion.AppendOcrTrainf(HImage image, string classVal, string trainingFile)

Description

The operator append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfAppendOcrTrainf 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. In contrast to the operator write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf the characters are appended to an existing file using the same training file format as this file. If the file does not exist, a new file is generated. In this case, the file format can be chosen by the parameter 'ocr_trainf_version'"ocr_trainf_version""ocr_trainf_version""ocr_trainf_version""ocr_trainf_version" of the operator set_systemset_systemSetSystemSetSystemSetSystem. If no file extension is specified in TrainingFileTrainingFileTrainingFileTrainingFiletrainingFile, the extension '.trf' is appended to the name.

Execution Information

Parameters

CharacterCharacterCharacterCharactercharacter (input_object)  region(-array) objectHRegionHRegionHobject

Characters to be trained.

ImageImageImageImageimage (input_object)  singlechannelimage objectHImageHImageHobject (byte / uint2)

Gray values of the characters.

ClassClassClassClassclassVal (input_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Class (name) of the characters.

TrainingFileTrainingFileTrainingFileTrainingFiletrainingFile (input_control)  filename.write HTupleHTupleHtuple (string) (string) (HString) (char*)

Name of the training file.

Default value: 'train_ocr' "train_ocr" "train_ocr" "train_ocr" "train_ocr"

File extension: .trf, .otr

Example (C)

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

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);
  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_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfAppendOcrTrainf returns the value 2 (H_MSG_TRUE). Otherwise an exception will be raised.

Possible Predecessors

thresholdthresholdThresholdThresholdThreshold, connectionconnectionConnectionConnectionConnection, read_ocr_trainfread_ocr_trainfReadOcrTrainfReadOcrTrainfReadOcrTrainf

Possible Successors

trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlp, trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmTrainfOcrClassSvm, write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf

Alternatives

write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf, write_ocr_trainf_imagewrite_ocr_trainf_imageWriteOcrTrainfImageWriteOcrTrainfImageWriteOcrTrainfImage

Module

OCR/OCV