L_OcrLanguageManager_DetectLanguage

#include "ltocr.h"

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

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

Parameters

L_OcrLanguageManager languageManager

OCR engine language manager handle.

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 passed for '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.

Returns

Value Meaning
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

See Also

Functions

Topics

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 21.0.2020.8.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - LEAD Engine C API Help