HALCON Reference Manual 10.0.2
Name
do_ocr_word_svmdo_ocr_word_svmdo_ocr_word_svmDoOcrWordSvmDoOcrWordSvm — Classify a related group of characters with an OCR classifier.
Herror do_ocr_word_svm(const Hobject Character, const Hobject Image, const Hlong OCRHandle, const char* Expression, const Hlong NumAlternatives, const Hlong NumCorrections, char* Class, char* Word, double* Score)
Herror T_do_ocr_word_svm(const Hobject Character, const Hobject Image, const Htuple OCRHandle, const Htuple Expression, const Htuple NumAlternatives, const Htuple NumCorrections, Htuple* Class, Htuple* Word, Htuple* Score)
Herror do_ocr_word_svm(Hobject Character, Hobject Image, const HTuple& OCRHandle, const HTuple& Expression, const HTuple& NumAlternatives, const HTuple& NumCorrections, char* Class, char* Word, double* Score)
Herror do_ocr_word_svm(Hobject Character, 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 HTuple& Expression, const HTuple& NumAlternatives, const HTuple& NumCorrections, char* Word, double* Score) const
HTuple HRegionArray::DoOcrWordSvm(const HImage& Image, const HOCRSvm& OCRHandle, const HTuple& Expression, const HTuple& NumAlternatives, const HTuple& NumCorrections, HTuple* Word, HTuple* Score) const
HTuple HOCRSvm::DoOcrWordSvm(const HRegionArray& Character, const HImage& Image, const HTuple& Expression, const HTuple& NumAlternatives, const HTuple& NumCorrections, HTuple* Word, HTuple* Score) const
void HOperatorSetX.DoOcrWordSvm(
[in] IHUntypedObjectX* Character, [in] IHUntypedObjectX* Image, [in] VARIANT OCRHandle, [in] VARIANT Expression, [in] VARIANT NumAlternatives, [in] VARIANT NumCorrections, [out] VARIANT* Class, [out] VARIANT* Word, [out] VARIANT* Score)
VARIANT HRegionX.DoOcrWordSvm(
[in] IHImageX* Image, [in] IHOCRSvmX* OCRHandle, [in] BSTR Expression, [in] Hlong NumAlternatives, [in] Hlong NumCorrections, [out] BSTR* Word, [out] double* Score)
VARIANT HOCRSvmX.DoOcrWordSvm(
[in] IHRegionX* Character, [in] IHImageX* Image, [in] BSTR Expression, [in] Hlong NumAlternatives, [in] Hlong NumCorrections, [out] BSTR* Word, [out] double* Score)
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)
do_ocr_word_svmdo_ocr_word_svmdo_ocr_word_svmDoOcrWordSvmDoOcrWordSvm works like do_ocr_multi_class_svmdo_ocr_multi_class_svmdo_ocr_multi_class_svmDoOcrMultiClassSvmDoOcrMultiClassSvm insofar
as it computes the best class for each of the characters given by the
regions CharacterCharacterCharacterCharactercharacter and the gray values ImageImageImageImageimage with the OCR
classifier OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle, and returns the results in ClassClassClassClassclassVal.
In contrast to do_ocr_multi_class_svmdo_ocr_multi_class_svmdo_ocr_multi_class_svmDoOcrMultiClassSvmDoOcrMultiClassSvm, do_ocr_word_svmdo_ocr_word_svmdo_ocr_word_svmDoOcrWordSvmDoOcrWordSvm
treats the group of characters as an entity which yields a WordWordWordWordword
by concatenating the class names for each character region. This allows
to restrict the allowed classification results on a textual level by
specifying an ExpressionExpressionExpressionExpressionexpression describing the expected word.
The ExpressionExpressionExpressionExpressionexpression may restrict the word to belong to a predefined
lexicon created using create_lexiconcreate_lexiconcreate_lexiconCreateLexiconCreateLexicon or import_lexiconimport_lexiconimport_lexiconImportLexiconImportLexicon,
by specifying the name of the lexicon in angular
brackets as in '<mylexicon>'"<mylexicon>""<mylexicon>""<mylexicon>""<mylexicon>". If the ExpressionExpressionExpressionExpressionexpression is of
any other form, it is interpreted as a regular expression with the same
syntax as specified for tuple_regexp_matchtuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatch. 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_matchtuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatch, do_ocr_word_svmdo_ocr_word_svmdo_ocr_word_svmDoOcrWordSvmDoOcrWordSvm 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 ExpressionExpressionExpressionExpressionexpression, do_ocr_word_svmdo_ocr_word_svmdo_ocr_word_svmDoOcrWordSvmDoOcrWordSvm attempts to correct it by
considering the NumAlternativesNumAlternativesNumAlternativesNumAlternativesnumAlternatives best classes for each character.
The alternatives used are identical to those
returned by do_ocr_single_class_svmdo_ocr_single_class_svmdo_ocr_single_class_svmDoOcrSingleClassSvmDoOcrSingleClassSvm for a single character. It does
so by testing all possible corrections for which the classification result
is changed for at most NumCorrectionsNumCorrectionsNumCorrectionsNumCorrectionsnumCorrections character regions.
In case the ExpressionExpressionExpressionExpressionexpression 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 NumCorrectionsNumCorrectionsNumCorrectionsNumCorrectionsnumCorrections edit operations for the
correction (see suggest_lexiconsuggest_lexiconsuggest_lexiconSuggestLexiconSuggestLexicon).
The resulting word is graded by a ScoreScoreScoreScorescore 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).
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Characters to be recognized.
Gray values of the characters.
Handle of the OCR classifier.
Expression describing the allowed word structure.
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
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
Result of classifying the characters with the
SVM.
Number of elements: Class == Character
Word text after classification and correction.
Measure of similarity between corrected word
and uncorrected classification results.
The complexity of checking all possible corrections is of magnitude
O((n*a)^min(c,n)),
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.
If the parameters are valid, the operator
do_ocr_multi_class_svmdo_ocr_multi_class_svmdo_ocr_multi_class_svmDoOcrMultiClassSvmDoOcrMultiClassSvm returns the value 2 (H_MSG_TRUE). If
necessary an exception is raised.
trainf_ocr_class_svmtrainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvm,
read_ocr_class_svmread_ocr_class_svmread_ocr_class_svmReadOcrClassSvmReadOcrClassSvm
do_ocr_multi_class_svmdo_ocr_multi_class_svmdo_ocr_multi_class_svmDoOcrMultiClassSvmDoOcrMultiClassSvm
create_ocr_class_svmcreate_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvm,
classify_class_svmclassify_class_svmclassify_class_svmClassifyClassSvmClassifyClassSvm
OCR/OCV
| HALCON Reference Manual 10.0.2 |
Copyright © 1996-2011 MVTec Software GmbH |