Blog

How Offline OCR Reads Text From a Screenshot, Step by Step

Written by InSnap · Published · ocr, text recognition, offline, onnx, how it works

How Offline OCR Reads Text From a Screenshot, Step by Step

Two small models, one to find lines of text and one to read them, run on your computer in about 30 ms. What happens between pressing OCR and copying the text, and its limits.

When you select an area and press OCR in InSnap, no screenshot leaves your computer. Two small neural networks run locally: one finds where the lines of text are, the second reads each line. On a small image that takes about 30 ms in an optimised build on our development Mac. This article follows the pipeline step by step and explains why some scripts are read well and others are not.

The two models

InSnap runs them with ONNX Runtime. The models are the PP-OCRv6 "tiny" detection and recognition models published by PaddlePaddle under the Apache-2.0 licence. Together they are roughly 6 MB (about 1.7 MB for detection and 4.3 MB for recognition), small enough to ship inside the app.

Nothing is downloaded when you press OCR. The models are in the app.

Step 1: find the lines

Detection is a segmentation network of the "DB" kind. It does not read anything; it paints a map showing how likely each pixel is to belong to text.

  1. The selection is scaled so its sides are multiples of 32 within the range the model accepts, and the colours are normalised.
  2. The network produces a probability map the same size as the input.
  3. Pixels above a threshold of 0.2 become text regions. Regions whose average score is below 0.4 are discarded.
  4. Each region is turned into a box and expanded outward by a factor of 1.4, because the network tends to paint slightly inside the real letters.

Up to 3000 candidate regions are considered, so dense tables and long chat logs are handled.

Selecting an area and running OCR

Step 2: read each line

Each detected line is cut out and fed to the recognition network.

  • The height is fixed at 48 pixels; the width follows the line.
  • A line shorter than 320 pixels is padded to 320, matching how the model was trained. A longer line keeps its natural width, and only a line beyond 3200 pixels is split.
  • The output is a score for each symbol at each horizontal position. A decoding step called CTC collapses repeated symbols and removes the blank, which leaves the text.

The recognition dictionary has 6904 symbols plus a blank and a space.

What the original is, and what it is not

OCR reads the original selected pixels, not your annotations. Arrows, boxes and highlights you drew are not part of the image that is recognised. That is why you can mark up a screenshot and still copy clean text from it.

Placing the text on the picture

Recognition returns a box for the whole line, not for each character. To let you drag over part of a line, InSnap estimates where each character sits: it measures the width of every character in a system font at the line's height and spreads the line width in proportion. If the font in the screenshot differs from that font, the estimate can be off by up to about half a character.

Why some scripts work and others do not

The dictionary decides what can be read. In our tests Chinese (simplified and traditional), English, and Latin-script languages such as German, French, Spanish, Portuguese and Italian are read well. Japanese kana, Korean and Russian are not read reliably, because those characters are not in the dictionary the model decodes against.

Search the text inside saved screenshots

Speed

ItemFigure
ModelsUnder 6 MB together
A small test imageAbout 30 ms
Network access neededNone

These are measurements from our development machine. Large images with a lot of text take longer.

Where the text goes

The recognised text appears in a panel next to the selection, one line per row. You can drag over it on the picture like normal text, click a line to select it, and copy with Command-C or Ctrl+C. With nothing selected, copying takes all lines. If the screenshot history is allowed to index text, the same recognition makes old screenshots searchable.

FAQ

Does OCR work offline?

Yes. The models are inside the app and recognition runs on your computer. No screenshot or text is uploaded.

Why is one word misread?

The recogniser picks the most likely symbol sequence for each line. Small fonts, unusual typefaces, low contrast and compression artefacts all lower accuracy. Selecting a tighter area or a larger zoom usually helps.

Why can OCR not read Japanese, Korean or Russian?

The model decodes against a fixed dictionary, and the characters used by those scripts are not read reliably with it. This is a limit of the model, not of your screenshot.

Does OCR read my annotations?

No. It reads the original pixels of the selection, so your arrows and highlights do not interfere.

Your next screenshot is one hotkey away.

macOS 14.4+ (Apple Silicon & Intel) · Windows 10+ (64-bit)