How to use Computer Vision to Find Text

IronOCR utilizes OpenCV to use Computer Vision to detect areas where text exists in an image. This is useful for images that contain a lot of noise, images with text in many different places, and images where text is warped. The use of computer vision in IronOCR will determine where text regions exist and then use Tesseract to attempt to read those regions.

IronOCR.ComputerVision Installation via NuGet Package

OpenCV methods that perform Computer Vision in IronOCR are visible in the regular IronOCR NuGet package.

Use of these methods requires NuGet installation of IronOcr.ComputerVision to the solution. You are prompted to download it if you do not have it installed.

  • Windows: IronOcr.ComputerVision.Windows
  • Linux: IronOcr.ComputerVision.Linux
  • macOS: IronOcr.ComputerVision.MacOS
  • macOS ARM: IronOcr.ComputerVision.MacOS.ARM

Install using the NuGet Package Manager or paste the following in the Package Manager Console:

Install-Package IronOcr.ComputerVision.Windows

This will provide the necessary assemblies to use IronOCR Computer Vision with our model file.

Functionality and API

Code Examples are included further down this tutorial. Here is a general overview of the methods that are currently available:

Method Explanation
FindTextRegion Detect regions which contain text elements and instruct Tesseract to only search for text within the area in which text was detected.
FindMultipleTextRegions Detect areas which contain text elements and divide the page into separate images based on text regions.
GetTextRegions Scans the image and returns a list of text regions as `List`.

FindTextRegion

Usage of FindTextRegion will use computer vision to detect regions which contain text elements on every page of an OcrInput object.

:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findtextregion-1.cs
using IronOcr;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("/path/file.png");

input.FindTextRegion();
OcrResult result = ocr.Read(input);
string resultText = result.Text;
Imports IronOcr

Private ocr = New IronTesseract()
Private input = New OcrInput()
input.LoadImage("/path/file.png")

input.FindTextRegion()
Dim result As OcrResult = ocr.Read(input)
Dim resultText As String = result.Text
$vbLabelText   $csharpLabel

Caution This method overload is currently depreciated in IronOcr 2025.6.x and doesn't take custom parameters.

Can optionally be called with custom parameters:

:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findtextregion-2.cs
using IronOcr;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("/path/file.png");

input.FindTextRegion(Scale: 2.0, DilationAmount: 20, Binarize: true, Invert: true);
OcrResult result = ocr.Read(input);
string resultText = result.Text;
Imports IronOcr

Private ocr = New IronTesseract()
Private input = New OcrInput()
input.LoadImage("/path/file.png")

input.FindTextRegion(Scale:= 2.0, DilationAmount:= 20, Binarize:= True, Invert:= True)
Dim result As OcrResult = ocr.Read(input)
Dim resultText As String = result.Text
$vbLabelText   $csharpLabel

In this example, I will use the following image for a method I am writing which needs to crop to areas containing text but input images may vary in text location. In this case, I can use FindTextRegion to narrow down the scan to an area that Computer Vision has detected text. This is an example image:

Image with Text
:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findtextregion-3.cs
using IronOcr;
using IronSoftware.Drawing;
using System;
using System.Linq;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("wh-words-sign.jpg");

// Find the text region using Computer Vision
Rectangle textCropArea = input.GetPages().First().FindTextRegion();

// For debugging and demonstration purposes, lets see what region it found:
input.StampCropRectangleAndSaveAs(textCropArea, Color.Red, "image_text_area", AnyBitmap.ImageFormat.Png);

// Looks good, so let us apply this region to hasten the read:
var ocrResult = ocr.Read("wh-words-sign.jpg", textCropArea);
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Imports IronSoftware.Drawing
Imports System
Imports System.Linq

Private ocr = New IronTesseract()
Private input = New OcrInput()
input.LoadImage("wh-words-sign.jpg")

' Find the text region using Computer Vision
Dim textCropArea As Rectangle = input.GetPages().First().FindTextRegion()

' For debugging and demonstration purposes, lets see what region it found:
input.StampCropRectangleAndSaveAs(textCropArea, Color.Red, "image_text_area", AnyBitmap.ImageFormat.Png)

' Looks good, so let us apply this region to hasten the read:
Dim ocrResult = ocr.Read("wh-words-sign.jpg", textCropArea)
Console.WriteLine(ocrResult.Text)
$vbLabelText   $csharpLabel

Now this code has two outputs, the first is a .png file saved by StampCropRectangleAndSaveAs which is used for debugging. We can see where IronCV (Computer Vision) thought the text was:

Image with Text Area Highlighted

Looks pretty good. Now the second output is the Text itself which is:

IRONSOFTWARE

50,000+

Developers in our active community

10,777,061 19,313
NuGet downloads Support tickets resolved
50%+ 80%+
Engineering Team growth Support Team growth
$25,000+

Raised with #TEAMSEAS to clean our beaches & waterways

FindMultipleTextRegions

Usage of FindMultipleTextRegions takes all pages of an OcrInput object and uses computer vision to detect areas which contain text elements and divide the input into separate images based on text regions:

:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findmultipletextregions-1.cs
using IronOcr;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("/path/file.png");

input.FindMultipleTextRegions();
OcrResult result = ocr.Read(input);
string resultText = result.Text;
Imports IronOcr

Private ocr = New IronTesseract()
Private input = New OcrInput()
input.LoadImage("/path/file.png")

input.FindMultipleTextRegions()
Dim result As OcrResult = ocr.Read(input)
Dim resultText As String = result.Text
$vbLabelText   $csharpLabel

Caution Starting from IronOcr v2025.6.x, the FindMultipleTextRegions method no longer supports custom parameters.

Can optionally be called with custom parameters:

:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findmultipletextregions-2.cs
using IronOcr;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("/path/file.png");

input.FindMultipleTextRegions(Scale: 2.0, DilationAmount: -1, Binarize: true, Invert: false);
OcrResult result = ocr.Read(input);
string resultText = result.Text;
Imports IronOcr

Private ocr = New IronTesseract()
Private input = New OcrInput()
input.LoadImage("/path/file.png")

input.FindMultipleTextRegions(Scale:= 2.0, DilationAmount:= -1, Binarize:= True, Invert:= False)
Dim result As OcrResult = ocr.Read(input)
Dim resultText As String = result.Text
$vbLabelText   $csharpLabel

Another overload method of FindMultipleTextRegions takes an OCR Page and returns a list of OCR Pages, one for each Text region on it:

:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findmultipletextregions-3.cs
using IronOcr;
using System.Collections.Generic;
using System.Linq;

int pageIndex = 0;
using var input = new OcrInput();
input.LoadImage("/path/file.png");

var selectedPage = input.GetPages().ElementAt(pageIndex);
List<OcrInputPage> textRegionsOnPage = selectedPage.FindMultipleTextRegions();
Imports IronOcr
Imports System.Collections.Generic
Imports System.Linq

Private pageIndex As Integer = 0
Private input = New OcrInput()
input.LoadImage("/path/file.png")

Dim selectedPage = input.GetPages().ElementAt(pageIndex)
Dim textRegionsOnPage As List(Of OcrInputPage) = selectedPage.FindMultipleTextRegions()
$vbLabelText   $csharpLabel

GetTextRegions

Usage of GetTextRegions returns a list of crop areas where text was detected in a page:

:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-gettextregions.cs
using IronOcr;
using IronSoftware.Drawing;
using System.Collections.Generic;
using System.Linq;

int pageIndex = 0;
using var input = new OcrInput();
input.LoadImage("/path/file.png");

var selectedPage = input.GetPages().ElementAt(pageIndex);
// List<Rectangle> regions = selectedPage.GetTextRegions();
Imports IronOcr
Imports IronSoftware.Drawing
Imports System.Collections.Generic
Imports System.Linq

Private pageIndex As Integer = 0
Private input = New OcrInput()
input.LoadImage("/path/file.png")

Dim selectedPage = input.GetPages().ElementAt(pageIndex)
' List<Rectangle> regions = selectedPage.GetTextRegions();
$vbLabelText   $csharpLabel

Specific Use Case Guides

With the right settings and input files, OCR can be a very powerful tool. It can almost perfectly imitate the reading capability of a human.

Frequently Asked Questions

How can I leverage Computer Vision for text detection in images?

IronOCR can be used to enhance text detection in images by utilizing its integration with OpenCV. Methods like FindTextRegion and FindMultipleTextRegions allow you to locate and manipulate text areas effectively.

What steps are required to install IronOCR for Computer Vision on different operating systems?

To use IronOCR on different operating systems, you can install the IronOCR.ComputerVision package via NuGet. Use the command Install-Package IronOcr.ComputerVision.Windows for Windows, with similar packages available for Linux and macOS.

What functionality does the FindTextRegion method provide?

The FindTextRegion method in IronOCR identifies areas in an image where text is present, allowing Tesseract to search for text only within those specified regions, improving OCR accuracy.

How do custom parameters improve text region detection?

You can refine text region detection in IronOCR by using custom parameters with the FindTextRegion method, such as setting the minimum text height and allowing subregions, to more precisely identify text areas in images.

Why is detecting multiple text regions in an image beneficial?

Detecting multiple text regions using the FindMultipleTextRegions method in IronOCR helps divide an image into separate sections based on text, which is particularly useful for processing documents with multiple text blocks like invoices and subtitles.

How can detected text areas be retrieved from an image?

The GetTextRegions method in IronOCR allows you to retrieve a list of CropRectangle areas where text was detected within an image, enabling further processing or manipulation of those text regions.

What are the key features of IronOCR's Computer Vision capabilities?

IronOCR's Computer Vision features include text region detection through methods like FindTextRegion and FindMultipleTextRegions, customizable OCR settings, and support for multiple operating systems to enhance text detection accuracy.

How does IronOCR process images with multiple text regions?

IronOCR uses the FindMultipleTextRegions method to process images by dividing them into separate images based on detected text regions, enabling detailed analysis and manipulation of each text area.

Where can I find code examples for using Computer Vision methods in IronOCR?

The tutorial provides code examples demonstrating the use of methods such as FindTextRegion and FindMultipleTextRegions with IronOCR, illustrating practical applications like reading license plates or processing invoices.

What is needed to utilize IronOCR's Computer Vision features in C#?

To use IronOCR's Computer Vision features in C#, you must install the IronOcr.ComputerVision package via NuGet and include the necessary namespaces in your project to access text detection methods.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.