Updated February 16, 2025
Share:

How to Read Screenshots using IronOCR

by Curtis Chau

Screenshots are a quick and easy way to share information and quickly capture vital information to send to colleagues and peers. However, extracting text from screenshots has often proven difficult because of the dimensions and noise involved in taking them. This makes screenshots a less effective medium in the release of OCR.

However, IronOCR resolves that issue by providing specialized methods such as "ReadScreenShot" to combat this. "ReadScreenshot is optimized for reading screenshots and extracting information from them; it also accepts common file formats.

In this guide, we'll quickly demonstrate how to use IronOCR for screenshot text recognition, walking through examples and the properties of the result object.

Start using IronOCR in your project today with a free trial.

First Step:
green arrow pointer

To use this function, you must also install the IronOcr.Extension.AdvancedScan package.

Read Screenshots Example

To read a screenshot in IronOCR we have to apply the following steps We utilize the ReadScreenShot method, which takes an OcrInput as a parameter for the input. This method is more optimized for screenshots than the library's standard Read counterpart.

Please note

  • The method currently only works for English, Chinese, Japanese, Korean, and LatinAlphabet.
  • Using advanced scan on .NET Framework requires the project to run on x64 architecture.

Input

Below is our input for the code example; we'll demonstrate the versatility of this method by mixing different text fonts and sizes.

Input

Code

:path=/static-assets/ocr/content-code-examples/how-to/read-screenshot-read-screenshot.cs
using IronOcr;
using System;
using System.Linq;

// Instantiate OCR engine
var ocr = new IronTesseract();

using var inputScreenshot = new OcrInput();
inputScreenshot.LoadImage("screenshotOCR.png");

// Perform OCR
OcrPhotoResult result = ocr.ReadScreenShot(inputScreenshot);

// Output screenshot information
Console.WriteLine(result.Text);
Console.WriteLine(result.TextRegions.First().Region.X);
Console.WriteLine(result.TextRegions.Last().Region.Width);
Console.WriteLine(result.Confidence);
Imports IronOcr
Imports System
Imports System.Linq

' Instantiate OCR engine
Private ocr = New IronTesseract()

Private inputScreenshot = New OcrInput()
inputScreenshot.LoadImage("screenshotOCR.png")

' Perform OCR
Dim result As OcrPhotoResult = ocr.ReadScreenShot(inputScreenshot)

' Output screenshot information
Console.WriteLine(result.Text)
Console.WriteLine(result.TextRegions.First().Region.X)
Console.WriteLine(result.TextRegions.Last().Region.Width)
Console.WriteLine(result.Confidence)
VB   C#

Output

output

As you can see from the console output above, it extracted all instances of text from the screenshot. Let's dive deeper into the properties of OcrPhotoResult.

Text: The extracted Text from OCR Input.

Confidence: A "double" property that indicates the statistical accuracy confidence of an average of every character, with one being the highest and 0 being the lowest.

TextRegion: An array of "TextRegion" whch holds the property that returns areas where text is found on the screenshot. By default, all TextRegion is a derived Rectangle class from the IronOCR models. It returns the x and y coordinates as well as the height and width of the rectangle.