Extracting text inside a rectangle

Contents
[ ]

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 found automatically using the paragraph, line or word detection.

To extract text from one or more areas of an image, provide region boundaries in rectangles parameter the recognition settings.

// Provide the image
string file = "source.png";
AsposeOCRInput source;
source.url = file.c_str();
std::vector<AsposeOCRInput> content = { source };
// Set rectangles
rect rectangles[2] = { {90, 186, 775, 95} , { 928, 606, 790, 160 } };
RecognitionSettings settings;
settings.rectangles = rectangles;
// Extract text from the image
auto result = asposeocr_recognize(content.data(), content.size(), settings);

Live demo

Driver's license

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