←Select platform

DetectLanguage Method

Summary

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

Syntax

C#
VB
Java
Objective-C
WinRT C#
C++
int DetectLanguage(  
   Leadtools.Forms.Ocr.IOcrPage page, 
   string[] languages, 
   int[] confidences, 
   int minimumConfidence 
) 
Function DetectLanguage( _ 
   ByVal page As Leadtools.Forms.Ocr.IOcrPage, _ 
   ByVal languages() As String, _ 
   ByVal confidences() As Integer, _ 
   ByVal minimumConfidence As Integer _ 
) As Integer 
int DetectLanguage(  
   Leadtools.Forms.Ocr.IOcrPage page, 
   string[] languages, 
   int[] confidences, 
   int minimumConfidence 
) 
- (NSUInteger)detectLanguage:(LTOcrPage *)page  
                   languages:(NSArray<NSNumber *> *)languages  
                 confidences:(NSArray<NSNumber *> * _Nullable * _Nullable)confidences  
           minimumConfidence:(NSUInteger)minimumConfidence  
                       error:(NSError **)error 
             
public int detectLanguage(OcrPage page, 
                          String[] languages, 
                          int[] confidences, 
                          int minimumConfidence) 
             
function Leadtools.Forms.Ocr.IOcrLanguageManager.DetectLanguage(  
   page , 
   languages , 
   confidences , 
   minimumConfidence  
) 
int DetectLanguage(  
   Leadtools.Forms.Ocr.IOcrPage^ page, 
   array<String^>^ languages, 
   array<int>^ confidences, 
   int minimumConfidence 
)  

Parameters

page
The IOcrPage to detect its language.

languages
An array of String objects that contain the names of the languages to check for. The language values used throughout the LEADTOOLS OCR toolkit are string values based on RFC 4646 (Windows Vista and later). The name could be an ISO 639 two-letter lowercase culture code associated with a language or a combination of ISO 630 and ISO 3166 two-letter uppercase subculture codes associated with a country or region.

confidences
An array of Int32 objects 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 higher than its value.

Return Value

The index of the language with the highest confidence in languages parameter.

Remarks

DetectLanguage is supported in the LEADTOOLS OCR Advantage Engine only.

Zone language detection is a dictionary based method. The confidence of a language without a dictionary is low. If a language does not have a dictionary installed, then that language will not be detected and the default (main) language will be used to recognize the text. For example, Asian languages such as Chinese, Japanese and Korean do not have dictionaries. If an Asian language text is present in the input image, then you should set the desired language as the default (main) language in the OCR engine in order to recognize text with the highest accuracy. To determine whether a given spell language (dictionary) is supported by the current spell checker engine use IsSpellLanguageSupported. In order to get a list of the languages (dictionaries) supported by the current spell checker engine use GetSupportedSpellLanguages. For more information on OCR languages and spell checkers, refer to IOcrLanguageManager and IOcrSpellCheckManager.

Use the GetSupportedLanguages to obtain a list of the languages supported by the IOcrEngine.

Use the IsLanguageSupported to check if a given language is supported by the IOcrEngine.

Example

This example will detect images with English, French, and German languages.

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Forms.Ocr; 
 
private void DetectLanguageExample(IOcrEngine engine, IOcrPage page) 
{ 
   string[] languages = new string[3]; 
   languages[0] = "en"; 
   languages[0] = "fr"; 
   languages[0] = "de"; 
   int[] confidences = new int[languages.Length]; 
   int maxIndex = engine.LanguageManager.DetectLanguage(page, languages, confidences, 90); 
   if (maxIndex == -1) 
      Console.WriteLine("No language has been detected"); 
   else 
      Console.WriteLine("The page language with the highest confidence is: " + languages[maxIndex] + ", with confidence: " + confidences[maxIndex]); 
   for (int i = 0; i < languages.Length; i++) 
      Console.WriteLine("Language: " + languages[i] + ", with confidence: " + confidences[i]); 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Forms.Ocr 
 
 
Public Sub DetectLanguageExample(engine As IOcrEngine, page As IOcrPage) 
   Dim languages As String() = New String(2) {} 
   languages(0) = "en" 
   languages(0) = "fr" 
   languages(0) = "de" 
   Dim confidences As Integer() = New Integer(languages.Length - 1) {} 
   Dim maxIndex As Integer = engine.LanguageManager.DetectLanguage(page, languages, confidences, 90) 
   If maxIndex = -1 Then 
      Console.WriteLine("No language has been detected") 
   Else 
      Console.WriteLine("The page language with the highest confidence is: " & languages(maxIndex) & ", with confidence: " & confidences(maxIndex)) 
   End If 
   For i As Integer = 0 To languages.Length - 1 
      Console.WriteLine("Language: " & languages(i) & ", with confidence: " & confidences(i)) 
   Next 
End Sub 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Forms.Ocr Assembly
Click or drag to resize