Rectangle Coordinates for OCR Region Detection
Several IronOCR methods accept a Rectangle so you can run OCR on a single part of an image rather than the whole thing. The four values it needs, x, y, width, and height, can be read straight out of Microsoft Paint.
The constructor looks like this:
Rectangle(int x, int y, int width, int height, MeasurementUnits units = MeasurementUnits.Pixels)
Rectangle(int x, int y, int width, int height, MeasurementUnits units = MeasurementUnits.Pixels)
Rectangle(x As Integer, y As Integer, width As Integer, height As Integer, Optional units As MeasurementUnits = MeasurementUnits.Pixels)
Each parameter maps to one measurement:
x: distance from the left edge of the image to the start of your region.y: distance from the top edge of the image to the start of your region.width: width of the region you want to read.height: height of the region you want to read.MeasurementUnits.Pixels: tells IronOCR the values are in pixels.
Coordinates start at the top-left corner of the image: x grows to the right, y grows downward.

Before you start, you need Microsoft Paint (or any editor that shows cursor position and selection size in pixels), the image you want to read, and IronOCR added to your project.
Solution
1. Read the X and Y Starting Point
Open the image in Microsoft Paint, then move the cursor to the top-left corner of the region you want to read. The cursor position shows in the bottom-left of the window. A readout of 2403, 1653px gives you the start of the region:

X = 2403
Y = 1653
2. Read the Width and Height
Switch to the Select tool and drag a box over the target text. Paint reports the size of the selection in the bottom-left. A readout of 1031 × 214px is the dimensions of your region:

Width = 1031
Height = 214
3. Build the Rectangle
With the four values in hand, construct the Rectangle. For the Testing123 region above:
var rectangle = new Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels);
var rectangle = new Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels);
Dim rectangle = New Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels)
4. Pass It to IronOCR
Hand the rectangle to LoadImage to crop the input down to that region before running OCR:
var rectangle = new Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels);
ocrInput.LoadImage(frame, rectangle);
var rectangle = new Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels);
ocrInput.LoadImage(frame, rectangle);
Dim rectangle = New Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels)
ocrInput.LoadImage(frame, rectangle)
Debug Tips
- The
1031 × 214pxvalue in the status bar is the width and height of the selection, not a coordinate. - The
2403, 1653pxcursor readout is the X and Y starting point, meaning the top-left of the region. - Paint reports in pixels, so pass
MeasurementUnits.Pixelsto match. - Reading the values by eye leaves them off by a few pixels. If the crop clips part of the text, widen
widthorheightslightly, or lowerxory.

