trainf_ocr_class_knnT_trainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnn (Operator)

Name

trainf_ocr_class_knnT_trainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnn — Trains an k-NN classifier for an OCR task.

Signature

trainf_ocr_class_knn( : : OCRHandle, TrainingFile, GenParamName, GenParamValue : )

Herror T_trainf_ocr_class_knn(const Htuple OCRHandle, const Htuple TrainingFile, const Htuple GenParamName, const Htuple GenParamValue)

void TrainfOcrClassKnn(const HTuple& OCRHandle, const HTuple& TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue)

void HOCRKnn::TrainfOcrClassKnn(const HTuple& TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const

void HOCRKnn::TrainfOcrClassKnn(const HString& TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const

void HOCRKnn::TrainfOcrClassKnn(const char* TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const

void HOCRKnn::TrainfOcrClassKnn(const wchar_t* TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const   (Windows only)

static void HOperatorSet.TrainfOcrClassKnn(HTuple OCRHandle, HTuple trainingFile, HTuple genParamName, HTuple genParamValue)

void HOCRKnn.TrainfOcrClassKnn(HTuple trainingFile, HTuple genParamName, HTuple genParamValue)

void HOCRKnn.TrainfOcrClassKnn(string trainingFile, HTuple genParamName, HTuple genParamValue)

Description

trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnn trains the k-NN classifier OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle with the training characters stored in the OCR training files given by TrainingFileTrainingFileTrainingFileTrainingFiletrainingFile. The training files must have been created, e.g., using write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf, before calling trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnn. Please, note that training characters that have no corresponding class in the classifier OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle are discarded.

It is possible to set the number of trees via the parameters GenParamNameGenParamNameGenParamNameGenParamNamegenParamName and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue by 'num_trees'"num_trees""num_trees""num_trees""num_trees". The default value for the number of search trees is 4. A higher number of trees improves the accuracy of the search, but also increases the runtime. Normalization can be activated by setting 'normalization'"normalization""normalization""normalization""normalization" in GenParamNameGenParamNameGenParamNameGenParamNamegenParamName and and 'true'"true""true""true""true" in GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue. This will change the stored training data permanently. Therefore, adding data after the training is not possible.

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_knn HOCRKnn, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the k-NN classifier.

TrainingFileTrainingFileTrainingFileTrainingFiletrainingFile (input_control)  filename.read(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Names of the training files.

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

File extension: .trf, .otr

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

Names of the generic parameters that can be adjusted for the k-NN classifier creation.

Default value: []

List of values: 'normalization'"normalization""normalization""normalization""normalization", 'num_trees'"num_trees""num_trees""num_trees""num_trees"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue (input_control)  number-array HTupleHTupleHtuple (integer / string / real) (int / long / string / double) (Hlong / HString / double) (Hlong / char* / double)

Values of the generic parameters that can be adjusted for the k-NN classifier creation.

Default value: []

Suggested values: 4, 5, 'false'"false""false""false""false", 'true'"true""true""true""true"

Example (HDevelop)

* Train an OCR classifier
read_ocr_trainf_names ('ocr.trf', CharacterNames, CharacterCount)
create_ocr_class_knn (8, 10, 'constant', 'default', CharacterNames, [],\
                      [], OCRHandle)
trainf_ocr_class_knn (OCRHandle, 'ocr.trf', [], [])
write_ocr_class_knn (OCRHandle, 'ocr.omc')

Result

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

Possible Predecessors

create_ocr_class_knncreate_ocr_class_knnCreateOcrClassKnnCreateOcrClassKnnCreateOcrClassKnn, write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf, append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfAppendOcrTrainf, write_ocr_trainf_imagewrite_ocr_trainf_imageWriteOcrTrainfImageWriteOcrTrainfImageWriteOcrTrainfImage

Possible Successors

do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnn, do_ocr_multi_class_knndo_ocr_multi_class_knnDoOcrMultiClassKnnDoOcrMultiClassKnnDoOcrMultiClassKnn

Alternatives

read_ocr_class_knnread_ocr_class_knnReadOcrClassKnnReadOcrClassKnnReadOcrClassKnn

See also

train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnn

Module

OCR/OCV