L_OcrLanguageManager_DetectLanguage - OCR Module - LEAD Engine C++ API Help

L_OcrLanguageManager_DetectLanguage

#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrLanguageManager_DetectLanguage(languageManager, page, languages, count, confidences, minimumConfidence, maximumConfidenceIndex)

L_OcrLanguageManager languageManager; handle to the OCR engine language manager
L_OcrPage page; the L_OcrPage handle to detect its language
const L_OcrLanguage* languages; an array of the languages to check for
L_UINT count; number of elements in the 'languages' parameter, this should be the _countof(languages)
L_INT* confidences; an array of integers updated by the confidences of the languages. The array size must be equivalent to the number of items in languages array. If it is set to NULL it will be ignored. The confidence value range is between -1 and 100. A value of -1 means the language is not supported, 0 means it is not confident, and 100 is fully confident
L_UINT minimumConfidence; the minimum confidence value to stop checking other languages when a language confidence is equal to or less than its value
L_UINT* maximumConfidenceIndex; address of L_UINT variable to be updated with the index of the language from the 'languages' array that has the highest confidence

Detects the language used in the specified L_OcrPage from a list of languages that is provided by the user.

Parameter Description
languageManager OCR engine language manager handle.
page The L_OcrPage handle to detect its language.
languages An array of the languages to check for.
count Number of elements passed for 'languages' parameter, this should be the _countof(languages).
confidences An array of integers updated by the confidences of the languages. The array size must be equivalent to the number of items in languages array. If it is set to NULL it will be ignored. The confidence value range is between -1 and 100. A value of -1 means the language is not supported, 0 means it is not confident, and 100 is fully confident.
minimumConfidence The minimum confidence value to stop checking other languages when a language confidence is equal to or less than its value.
maximumConfidenceIndex Address of L_UINT variable to be updated with the index of the language from the 'languages' array that has the highest confidence.

Returns

SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

The L_OcrLanguageManager_DetectLanguage method is a dictionary based method that the recognition confidence has low contribution to its calculations. The confidence of a language without a dictionary is low. To determine whether a given spell language (dictionary) is supported by the current spell checker engine use L_OcrSpellCheckManager_IsLanguageSupported. In order to get a list of the languages (dictionaries) supported by the current spell checker engine use L_OcrSpellCheckManager_GetSupportedLanguages.

Use the L_OcrLanguageManager_GetSupportedLanguages to obtain a list of the languages supported by the OCR engine.

Use the L_OcrLanguageManager_IsLanguageSupported to check if a given language is supported by the OCR engine.

Required DLLs and Libraries

LTOCR
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions: L_OcrLanguageManager_GetLanguageName, L_OcrLanguageManager_GetLanguageValue, L_OcrLanguageManager_GetSupportedLanguages, L_OcrLanguageManager_IsLanguageSupported, L_OcrLanguageManager_GetAdditionalLanguages, L_OcrLanguageManager_EnableLanguages, L_OcrLanguageManager_GetEnabledLanguages
Topics: Programming with LEADTOOLS OCR Module - LEAD Engine
Starting and Shutting Down the OCR Engine
OCR Languages and Spell Checking
OCR Spell Language Dictionaries

Example

L_INT L_OcrLanguageManager_DetectLanguageExample(L_OcrEngine engine, L_OcrPage page) 
{ 
   L_OcrLanguageManager ocrLanguageManager = NULL; 
   const L_UINT languageCount = 3; 
   L_OcrLanguage languages[languageCount] = { L_OcrLanguage_EN, L_OcrLanguage_FR, L_OcrLanguage_DE }; 
   L_INT confidences[languageCount] = { -1, -1, -1}; 
 
   L_OcrEngine_GetLanguageManager(engine, &ocrLanguageManager); 
   L_UINT maxConfidenceIndex = 0; 
   L_OcrLanguageManager_DetectLanguage(ocrLanguageManager, page, languages, languageCount, confidences, 25, &maxConfidenceIndex); 
   if (maxConfidenceIndex == -1) 
      std::cout << "No language has been detected\n"; 
   else 
      std::cout << "The page language with the highest confidence is: " << languages[maxConfidenceIndex] << ", with confidence: " << confidences[maxConfidenceIndex] << std::endl; 
 
   for (int i = 0; i < languageCount; i++) 
      std::cout << "Language: " << languages[i] << ", with confidence: " << confidences[i] << std::endl; 
 
   return SUCCESS; 
} 
Help Version 20.0.2018.6.21
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - LEAD Engine C API Help