Leadtools.Services.Forms.ServiceContracts Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Recognize(RecognizeRequest) Method
See Also  Example
Leadtools.Services.Forms.ServiceContracts Namespace > IOcrService Interface > Recognize Method : Recognize(RecognizeRequest) Method



request
A DataContractAttribute containing the data that will be used for this Recognize operation.
request
A DataContractAttribute containing the data that will be used for this Recognize operation.
Converts an image file to a document file in the specified document format.

Syntax

Visual Basic (Declaration) 
<OperationContractAttribute("Recognize")>
<FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=False)>
Overloads Overridable Function Recognize( _
   ByVal request As RecognizeRequest _
) As RecognizeResponse
Visual Basic (Usage)Copy Code
Dim instance As IOcrService
Dim request As RecognizeRequest
Dim value As RecognizeResponse
 
value = instance.Recognize(request)
C# 
[OperationContractAttribute("Recognize")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=false)]
virtual RecognizeResponse Recognize( 
   RecognizeRequest request
)
C++/CLI 
[OperationContractAttribute("Recognize")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=false)]
virtual RecognizeResponse Recognize( 
   RecognizeRequest request
) 

Parameters

request
A DataContractAttribute containing the data that will be used for this Recognize operation.

Return Value

A DataContractAttribute containing the document data resulting from the Recognize operation.

Example

Visual BasicCopy Code
Public Sub DocumentConvertOptionsExample()
  Dim client As OcrServiceClient = New OcrServiceClient()
  Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
  sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "clean.tif")

  ' set the document convertion options
  Dim convertOptions As DocumentConvertOptions = New DocumentConvertOptions()

  convertOptions.Source = sourceBinaryData
  convertOptions.Destination = Nothing
  convertOptions.Format = OcrDocumentFormatType.TextAnsi
  convertOptions.FirstPageNumber = 1
  convertOptions.LastPageNumber = 1
  Dim files As DocumentFiles = Nothing

  Dim request As RecognizeRequest = New RecognizeRequest()
  request.ConvertOptions = convertOptions

  Dim response As RecognizeResponse = client.Recognize(request)

  If Not response.Destination Is Nothing Then
    If TypeOf response.Destination Is RawBinaryData Then
       File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "clean.txt", (TryCast(response.Destination, RawBinaryData)).Data)
    End If
  End If

  client.Close()
End Sub
C#Copy Code
public void DocumentConvertOptionsExample() 

   OcrServiceClient client = new OcrServiceClient(); 
   RawBinaryData sourceBinaryData = new RawBinaryData(); 
   sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "clean.tif"); 
 
   // set the document convertion options 
   DocumentConvertOptions convertOptions = new DocumentConvertOptions(); 
 
   convertOptions.Source = sourceBinaryData; 
   convertOptions.Destination = null; 
   convertOptions.Format = OcrDocumentFormatType.TextAnsi; 
   convertOptions.FirstPageNumber = 1; 
   convertOptions.LastPageNumber = 1; 
   DocumentFiles files = null; 
 
   RecognizeRequest request = new RecognizeRequest(); 
   request.ConvertOptions = convertOptions; 
 
   RecognizeResponse response = client.Recognize(request); 
 
   if (response.Destination != null) 
   { 
      if(response.Destination is RawBinaryData) 
         File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "clean.txt", (response.Destination as RawBinaryData).Data); 
   } 
 
   client.Close(); 
}

Remarks

This method is supported when hosting is done using WebHttpBinding.

The LEADTOOLS OCR engines provide support for recognizing document zones in separate threads. This can improve the performance of the recognition process. Control the number of threads through Leadtools.Services.Forms.ServiceImplementations.dll.config by setting the value for MaximumRecognitionThreads to one of the following:

  • A value of 0 (zero) instructs LEADTOOLS to use the maximum number of threads equal to the number of cores available in the current machine.
  • A value of 1, 2, 3, 4, etc. instructs LEADTOOLS to use that maximum number of threads equal to that number.
  • A value of 1 instructs LEADTOOLS not to use multi-threading
  • Leave the value of this property at the default value of 1 in WCF applications.

Also LEADTOOLS OCR engines provide support for auto-zoning in separate threads. This can improve the performance of the recognition process. Disable and enable this option through Leadtools.Services.Forms.ServiceImplementations.dll.config by setting the value for EnableMultiThreadingZoning to one of the following:

  • True
  • False
  • Leave the value of this property to the default value of false in WCF applications.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Applications developed with LEADTOOLS WCF components require runtime licenses. Server licensing is required for applications on a server. For more information, refer to: Imaging Pro/Document/Medical Features