do_ocr_single_class_knnT_do_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnndo_ocr_single_class_knn (Operator)

Name

do_ocr_single_class_knnT_do_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnndo_ocr_single_class_knn — Classify a single character with an OCR classifier.

Signature

do_ocr_single_class_knn(Character, Image : : OCRHandle, NumClasses, NumNeighbors : Class, Confidence)

Herror T_do_ocr_single_class_knn(const Hobject Character, const Hobject Image, const Htuple OCRHandle, const Htuple NumClasses, const Htuple NumNeighbors, Htuple* Class, Htuple* Confidence)

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)

def do_ocr_single_class_knn(character: HObject, image: HObject, ocrhandle: HHandle, num_classes: Sequence[int], num_neighbors: Sequence[int]) -> Tuple[Sequence[str], Sequence[float]]

def do_ocr_single_class_knn_s(character: HObject, image: HObject, ocrhandle: HHandle, num_classes: Sequence[int], num_neighbors: Sequence[int]) -> Tuple[str, float]

Description

do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnndo_ocr_single_class_knn uses the OCR-k-NN classifier OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle to determine the best training samples for the features of the character given by the region CharacterCharacterCharacterCharactercharactercharacter and the gray values ImageImageImageImageimageimage and returns their classes in ClassClassClassClassclassValclass and the corresponding confidences in ConfidenceConfidenceConfidenceConfidenceconfidenceconfidence. If the first NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighborsnum_neighbors training vectors have different classes, maximally NumClassesNumClassesNumClassesNumClassesnumClassesnum_classes 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 NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighborsnum_neighbors is large enough.

Because multiple classes may be returned by do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnndo_ocr_single_class_knn, CharacterCharacterCharacterCharactercharactercharacter 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_knnDoOcrMultiClassKnnDoOcrMultiClassKnnDoOcrMultiClassKnndo_ocr_multi_class_knn must be used. Before calling do_ocr_single_class_knndo_ocr_single_class_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnndo_ocr_single_class_knn, the classifier must be trained with trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnntrainf_ocr_class_knn or select_feature_set_trainf_knnselect_feature_set_trainf_knnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnSelectFeatureSetTrainfKnnselect_feature_set_trainf_knn. If all NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighborsnum_neighbors neighbors are of the same class, only one class is returned.

Execution Information

Parameters

CharacterCharacterCharacterCharactercharactercharacter (input_object)  region objectHRegionHObjectHRegionHobject

Character to be recognized.

ImageImageImageImageimageimage (input_object)  singlechannelimage objectHImageHObjectHImageHobject (byte / uint2)

Gray values of the character.

OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle (input_control)  ocr_knn HOCRKnn, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the k-NN classifier.

NumClassesNumClassesNumClassesNumClassesnumClassesnum_classes (input_control)  integer-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Number of maximal classes to determine.

Default: 1

Suggested values: 1, 2, 3, 4, 5

NumNeighborsNumNeighborsNumNeighborsNumNeighborsnumNeighborsnum_neighbors (input_control)  integer-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Number of neighbors to consider.

Default: 1

Suggested values: 1, 2, 3, 4, 5

ClassClassClassClassclassValclass (output_control)  string(-array) HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Results of classifying the character with the k-NN.

ConfidenceConfidenceConfidenceConfidenceconfidenceconfidence (output_control)  real(-array) HTupleSequence[float]HTupleHtuple (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_knnDoOcrSingleClassKnnDoOcrSingleClassKnnDoOcrSingleClassKnndo_ocr_single_class_knn returns the value 2 ( H_MSG_TRUE) . If necessary, an exception is raised.

Possible Predecessors

trainf_ocr_class_knntrainf_ocr_class_knnTrainfOcrClassKnnTrainfOcrClassKnnTrainfOcrClassKnntrainf_ocr_class_knn, read_ocr_class_knnread_ocr_class_knnReadOcrClassKnnReadOcrClassKnnReadOcrClassKnnread_ocr_class_knn

Alternatives

do_ocr_multi_class_knndo_ocr_multi_class_knnDoOcrMultiClassKnnDoOcrMultiClassKnnDoOcrMultiClassKnndo_ocr_multi_class_knn

See also

create_ocr_class_knncreate_ocr_class_knnCreateOcrClassKnnCreateOcrClassKnnCreateOcrClassKnncreate_ocr_class_knn, classify_class_knnclassify_class_knnClassifyClassKnnClassifyClassKnnClassifyClassKnnclassify_class_knn

Module

OCR/OCV