do_ocr_singleT_do_ocr_singleDoOcrSingleDoOcrSingledo_ocr_single (Operator)

Name

do_ocr_singleT_do_ocr_singleDoOcrSingleDoOcrSingledo_ocr_single — Classify one character.

Warning

do_ocr_singledo_ocr_singleDoOcrSingleDoOcrSingleDoOcrSingledo_ocr_single is obsolete and is only provided for reasons of backward compatibility. New applications should use the MLP, SVM or CNN based operators instead.

Signature

do_ocr_single(Character, Image : : OcrHandle : Classes, Confidences)

Herror T_do_ocr_single(const Hobject Character, const Hobject Image, const Htuple OcrHandle, Htuple* Classes, Htuple* Confidences)

void DoOcrSingle(const HObject& Character, const HObject& Image, const HTuple& OcrHandle, HTuple* Classes, HTuple* Confidences)

HTuple HRegion::DoOcrSingle(const HImage& Image, const HOCRBox& OcrHandle, HTuple* Confidences) const

HTuple HOCRBox::DoOcrSingle(const HRegion& Character, const HImage& Image, HTuple* Confidences) const

static void HOperatorSet.DoOcrSingle(HObject character, HObject image, HTuple ocrHandle, out HTuple classes, out HTuple confidences)

HTuple HRegion.DoOcrSingle(HImage image, HOCRBox ocrHandle, out HTuple confidences)

HTuple HOCRBox.DoOcrSingle(HRegion character, HImage image, out HTuple confidences)

def do_ocr_single(character: HObject, image: HObject, ocr_handle: HHandle) -> Tuple[Sequence[str], Sequence[float]]

Description

The operator do_ocr_singledo_ocr_singleDoOcrSingleDoOcrSingleDoOcrSingledo_ocr_single assigns classes to the CharacterCharacterCharacterCharactercharactercharacter (characters). For gray value features gray values of the surrounding rectangles of the regions will be used. The gray values will be taken from the parameter ImageImageImageImageimageimage. For each character the two classes with the highest confidences will be returned in ClassesClassesClassesClassesclassesclasses. The corresponding confidences will be returned in ConfidencesConfidencesConfidencesConfidencesconfidencesconfidences. The confidence value indicates the similarity between the input pattern and the assigned character.

Execution Information

Parameters

CharacterCharacterCharacterCharactercharactercharacter (input_object)  region objectHRegionHObjectHRegionHobject

Character to be recognized.

ImageImageImageImageimageimage (input_object)  singlechannelimage objectHImageHObjectHImageHobject (byte / uint2)

Gray values of the characters.

OcrHandleOcrHandleOcrHandleOcrHandleocrHandleocr_handle (input_control)  ocr_box HOCRBox, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

ID of the OCR classifier.

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

Classes (names) of the characters.

Number of elements: 2

ConfidencesConfidencesConfidencesConfidencesconfidencesconfidences (output_control)  real-array HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Confidence values of the characters.

Number of elements: 2

Example (C)

HTuple  Classes,Confidences;
Hlong    orc_handle;
HTuple  OcrHandle;

read_ocr("testnet",&orc_handle);
create_tuple(&OcrHandle,1);
set_i(OcrHandle,orc_handle,0);
read_image(&Image,"character.tiff");
binary_threshold(Image,&Dark, 'otsu', 'dark', &UsedThreshold);
connection(Dark,&Character);
count_obj(Character,&num);
open_window(0,0,-1,-1,0,"","",&WindowHandle);
for (i=0; i<num; i++) {
  select_obj(Character,&SingleCharacter,i);
  T_do_ocr_single(SingleCharacter,Image,
                  OcrHandle,&Classes,&Confidences);
  printf("best   = %s (%g)\n",
         get_s(Classes,0),get_d(Confidences,0));
  printf("second = %s (%g)\n\n",
         get_s(Classes,1),get_d(Confidences,1));
}

Result

If the input parameters are correct, the operator do_ocr_singledo_ocr_singleDoOcrSingleDoOcrSingleDoOcrSingledo_ocr_single returns the value 2 (H_MSG_TRUE). Otherwise an exception will be raised.

Possible Predecessors

traind_ocr_class_boxtraind_ocr_class_boxTraindOcrClassBoxTraindOcrClassBoxTraindOcrClassBoxtraind_ocr_class_box, trainf_ocr_class_boxtrainf_ocr_class_boxTrainfOcrClassBoxTrainfOcrClassBoxTrainfOcrClassBoxtrainf_ocr_class_box, read_ocrread_ocrReadOcrReadOcrReadOcrread_ocr, connectionconnectionConnectionConnectionConnectionconnection, sort_regionsort_regionSortRegionSortRegionSortRegionsort_region

Alternatives

do_ocr_multido_ocr_multiDoOcrMultiDoOcrMultiDoOcrMultido_ocr_multi

See also

write_ocrwrite_ocrWriteOcrWriteOcrWriteOcrwrite_ocr

Module

OCR/OCV