Skip to content

do_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnndo_ocr_single_class_cnnT_do_ocr_single_class_cnnπŸ”—

Short descriptionπŸ”—

do_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnndo_ocr_single_class_cnnT_do_ocr_single_class_cnn β€” Classify a single character with an CNN-based OCR classifier.

SignatureπŸ”—

do_ocr_single_class_cnn( region Character, image Image, ocr_cnn OCRHandle, integer Num, out string Class, out real Confidence )void DoOcrSingleClassCnn( const HObject& Character, const HObject& Image, const HTuple& OCRHandle, const HTuple& Num, HTuple* Class, HTuple* Confidence )static void HOperatorSet.DoOcrSingleClassCnn( HObject character, HObject image, HTuple OCRHandle, HTuple num, out HTuple classVal, out HTuple confidence )def do_ocr_single_class_cnn( character: HObject, image: HObject, ocrhandle: HHandle, num: Sequence[int] ) -> Tuple[Sequence[str], Sequence[float]]

def do_ocr_single_class_cnn_s( character: HObject, image: HObject, ocrhandle: HHandle, num: Sequence[int] ) -> Tuple[str, float]Herror T_do_ocr_single_class_cnn( const Hobject Character, const Hobject Image, const Htuple OCRHandle, const Htuple Num, Htuple* Class, Htuple* Confidence )

HTuple HRegion::DoOcrSingleClassCnn( const HImage& Image, const HOCRCnn& OCRHandle, const HTuple& Num, HTuple* Confidence ) const

HString HRegion::DoOcrSingleClassCnn( const HImage& Image, const HOCRCnn& OCRHandle, const HTuple& Num, double* Confidence ) const

HTuple HOCRCnn::DoOcrSingleClassCnn( const HRegion& Character, const HImage& Image, const HTuple& Num, HTuple* Confidence ) const

HString HOCRCnn::DoOcrSingleClassCnn( const HRegion& Character, const HImage& Image, const HTuple& Num, double* Confidence ) const

HTuple HRegion.DoOcrSingleClassCnn( HImage image, HOCRCnn OCRHandle, HTuple num, out HTuple confidence )

string HRegion.DoOcrSingleClassCnn( HImage image, HOCRCnn OCRHandle, HTuple num, out double confidence )

HTuple HOCRCnn.DoOcrSingleClassCnn( HRegion character, HImage image, HTuple num, out HTuple confidence )

string HOCRCnn.DoOcrSingleClassCnn( HRegion character, HImage image, HTuple num, out double confidence )

DescriptionπŸ”—

do_ocr_single_class_cnnDoOcrSingleClassCnn computes the best classification for the character given by the region Charactercharactercharacter and the gray values Imageimageimage with the OCR classifier OCRHandleOCRHandleocrhandle and returns the best Numnumnum classes in ClassclassValclass and the corresponding confidences (probabilities) of the classes in Confidenceconfidenceconfidence. Because multiple classes may be returned by do_ocr_single_class_cnnDoOcrSingleClassCnn, Charactercharactercharacter may only contain a single region (a single character). If multiple characters should be classified in a single call, do_ocr_multi_class_cnnDoOcrMultiClassCnn must be used.

In most cases, do_ocr_multi_class_cnnDoOcrMultiClassCnn should be preferred over do_ocr_single_class_cnnDoOcrSingleClassCnn, since do_ocr_multi_class_cnnDoOcrMultiClassCnn is typically faster than a loop with do_ocr_single_class_cnnDoOcrSingleClassCnn. Furthermore, the resulting confidences can be interpreted as probabilities. They indicate the uncertainty of a character’s classification result. The operator do_ocr_single_class_cnnDoOcrSingleClassCnn has to be used if the nth-best class has to be examined explicitly for n greater than one.

A string of the number \('\backslash 032'\) (alternatively displayed as \('\backslash 0x1A'\)) in ClassclassValclass signifies that the region has been classified as rejection class.

Execution informationπŸ”—

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πŸ”—

Charactercharactercharacter (input_object) region β†’ objectHObjectHRegionHObjectHobject

Character to be recognized.

Imageimageimage (input_object) singlechannelimage β†’ object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)

Gray values of the character.

OCRHandleOCRHandleocrhandle (input_control) ocr_cnn β†’ (handle)HTuple (HHandle)HOCRCnn, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the OCR classifier.

Numnumnum (input_control) integer-array β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Number of best classes to determine.

Default: 11
Suggested values: 1, 2, 3, 4, 51, 2, 3, 4, 5

ClassclassValclass (output_control) string(-array) β†’ (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Result of classifying the character with the CNN.

Confidenceconfidenceconfidence (output_control) real(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Confidence(s) of the class(es) of the character.

ExampleπŸ”—

(HDevelop)

read_image(Image, 'bottle2')
OffsetRow := 100
OffsetCol := 108
read_ocr_class_cnn('Universal_0-9_NoRej.occ', OCRHandle)
* Select each digit and use do_ocr_single_class_cnn to apply OCR
gen_rectangle1(ROI_Date, OffsetRow, OffsetCol, OffsetRow, OffsetCol)
for I := 1 to 6 by 1
  Offset := I % 2 * 10
  smallest_rectangle1(ROI_Date, Row1, Col1, Row2, Col2)
  gen_rectangle1(ROI_Date, OffsetRow, Offset + Col2, OffsetRow + 42, \
  Col2 + Offset + 31)
  do_ocr_single_class_cnn(ROI_Date, Image, OCRHandle, 1, Class, Confidence)
endfor

ResultπŸ”—

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

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

read_ocr_class_cnnReadOcrClassCnn

Alternatives

do_ocr_multi_class_cnnDoOcrMultiClassCnn

ModuleπŸ”—

OCR/OCV