Converts an image file to a document file in the specified document format.
[OperationContractAttribute(Action="Recognize",
AsyncPattern=false,
IsOneWay=false,
IsInitiating=true,
IsTerminating=false)]
[FaultContractAttribute(System.Type)]
public RecognizeResponse Recognize(
RecognizeRequest request
)
request
A System.Runtime.Serialization.DataContractAttribute containing the data that will be used for this Recognize(recognizerequest) operation.
A System.Runtime.Serialization.DataContractAttribute containing the document data resulting from the Recognize(recognizerequest) operation.
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:
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:
using Leadtools.Services;
using Leadtools.Services.Forms.ServiceContracts;
using Leadtools.Services.Forms.ServiceImplementations;
public void DocumentConvertOptionsExample()
{
OcrServiceClient client = new OcrServiceClient();
RawBinaryData sourceBinaryData = new RawBinaryData();
sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "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(Path.Combine(LEAD_VARS.ImagesDir, "clean.txt"), (response.Destination as RawBinaryData).Data);
}
client.Close();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}