trainf_ocr_class_svmT_trainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm (Operator)

Name

trainf_ocr_class_svmT_trainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm — Train an OCR classifier.

Signature

trainf_ocr_class_svm( : : OCRHandle, TrainingFile, Epsilon, TrainMode : )

Herror T_trainf_ocr_class_svm(const Htuple OCRHandle, const Htuple TrainingFile, const Htuple Epsilon, const Htuple TrainMode)

void TrainfOcrClassSvm(const HTuple& OCRHandle, const HTuple& TrainingFile, const HTuple& Epsilon, const HTuple& TrainMode)

void HOCRSvm::TrainfOcrClassSvm(const HTuple& TrainingFile, double Epsilon, const HTuple& TrainMode) const

void HOCRSvm::TrainfOcrClassSvm(const HString& TrainingFile, double Epsilon, const HString& TrainMode) const

void HOCRSvm::TrainfOcrClassSvm(const char* TrainingFile, double Epsilon, const char* TrainMode) const

void HOCRSvm::TrainfOcrClassSvm(const wchar_t* TrainingFile, double Epsilon, const wchar_t* TrainMode) const   ( Windows only)

static void HOperatorSet.TrainfOcrClassSvm(HTuple OCRHandle, HTuple trainingFile, HTuple epsilon, HTuple trainMode)

void HOCRSvm.TrainfOcrClassSvm(HTuple trainingFile, double epsilon, HTuple trainMode)

void HOCRSvm.TrainfOcrClassSvm(string trainingFile, double epsilon, string trainMode)

def trainf_ocr_class_svm(ocrhandle: HHandle, training_file: MaybeSequence[str], epsilon: float, train_mode: Union[str, int]) -> None

Description

trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm trains the OCR classifier OCRHandleOCRHandleOCRHandleOCRHandleocrhandle with the training characters stored in the OCR training files given by TrainingFileTrainingFileTrainingFiletrainingFiletraining_file. The training files must have been created, e.g., using write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf, before calling trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm. The parameters EpsilonEpsilonEpsilonepsilonepsilon and TrainModeTrainModeTrainModetrainModetrain_mode have the same meaning as in train_class_svmtrain_class_svmTrainClassSvmTrainClassSvmtrain_class_svm. Please, note that training characters that have no corresponding class in the classifier OCRHandleOCRHandleOCRHandleOCRHandleocrhandle are discarded.

Execution Information

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters

OCRHandleOCRHandleOCRHandleOCRHandleocrhandle (input_control, state is modified)  ocr_svm HOCRSvm, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the OCR classifier.

TrainingFileTrainingFileTrainingFiletrainingFiletraining_file (input_control)  filename.read(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Names of the training files.

Default: 'ocr.trf' "ocr.trf" "ocr.trf" "ocr.trf" "ocr.trf"

File extension: .trf, .otr

EpsilonEpsilonEpsilonepsilonepsilon (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Stop parameter for training.

Default: 0.001

Suggested values: 0.00001, 0.0001, 0.001, 0.01, 0.1

TrainModeTrainModeTrainModetrainModetrain_mode (input_control)  number HTupleUnion[str, int]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Mode of training.

Default: 'default' "default" "default" "default" "default"

List of values: 'add_sv_to_train_set'"add_sv_to_train_set""add_sv_to_train_set""add_sv_to_train_set""add_sv_to_train_set", 'default'"default""default""default""default"

Example (HDevelop)

* Train an OCR classifier
read_ocr_trainf_names ('ocr.trf', CharacterNames, CharacterCount)
create_ocr_class_svm (8, 10, 'constant', 'default', CharacterNames, \
                      'rbf', 0.01, 0.01, 'one-versus-one', \
                      'normalization', 81, OCRHandle)
trainf_ocr_class_svm (OCRHandle, 'ocr.trf', 0.001, 'default')
write_ocr_class_svm (OCRHandle, 'ocr.osc')

Result

If the parameters are valid the operator trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm returns the value 2 ( H_MSG_TRUE) . If necessary, an exception is raised.

trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm may return the error 9211 (Matrix is not positive definite) if PreprocessingPreprocessingPreprocessingpreprocessingpreprocessing = 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates" is used. This typically indicates that not enough training samples have been stored for each class. In this case we recommend to change PreprocessingPreprocessingPreprocessingpreprocessingpreprocessing to 'normalization'"normalization""normalization""normalization""normalization". Another solution can be to add more training samples.

Possible Predecessors

create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm, write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf, append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfappend_ocr_trainf, write_ocr_trainf_imagewrite_ocr_trainf_imageWriteOcrTrainfImageWriteOcrTrainfImagewrite_ocr_trainf_image

Possible Successors

do_ocr_single_class_svmdo_ocr_single_class_svmDoOcrSingleClassSvmDoOcrSingleClassSvmdo_ocr_single_class_svm, do_ocr_multi_class_svmdo_ocr_multi_class_svmDoOcrMultiClassSvmDoOcrMultiClassSvmdo_ocr_multi_class_svm, write_ocr_class_svmwrite_ocr_class_svmWriteOcrClassSvmWriteOcrClassSvmwrite_ocr_class_svm

Alternatives

read_ocr_class_svmread_ocr_class_svmReadOcrClassSvmReadOcrClassSvmread_ocr_class_svm

See also

train_class_svmtrain_class_svmTrainClassSvmTrainClassSvmtrain_class_svm

Module

OCR/OCV