Extracting lines with coordinates

Contents
[ ]

Aspose.OCR returns coordinates of each extracted line in recognition results. This can be useful for highlighting detected lines when previewing an image.

The lines are returned as a list of Aspose.OCR.RecognitionResult.LinesResult objects with the following fields:

Field Type Description
Line Aspose.Drawing.Rectangle Line bounding box
TextInLine string Extracted text
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source.png");
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input);
foreach(Aspose.OCR.RecognitionResult.LinesResult line in results[0].RecognitionLinesResult)
{
	Console.WriteLine($"{line.Line}: {line.TextInLine}");
}

Live demo

Recognized image

Extracted line
Optical character recognition or optical character reader (OCR) is the
electronic or mechanical conversion of images of typed, handwritten or
printed text into machine-encoded text. whether from a scanned document
a photo of a document, a scene-photo (for example the text on signs and
billboards in a landscape photo) or from subtitle text superimposed on an
image (for example: from a television broadcast).