Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.OCR allows you to extract names, dates, numbers, and other blocks from certain areas of uniform images, such as ID cards, visas, driver’s licenses, applications, and so on. Regions can be provided manually or automatically detected using the Aspose.OCR.AsposeOcr.DetectRectangles
method.
To extract text from one or more areas of an image, provide a list of Aspose.Drawing.Rectangle
objects specifying the upper left corner and the width and height of the image area in RecognitionAreas
field of RecognitionSettings
.
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Manually specify recognition areas
List<Aspose.Drawing.Rectangle> rectangles = new List<Aspose.Drawing.Rectangle>(){
new Aspose.Drawing.Rectangle(231,101,430,42),
new Aspose.Drawing.Rectangle(546,224,123,26)
};
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.RecognitionAreas = rectangles;
// Recognize image
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source.png");
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input, recognitionSettings);
// Output recognition results for each area
Console.WriteLine("Name: "+results[0].RecognitionAreasText[0]);
Console.WriteLine("Expiry: "+results[0].RecognitionAreasText[1]);
The text from each rectangle is returned in the RecognitionAreasText
property of the recognition result.
Block | Coordinates | Extracted text |
---|---|---|
Name | {X=231, Y=101, Width=430, Height=42} | SAMPLE AVERY JOSEPH |
Expiry date | {X=546, Y=224, Width=123, Height=26} | 08/15/2022 |
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.