do_ocr_word_svm T_do_ocr_word_svm DoOcrWordSvm DoOcrWordSvm (Operator)
Name
do_ocr_word_svm T_do_ocr_word_svm DoOcrWordSvm DoOcrWordSvm
— Classify a related group of characters with an OCR classifier.
Signature
void DoOcrWordSvm (const HObject& Character , const HObject& Image , const HTuple& OCRHandle , const HTuple& Expression , const HTuple& NumAlternatives , const HTuple& NumCorrections , HTuple* Class , HTuple* Word , HTuple* Score )
HTuple HRegion ::DoOcrWordSvm (const HImage& Image , const HOCRSvm& OCRHandle , const HString& Expression , Hlong NumAlternatives , Hlong NumCorrections , HString* Word , double* Score ) const
HTuple HRegion ::DoOcrWordSvm (const HImage& Image , const HOCRSvm& OCRHandle , const char* Expression , Hlong NumAlternatives , Hlong NumCorrections , HString* Word , double* Score ) const
HTuple HRegion ::DoOcrWordSvm (const HImage& Image , const HOCRSvm& OCRHandle , const wchar_t* Expression , Hlong NumAlternatives , Hlong NumCorrections , HString* Word , double* Score ) const
(Windows only)
HTuple HOCRSvm ::DoOcrWordSvm (const HRegion& Character , const HImage& Image , const HString& Expression , Hlong NumAlternatives , Hlong NumCorrections , HString* Word , double* Score ) const
HTuple HOCRSvm ::DoOcrWordSvm (const HRegion& Character , const HImage& Image , const char* Expression , Hlong NumAlternatives , Hlong NumCorrections , HString* Word , double* Score ) const
HTuple HOCRSvm ::DoOcrWordSvm (const HRegion& Character , const HImage& Image , const wchar_t* Expression , Hlong NumAlternatives , Hlong NumCorrections , HString* Word , double* Score ) const
(Windows only)
static void HOperatorSet .DoOcrWordSvm (HObject character , HObject image , HTuple OCRHandle , HTuple expression , HTuple numAlternatives , HTuple numCorrections , out HTuple classVal , out HTuple word , out HTuple score )
HTuple HRegion .DoOcrWordSvm (HImage image , HOCRSvm OCRHandle , string expression , int numAlternatives , int numCorrections , out string word , out double score )
HTuple HOCRSvm .DoOcrWordSvm (HRegion character , HImage image , string expression , int numAlternatives , int numCorrections , out string word , out double score )
Description
do_ocr_word_svm do_ocr_word_svm DoOcrWordSvm DoOcrWordSvm DoOcrWordSvm
works like do_ocr_multi_class_svm do_ocr_multi_class_svm DoOcrMultiClassSvm DoOcrMultiClassSvm DoOcrMultiClassSvm
insofar
as it computes the best class for each of the characters given by the
regions Character Character Character Character character
and the gray values Image Image Image Image image
with the OCR
classifier OCRHandle OCRHandle OCRHandle OCRHandle OCRHandle
, and returns the results in Class Class Class Class classVal
.
In contrast to do_ocr_multi_class_svm do_ocr_multi_class_svm DoOcrMultiClassSvm DoOcrMultiClassSvm DoOcrMultiClassSvm
, do_ocr_word_svm do_ocr_word_svm DoOcrWordSvm DoOcrWordSvm DoOcrWordSvm
treats the group of characters as an entity which yields a Word Word Word Word word
by concatenating the class names for each character region. This allows
to restrict the allowed classification results on a textual level by
specifying an Expression Expression Expression Expression expression
describing the expected word.
The Expression Expression Expression Expression expression
may restrict the word to belong to a predefined
lexicon created using create_lexicon create_lexicon CreateLexicon CreateLexicon CreateLexicon
or import_lexicon import_lexicon ImportLexicon ImportLexicon ImportLexicon
,
by specifying the name of the lexicon in angular
brackets as in '<mylexicon>' "<mylexicon>" "<mylexicon>" "<mylexicon>" "<mylexicon>" . If the Expression Expression Expression Expression expression
is of
any other form, it is interpreted as a regular expression with the same
syntax as specified for tuple_regexp_match tuple_regexp_match TupleRegexpMatch TupleRegexpMatch TupleRegexpMatch
. Note that you will
usually want to use an expression of the form
'^...$'
when using variable quantifiers like '*', to ensure that the entire word
is used in the expression. Also note that in contrast to
tuple_regexp_match tuple_regexp_match TupleRegexpMatch TupleRegexpMatch TupleRegexpMatch
, do_ocr_word_svm do_ocr_word_svm DoOcrWordSvm DoOcrWordSvm DoOcrWordSvm
does not
support passing extra options in an expression tuple.
If the word derived from the best class for each character does not match
the Expression Expression Expression Expression expression
, do_ocr_word_svm do_ocr_word_svm DoOcrWordSvm DoOcrWordSvm DoOcrWordSvm
attempts to correct it by
considering the NumAlternatives NumAlternatives NumAlternatives NumAlternatives numAlternatives
best classes for each character.
The alternatives used are identical to those
returned by do_ocr_single_class_svm do_ocr_single_class_svm DoOcrSingleClassSvm DoOcrSingleClassSvm DoOcrSingleClassSvm
for a single character. It does
so by testing all possible corrections for which the classification result
is changed for at most NumCorrections NumCorrections NumCorrections NumCorrections numCorrections
character regions.
In case the Expression Expression Expression Expression expression
is a lexicon and the above procedure did
not yield a result, the most similar word in the lexicon is returned as long
as it requires less than NumCorrections NumCorrections NumCorrections NumCorrections numCorrections
edit operations for the
correction (see suggest_lexicon suggest_lexicon SuggestLexicon SuggestLexicon SuggestLexicon
).
The resulting word is graded by a Score Score Score Score score
between 0.0 (no correction
found) and 1.0 (original word correct), which is dominated by the number of
corrected characters but also adds a minor penalty for ignoring the second
best class or even all best classes (in case of lexica).
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
Character Character Character Character character
(input_object) region(-array) →
object HRegion HRegion Hobject
Characters to be recognized.
Image Image Image Image image
(input_object) singlechannelimage →
object HImage HImage Hobject (byte / uint2)
Gray values of the characters.
OCRHandle OCRHandle OCRHandle OCRHandle OCRHandle
(input_control) ocr_svm →
HOCRSvm , HTuple HTuple Htuple (handle) (IntPtr ) (HHandle ) (handle )
Handle of the OCR classifier.
Expression Expression Expression Expression expression
(input_control) string →
HTuple HTuple Htuple (string) (string ) (HString ) (char* )
Expression describing the allowed word structure.
NumAlternatives NumAlternatives NumAlternatives NumAlternatives numAlternatives
(input_control) integer →
HTuple HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Number of classes per character considered for the
internal word correction.
Default value: 3
Suggested values: 3, 4, 5
Typical range of values: 1
≤
NumAlternatives
NumAlternatives
NumAlternatives
NumAlternatives
numAlternatives
NumCorrections NumCorrections NumCorrections NumCorrections numCorrections
(input_control) integer →
HTuple HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Maximum number of corrected characters.
Default value: 2
Suggested values: 1, 2, 3, 4, 5
Typical range of values: 0
≤
NumCorrections
NumCorrections
NumCorrections
NumCorrections
numCorrections
Class Class Class Class classVal
(output_control) string(-array) →
HTuple HTuple Htuple (string) (string ) (HString ) (char* )
Result of classifying the characters with the
SVM.
Number of elements: Class == Character
Word Word Word Word word
(output_control) string →
HTuple HTuple Htuple (string) (string ) (HString ) (char* )
Word text after classification and correction.
Score Score Score Score score
(output_control) real →
HTuple HTuple Htuple (real) (double ) (double ) (double )
Measure of similarity between corrected word
and uncorrected classification results.
Complexity
The complexity of checking all possible corrections is of magnitude
,
where a is the number of alternatives, n is the
number of character regions, and c is the number of allowed corrections.
However, to guard against a near-infinite loop in case of large n,
c is internally clipped to 5, 3, or 1 if
a*n >= 30, 60, or 90, respectively.
Result
If the parameters are valid, the operator
do_ocr_word_svm do_ocr_word_svm DoOcrWordSvm DoOcrWordSvm DoOcrWordSvm
returns the value 2 (H_MSG_TRUE). If
necessary an exception is raised.
Possible Predecessors
trainf_ocr_class_svm trainf_ocr_class_svm TrainfOcrClassSvm TrainfOcrClassSvm TrainfOcrClassSvm
,
read_ocr_class_svm read_ocr_class_svm ReadOcrClassSvm ReadOcrClassSvm ReadOcrClassSvm
Alternatives
do_ocr_multi_class_svm do_ocr_multi_class_svm DoOcrMultiClassSvm DoOcrMultiClassSvm DoOcrMultiClassSvm
See also
create_ocr_class_svm create_ocr_class_svm CreateOcrClassSvm CreateOcrClassSvm CreateOcrClassSvm
,
classify_class_svm classify_class_svm ClassifyClassSvm ClassifyClassSvm ClassifyClassSvm
Module
OCR/OCV