do_ocr_single_class_cnnT_do_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnn (Operator)
Name
do_ocr_single_class_cnnT_do_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnn
— Classify a single character with an CNN-based OCR classifier.
Signature
void DoOcrSingleClassCnn(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
static void HOperatorSet.DoOcrSingleClassCnn(HObject character, HObject image, HTuple OCRHandle, HTuple num, out HTuple classVal, out HTuple confidence)
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_cnndo_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnnDoOcrSingleClassCnn
computes the best classification for the
character given by the region CharacterCharacterCharacterCharactercharacter
and the gray values ImageImageImageImageimage
with the OCR classifier
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle
and returns the best NumNumNumNumnum
classes in
ClassClassClassClassclassVal
and the corresponding confidences (probabilities) of the
classes in ConfidenceConfidenceConfidenceConfidenceconfidence
. Because multiple classes may be returned by
do_ocr_single_class_cnndo_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnnDoOcrSingleClassCnn
, CharacterCharacterCharacterCharactercharacter
may only contain
a single region (a single character). If multiple characters should
be classified in a single call, do_ocr_multi_class_cnndo_ocr_multi_class_cnnDoOcrMultiClassCnnDoOcrMultiClassCnnDoOcrMultiClassCnn
must
be used.
In most cases, do_ocr_multi_class_cnndo_ocr_multi_class_cnnDoOcrMultiClassCnnDoOcrMultiClassCnnDoOcrMultiClassCnn
should be preferred over
do_ocr_single_class_cnndo_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnnDoOcrSingleClassCnn
, since do_ocr_multi_class_cnndo_ocr_multi_class_cnnDoOcrMultiClassCnnDoOcrMultiClassCnnDoOcrMultiClassCnn
is
typically faster than a loop with do_ocr_single_class_cnndo_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnnDoOcrSingleClassCnn
.
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_cnndo_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnnDoOcrSingleClassCnn
has to be used if the
nth-best class has to be examined explicitly for n greater than one.
A string of the number
'\032'"\032""\032""\032""\032" (alternatively
displayed as '\0x1A'"\0x1A""\0x1A""\0x1A""\0x1A") in
ClassClassClassClassclassVal
signifies that the region has been classified as rejection
class.
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_cnn →
HOCRCnn, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Handle of the OCR classifier.
NumNumNumNumnum
(input_control) integer-array →
HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Number of best classes to determine.
Default value: 1
Suggested values: 1, 2, 3, 4, 5
ClassClassClassClassclassVal
(output_control) string(-array) →
HTupleHTupleHtuple (string) (string) (HString) (char*)
Result of classifying the character with the
CNN.
ConfidenceConfidenceConfidenceConfidenceconfidence
(output_control) real(-array) →
HTupleHTupleHtuple (real) (double) (double) (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_cnndo_ocr_single_class_cnnDoOcrSingleClassCnnDoOcrSingleClassCnnDoOcrSingleClassCnn
returns the value 2 (H_MSG_TRUE). If
necessary, an exception is raised.
Possible Predecessors
read_ocr_class_cnnread_ocr_class_cnnReadOcrClassCnnReadOcrClassCnnReadOcrClassCnn
Alternatives
do_ocr_multi_class_cnndo_ocr_multi_class_cnnDoOcrMultiClassCnnDoOcrMultiClassCnnDoOcrMultiClassCnn
Module
OCR/OCV