do_ocr_single_class_knnT_do_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnn (Operator)
Name
do_ocr_single_class_knnT_do_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnn
— Classify a single character with an OCR classifier.
Signature
void DoOcrSingleClassKnn(const HObject& Character, const HObject& Image, const HTuple& OCRHandle, const HTuple& NumClasses, const HTuple& NumNeighbors, HTuple* Class, HTuple* Confidence)
HTuple HRegion::DoOcrSingleClassKnn(const HImage& Image, const HOCRKnn& OCRHandle, const HTuple& NumClasses, const HTuple& NumNeighbors, HTuple* Confidence) const
HString HRegion::DoOcrSingleClassKnn(const HImage& Image, const HOCRKnn& OCRHandle, const HTuple& NumClasses, const HTuple& NumNeighbors, double* Confidence) const
HTuple HOCRKnn::DoOcrSingleClassKnn(const HRegion& Character, const HImage& Image, const HTuple& NumClasses, const HTuple& NumNeighbors, HTuple* Confidence) const
HString HOCRKnn::DoOcrSingleClassKnn(const HRegion& Character, const HImage& Image, const HTuple& NumClasses, const HTuple& NumNeighbors, double* Confidence) const
static void HOperatorSet.DoOcrSingleClassKnn(HObject character, HObject image, HTuple OCRHandle, HTuple numClasses, HTuple numNeighbors, out HTuple classVal, out HTuple confidence)
HTuple HRegion.DoOcrSingleClassKnn(HImage image, HOCRKnn OCRHandle, HTuple numClasses, HTuple numNeighbors, out HTuple confidence)
string HRegion.DoOcrSingleClassKnn(HImage image, HOCRKnn OCRHandle, HTuple numClasses, HTuple numNeighbors, out double confidence)
HTuple HOCRKnn.DoOcrSingleClassKnn(HRegion character, HImage image, HTuple numClasses, HTuple numNeighbors, out HTuple confidence)
string HOCRKnn.DoOcrSingleClassKnn(HRegion character, HImage image, HTuple numClasses, HTuple numNeighbors, out double confidence)
Description
do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnn
uses the OCR-k-NN classifier
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle
to determine the best training samples for the
features of the character given by the region CharacterCharacterCharacterCharactercharacter
and
the gray values ImageImageImageImageimage
and returns their classes in
ClassClassClassClassclassVal
and the corresponding confidences in ConfidenceConfidenceConfidenceConfidenceconfidence
.
If the first NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighbors
training vectors have different classes,
maximally NumClassesNumClassesNumClassesNumClassesnumClasses
classes are returned sorted by frequency
and weighted distance.
The confidences lie between 0.0 and 1.0. The larger the value, the
more reliable is the classification.
The confidence can be only computed robustly
if NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighbors
is large enough.
Because multiple classes may be returned by
do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnn
, CharacterCharacterCharacterCharactercharacter
may only contain
a single region (a single character). If multiple characters should
be classified in a single call, do_ocr_multi_class_knndo_ocr_multi_class_knnDoOcrMultiClassKnnDoOcrMultiClassKnnDoOcrMultiClassKnn
must
be used. Before calling do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnn
, the classifier must
be trained with trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnn
or
select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnn
.
If all NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighbors
neighbors are of the same class, only
one class is returned.
Execution Information
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Parameters
CharacterCharacterCharacterCharactercharacter
(input_object) region →
objectHRegionHRegionHobject
Character to be recognized.
ImageImageImageImageimage
(input_object) singlechannelimage →
objectHImageHImageHobject (byte / uint2)
Gray values of the character.
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle
(input_control) ocr_knn →
HOCRKnn, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Handle of the k-NN classifier.
NumClassesNumClassesNumClassesNumClassesnumClasses
(input_control) integer-array →
HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Number of maximal classes to determine.
Default value: 1
Suggested values: 1, 2, 3, 4, 5
NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighbors
(input_control) integer-array →
HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Number of neighbors to consider.
Default value: 1
Suggested values: 1, 2, 3, 4, 5
ClassClassClassClassclassVal
(output_control) string(-array) →
HTupleHTupleHtuple (string) (string) (HString) (char*)
Results of classifying the character with the
k-NN.
ConfidenceConfidenceConfidenceConfidenceconfidence
(output_control) real(-array) →
HTupleHTupleHtuple (real) (double) (double) (double)
Confidence(s) of the class(es) of the character.
Result
If the parameters are valid, the operator
do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnn
returns the value 2 (H_MSG_TRUE). If
necessary, an exception is raised.
Possible Predecessors
trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnn
,
read_ocr_class_knnread_ocr_class_knnReadOcrClassKnnReadOcrClassKnnReadOcrClassKnn
Alternatives
do_ocr_multi_class_knndo_ocr_multi_class_knnDoOcrMultiClassKnnDoOcrMultiClassKnnDoOcrMultiClassKnn
See also
create_ocr_class_knncreate_ocr_class_knnCreateOcrClassKnnCreateOcrClassKnnCreateOcrClassKnn
,
classify_class_knnclassify_class_knnClassifyClassKnnClassifyClassKnnClassifyClassKnn
Module
OCR/OCV