How to Find Text with Computer Vision in C#
IronOCR uses OpenCV computer vision to automatically detect text regions in images before OCR processing. This improves accuracy for noisy, multi-region, or warped text by focusing Tesseract recognition only on identified text areas, significantly enhancing extraction results compared to processing entire images.
Quickstart: Detect and OCR the Primary Text Region
This example demonstrates immediate text extraction: load an image, use IronOCR's Computer Vision to auto-detect the main text region with FindTextRegion(), then run .Read(...) to extract text in one line.
Get started making PDFs with NuGet now:
Install IronOCR with NuGet Package Manager
Copy and run this code snippet.
using var result = new IronTesseract().Read(new OcrInput().LoadImage("image.png").FindTextRegion());Deploy to test on your live environment
- How to OCR License Plate in C# (Tutorial)
- How to Get Text From Invoice in C# Tutorial
- How to OCR Get Text From Screenshot in C#
- How to OCR Subtitles in C# (Tutorial)
Minimal Workflow (5 steps)
- Download C# library to use OCR with Computer Vision
- Utilize
FindTextRegionmethod to auto detect text regions - Check which text region got detected with
StampCropRectangleAndSaveAsmethod - Use computer vision to separate the original image into images based on text regions with
FindMultipleTextRegionsmethod - Use
GetTextRegionsmethod to get crop areas list where text was detected
How Do I Install IronOCR.ComputerVision via NuGet Package?
OpenCV methods that perform Computer Vision in IronOCR are visible in the regular IronOCR NuGet package. For detailed installation guidance, see our NuGet installation guide.
Why Does IronOCR Require a Separate Computer Vision Package?
Using these methods requires NuGet installation of IronOcr.ComputerVision to the solution. You are prompted to download it if you do not have it installed. The computer vision functionality leverages OpenCV algorithms that significantly enhance text detection accuracy, similar to techniques used in our license plate recognition and passport scanning features.
Which Platform-Specific Package Should I Install?
- Windows:
IronOcr.ComputerVision.Windows- See our Windows setup guide - Linux:
IronOcr.ComputerVision.Linux- Check our Linux installation tutorial - macOS:
IronOcr.ComputerVision.MacOS- Review our macOS setup instructions - macOS ARM:
IronOcr.ComputerVision.MacOS.ARM
How Do I Install Using Package Manager Console?
Install using the NuGet Package Manager or paste the following in the Package Manager Console:
Install-Package IronOcr.ComputerVision.Windows
This provides the necessary assemblies to use IronOCR Computer Vision with our model file.
What Computer Vision Methods Are Available in IronOCR?
Code examples are included further down this tutorial. Here is a general overview of the methods 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 |
How Do I Use FindTextRegion to Detect Text Areas?
FindTextRegion uses computer vision to detect regions containing text elements on every page of an OcrInput object. This method is particularly useful when processing images with scattered text or when you need to improve performance by focusing only on text-containing areas.
What Is the Basic FindTextRegion Usage?
:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findtextregion-1.csusing 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;IronOcr 2025.6.x and doesn't take custom parameters.How Can I Customize FindTextRegion Parameters?
Call this method with custom parameters to fine-tune text detection. These parameters work similarly to our image filter configurations:
:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findtextregion-2.csusing 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;What Does FindTextRegion Look Like in Practice?
In this example, I use the following image for a method that needs to crop to areas containing text, but input images may vary in text location. I use FindTextRegion to narrow down the scan to an area that Computer Vision has detected text. This approach is similar to techniques used in our content areas and crop regions tutorial. This is an example image:

:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findtextregion-3.csusing 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);How Do I Debug and Verify Text Region Detection?
This code has two outputs. The first is a .png file saved by StampCropRectangleAndSaveAs used for debugging. This technique is also covered in our highlight texts for debugging guide. We can see where IronCV (Computer Vision) detected the text:
The detection accurately identifies the text area. The second output is the text itself:
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 & waterwaysHow Do I Use FindMultipleTextRegions for Multiple Text Areas?
FindMultipleTextRegions takes all pages of an OcrInput object and uses computer vision to detect areas containing text elements, then divides the input into separate images based on text regions. This is particularly useful for processing documents with multiple distinct text areas, similar to our read table in document functionality:
What Is the Basic FindMultipleTextRegions Usage?
:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findmultipletextregions-1.csusing 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;FindMultipleTextRegions method no longer supports custom parameters.How Can I Customize FindMultipleTextRegions Parameters?
Call this method with custom parameters to control how regions are detected and separated:
:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findmultipletextregions-2.csusing 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;How Do I Process Individual Pages with FindMultipleTextRegions?
Another overload method of FindMultipleTextRegions takes an OCR Page and returns a list of OCR Pages, one for each text region on it. This approach helps when dealing with complex layouts, similar to techniques described in our multipage TIFF processing guide:
:path=/static-assets/ocr/content-code-examples/how-to/computer-vision-findmultipletextregions-3.csusing 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();How Do I Use GetTextRegions to Get Text Region Coordinates?
GetTextRegions returns a list of crop areas where text was detected on a page. This method is particularly useful when you need the coordinates of text regions for further processing or when implementing custom OCR workflows. For more details on working with results, see our OcrResult class documentation:
When Should I Use GetTextRegions Instead of FindTextRegion?
/* :path=/static-assets/ocr/content-code-examples/how-to/computer-vision-gettextregions.cs */
using IronOcr;
using IronSoftware.Drawing;
using System;
using System.Collections.Generic;
using System.Linq;
// Create a new IronTesseract object for OCR
var ocr = new IronTesseract();
// Load an image into OcrInput
using var input = new OcrInput();
input.LoadImage("/path/file.png");
// Get the first page from the input
var firstPage = input.GetPages().First();
// Get all text regions detected on this page
List<Rectangle> textRegions = firstPage.GetTextRegions();
// Display information about each detected region
Console.WriteLine($"Found {textRegions.Count} text regions:");
foreach (var region in textRegions)
{
Console.WriteLine($"Region at X:{region.X}, Y:{region.Y}, Width:{region.Width}, Height:{region.Height}");
}
// You can also process each region individually
foreach (var region in textRegions)
{
var regionResult = ocr.Read(input, region);
Console.WriteLine($"Text in region: {regionResult.Text}");
}/* :path=/static-assets/ocr/content-code-examples/how-to/computer-vision-gettextregions.cs */
using IronOcr;
using IronSoftware.Drawing;
using System;
using System.Collections.Generic;
using System.Linq;
// Create a new IronTesseract object for OCR
var ocr = new IronTesseract();
// Load an image into OcrInput
using var input = new OcrInput();
input.LoadImage("/path/file.png");
// Get the first page from the input
var firstPage = input.GetPages().First();
// Get all text regions detected on this page
List<Rectangle> textRegions = firstPage.GetTextRegions();
// Display information about each detected region
Console.WriteLine($"Found {textRegions.Count} text regions:");
foreach (var region in textRegions)
{
Console.WriteLine($"Region at X:{region.X}, Y:{region.Y}, Width:{region.Width}, Height:{region.Height}");
}
// You can also process each region individually
foreach (var region in textRegions)
{
var regionResult = ocr.Read(input, region);
Console.WriteLine($"Text in region: {regionResult.Text}");
}What Are Common Use Cases for Computer Vision in OCR?
Computer vision significantly enhances OCR accuracy in challenging scenarios. Here are practical applications:
Document Layout Analysis: Identify and process different sections of complex documents automatically. Especially useful with scanned documents.
Multi-Column Text: Separate and read columns independently for newspapers or magazines. Use multithreaded processing for faster results.
Mixed Content: Distinguish between text regions and graphics in documents. Helpful when processing photos with embedded text.
Performance Optimization: Focus OCR processing only on text-containing areas. See our fast OCR configuration guide.
- Quality Control: Verify text detection before full OCR processing. Our progress tracking feature monitors each stage.
With the right settings and input files, OCR can achieve near-human reading capability. For optimal results, combine computer vision with our image optimization filters to achieve the best possible OCR accuracy. When working with low-quality images, our guide on fixing low quality scans provides valuable preprocessing techniques.
Advanced Computer Vision Techniques
For developers looking to push OCR accuracy boundaries, consider these advanced approaches:
- Custom Training: Train the OCR engine for specialized fonts using our custom language files guide
- Multi-Language Support: Process multi-language documents with our multiple languages feature
- Barcode Integration: Combine text recognition with barcode reading using our OCR with barcode reading capabilities
Frequently Asked Questions
What is Computer Vision in OCR and how does it improve text extraction?
Computer Vision in IronOCR uses OpenCV algorithms to automatically detect text regions in images before OCR processing. This significantly improves accuracy for noisy, multi-region, or warped text by focusing Tesseract recognition only on identified text areas, rather than processing entire images.
How can I quickly implement Computer Vision OCR in C#?
IronOCR allows you to implement Computer Vision OCR in just one line of code: use IronTesseract with the FindTextRegion() method to auto-detect the main text region, then run .Read() to extract text immediately.
Why do I need to install a separate Computer Vision package?
IronOCR requires the separate IronOcr.ComputerVision NuGet package because the computer vision functionality leverages OpenCV algorithms. These algorithms significantly enhance text detection accuracy and are essential for features like license plate recognition and passport scanning.
Which platform-specific Computer Vision package should I install?
IronOCR offers platform-specific packages: IronOcr.ComputerVision.Windows for Windows systems, IronOcr.ComputerVision.Linux for Linux distributions, and IronOcr.ComputerVision.MacOS for macOS environments.
How can I detect multiple text regions in an image?
IronOCR provides the FindMultipleTextRegions method to separate the original image into multiple images based on detected text regions. You can also use GetTextRegions to retrieve a list of crop areas where text was detected.
Can I verify which text regions were detected before processing?
Yes, IronOCR includes the StampCropRectangleAndSaveAs method that allows you to check which text regions were detected by the Computer Vision algorithms before running the actual OCR process.






