trainf_ocr_class_knnT_trainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnntrainf_ocr_class_knn (算子名称)
名称
trainf_ocr_class_knnT_trainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnntrainf_ocr_class_knn — Trains an k-NN classifier for an OCR task.
参数签名
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)
描述
trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnntrainf_ocr_class_knn trains the k-NN classifier
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle with the training characters stored in the OCR
training files given by TrainingFileTrainingFileTrainingFileTrainingFiletrainingFiletraining_file. The training files
must have been created, e.g., using write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf, before
calling trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnntrainf_ocr_class_knn. Please, note that training characters
that have no corresponding class in the classifier OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle are
discarded.
It is possible to set the number of trees via
the parameters GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value by
'num_trees'"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""normalization" in
GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and 'true'"true""true""true""true""true" in GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value.
This will change the stored training data permanently. Therefore,
adding data after the training is not possible.
运行信息
- 多线程类型:可重入(与非独占操作符并行运行)。
- 多线程作用域:全局(可以从任何线程调用)。
- 未经并行化处理。
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.
参数表
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle (input_control, state is modified) ocr_knn → HOCRKnn, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Handle of the k-NN classifier.
TrainingFileTrainingFileTrainingFileTrainingFiletrainingFiletraining_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"
"ocr.trf"
File extension:
.trf, .otr
GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control) string-array → HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Names of the generic parameters that can be adjusted
for the k-NN classifier creation.
Default:
[]
List of values:
'normalization'"normalization""normalization""normalization""normalization""normalization", 'num_trees'"num_trees""num_trees""num_trees""num_trees""num_trees"
GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control) number-array → HTupleSequence[Union[int, str, float]]HTupleHtuple (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:
[]
Suggested values:
4, 5, 'false'"false""false""false""false""false", 'true'"true""true""true""true""true"
例程 (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')
结果
如果参数均有效,算子
trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnntrainf_ocr_class_knn 返回值 2 (
H_MSG_TRUE)
. If necessary,
an exception is raised.
可能的前置算子
create_ocr_class_knncreate_ocr_class_knnCreateOcrClassKnnCreateOcrClassKnnCreateOcrClassKnncreate_ocr_class_knn,
write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf,
append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfAppendOcrTrainfappend_ocr_trainf,
write_ocr_trainf_imagewrite_ocr_trainf_imageWriteOcrTrainfImageWriteOcrTrainfImageWriteOcrTrainfImagewrite_ocr_trainf_image
可能的后置算子
do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnndo_ocr_single_class_knn,
do_ocr_multi_class_knndo_ocr_multi_class_knnDoOcrMultiClassKnnDoOcrMultiClassKnnDoOcrMultiClassKnndo_ocr_multi_class_knn
可替代算子
read_ocr_class_knnread_ocr_class_knnReadOcrClassKnnReadOcrClassKnnReadOcrClassKnnread_ocr_class_knn
参考其它
train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnntrain_class_knn
模块
OCR/OCV