Reading Text

One reading, on demand. Nothing happens until a client writes <module>/read-text/execute.

What a run does

  1. Refuses the call if this module is already busy (status code -1).

  2. Clears the previous reading, so a failure never leaves old text behind.

  3. Checks every setting and reports all the problems at once.

  4. Reads the image from input/input-image-address.

  5. Applies input/crop.

  6. Runs the OCR engine and publishes the text.

The settings

Node Default What it does

input/input-image-address

(empty)

Address of the image node to read, e.g. hdvisionsystems/lumiscan-cam-driver/camera1/output/image.

input/crop/startX
input/crop/startY
input/crop/width
input/crop/height

0

The part of the image to read. All zero reads the whole image; a zero width or height reaches the right or bottom edge. Crop tight around the text - see Reading Accurately.

input/language

eng

Which language model to read with. The models installed on this device are listed on system/languages.

input/engine

DEFAULT

DEFAULT picks the best available, LSTM is the modern neural-network engine, LEGACY the original pattern-matching one, and COMBINED runs both. LEGACY is worth trying on dot-matrix and laser-etched marking.

input/layout

SINGLE_BLOCK

How much structure to look for in the image.

input/preprocess

NONE

What is done to the image before it is read. Reach for GRAYSCALE when a colour frame comes back with no words at all, which happens when a photograph shares the image with the text - see Reading Accurately.

input/characters/mode
input/characters/allow
input/characters/deny

ALL_SYMBOLS
(empty)
(empty)

Which characters may be returned.

input/min-score

0

The confidence a word must reach to be reported, between 0 and 1.

Reading the result

output/result is a text_read_result flatbuffer.

Field Meaning

text

The whole reading exactly as the engine produced it, lines separated by newlines. Not filtered by min-score.

words[].text
words[].score
words[].bbox_x … bbox_height

One recognised word, its confidence from 0 to 1, and a box around it in the coordinates of the region that was read.

word_count

How many words are reported.

mean_score

Average confidence over the reported words; 0 when there are none.

min_score

The threshold that was applied, so a short word list reads as "strict" rather than "bad image".

language

The language actually used - not always the one asked for.

engine, layout

As actually used.

image_width, image_height

The region that was read - the whole image unless a crop was set.

timestamp

Microseconds since the epoch, when the reading finished.

text and words[] can disagree, on purpose

text is the engine’s own output, with the line breaks it found. words[] is filtered by min-score. With min-score at 0.8, a word the engine reported at 0.4 appears in text and not in words[].

If you need them to agree, read text only when word_count is the number you expected.

When it fails

Situation Status code What you get

Another operation on this module is running

-1

Nothing done; the previous reading is left alone

Any setting is unusable

-2

Every problem named in one status-text

The image node cannot be read

-3

Empty result

The crop does not fit the image

-2

Empty result

The OCR engine could not start

-7

Empty result, with the reason in status-text

Nothing readable in the image

1 (success)

Empty text, word_count 0

The last two rows are the distinction that matters most in production: a reader that could not start reports -7 and says why, while a working reader looking at a blank part reports success with no words. They used to be indistinguishable.

The outputs belong to the run that is starting

Every execute empties output/result the moment it begins, so a client must read a result before triggering the next reading. status-code and status-text are the exception - they always describe the latest attempt.