Code readingTroubleshooting

Seven segment display OCR: set the ROI, reject false reads

Size the ROI to the digit cells, keep the minus-sign cell in view, and validate every seven segment display OCR read by range, character set and repeat frames.

LumaSpec Vision11 min read Share on LinkedIn

On this page 9 sections
  1. 01What goes wrong, in order of probability
  2. 02Size the ROI from the digit grid
  3. 03Keep the minus sign inside the ROI
  4. 04Leading-zero suppression: why blank cells invent digits
  5. 05Reject the read before it counts
  6. 06Light, exposure and the polarizer
  7. 07Choosing the reader
  8. 08Sign-off checklist
  9. 09Questions

A panel meter that read correctly yesterday returns 123.4 while the process sits at -123.4, or invents a digit in a cell the display leaves blank. Seven segment and LCD displays fail OCR in ways barcodes never do: unlit segments stay faintly visible, the minus sign shares a digit cell, and instruments suppress leading zeros. This guide sizes the ROI around the digit grid, keeps the sign inside it, and adds validation checks so a wrong read never reaches your PLC. It is for anyone pointing a fixed code reader or smart camera at an instrument display on a test bench, a rig panel or a line.

What goes wrong, in order of probability

Most display-reading failures trace to six causes. Work down the table; on LCD instruments the first three account for most misreads. Rows 1 and 2 come from set-up geometry and get fixed recipes below; rows 3 to 6 fall to the validation checks further down.

# Symptom Likely cause Test Fix
1 Digits appear in blank cells Ghost segments: unlit LCD bars stay faintly visible Image a blank value and inspect the empty cells at high zoom Per-cell segment comparison (below)
2 Negative values read positive Sign cell outside the ROI Force a negative value and read 20 frames Widen the ROI one cell left; add "-" to the character set
3 Random extra characters in the string Unit symbols or panel print inside the ROI Log every string for one shift and list the extras Tighten the right edge; restrict the character set
4 The value flickers between two readings Threshold splits lit and unlit bars poorly Histogram the ROI: lit and unlit peaks less than ~40 gray levels apart Fix light and exposure before touching the threshold
5 The decimal point jumps position The dot is small and misclassified Compare the decimal position across 100 frames Fix decimal places in software; ignore the dot
6 One segment changes between frames Multiplexed LCD drive caught mid-cycle Compare per-segment brightness across two exposures of very different length Lengthen the exposure past the display's drive period, or average two frames

Size the ROI from the digit grid

Set the ROI from the display's geometry, measured once on the image:

  • Left edge: one full digit cell left of the first value digit. That cell carries the minus bar and is blank most of the time.
  • Right edge: tight against the last digit. Unit symbols (V, A, °C) and panel printing are the main source of phantom characters.
  • Top and bottom: the digit block plus 10-20% of the digit height in total, so the decimal dot stays inside and neighboring print stays out.
  • Cell shape: most seven segment digit cells run about twice as tall as wide, with a pitch of 1.1-1.2 cell widths between digits. Measure both values on your image and use what you measure.
px/mm = sensor width (px) / FOV width (mm) digit height (px) = digit height (mm) × px/mm ROI height = digit height (px) × 1.2 cell width (px) = digit height (px) / 2 digit pitch (px) = cell width (px) × 1.15 ROI width = digit pitch × (digits + 1) + 0.2 × cell width

The +1 cell in ROI width is the sign cell; the 0.2 term is the side margin.

Worked example. A four-digit panel meter, 50 mm × 18 mm window, 12 mm digit height, shot with a 2592 px wide sensor over a 56 mm field of view:

  • px/mm = 2592 / 56 = 46.3 px/mm
  • digit height = 12 mm × 46.3 = 555 px
  • ROI height = 555 × 1.2 = 666 px
  • cell width = 555 / 2 = 278 px; pitch = 278 × 1.15 ≈ 320 px
  • ROI width = 320 × 5 + 0.2 × 278 = 1,656 px

The ROI fits the 2592 px frame with room for bracket drift, and each digit stands 555 px tall, far above the 40-60 px that reliable OCR wants — at that size a segment bar, roughly a tenth of the digit height, stays 4-6 px wide, so a one-pixel glare streak cannot merge neighboring bars. Pixels rarely constrain a display read; contrast does. If the instrument cannot show an all-segments-on calibration image, set the ROI from the fullest value it legitimately displays and confirm the sign cell by forcing a negative reading.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

For your own display, the calculator above turns field of view and digit size into the pixel counts to expect.

A tight ROI also cuts decode time per frame, the same effect tight ROIs deliver on inline barcode reads. When one frame must carry two displays or a value plus a serial number, give each its own ROI and decode separately, the pattern behind OCR on a fixed code reader with multiple text strings in one image.

Keep the minus sign inside the ROI

On a seven segment display the minus is the middle horizontal bar of the leading digit cell, sitting at mid-height — not a hyphen floating above the number. On a 3.5-digit meter that cell shows a leading 1 or the bar and is blank otherwise, so it is easy to crop away by eye. Two changes make sign detection work:

  1. Widen the ROI left by one full cell and include the full digit height, so the bar sits well inside at every reading.
  2. Add "-" to the allowed character set. Without it the engine drops the bar and returns a positive value, or promotes the blank cell to a phantom 1.

What happens to a signed string afterwards — parsing, sign conventions, unit scaling — is its own problem; the minus sign recognition guide covers distinguishing negative values downstream.

Leading-zero suppression: why blank cells invent digits

An instrument showing 8.5 on a four-digit display leaves two cells blank. On an LED display blank means dark. On an LCD the unlit segments stay faintly visible, and that is where false reads come from: a global threshold low enough to keep the real bars also keeps the ghosts, so a blank cell decodes as 0 or 8 and 8.5 becomes 088.5. Raising and lowering that threshold cannot fix it — one setting either kills dim real segments or keeps ghosts, because the two sit close together in the histogram.

Judge each segment against its own cell instead:

  1. Split each digit cell into its seven segment boxes.
  2. Measure how far each bar sits below the cell's own background. Illustrative numbers from a bench instrument: lit bars measured 60-75 gray levels darker than their cell background, ghost bars 15-25. A cut at 40 separates the groups with margin on both sides.
  3. Decode the digit from the seven on/off decisions. Seven segments form 128 patterns and only eleven are legal — the ten digits plus a lone middle bar. Any other pattern means a corrupt read; reject the frame instead of taking the nearest character.

Suppression then resolves itself: a suppressed cell yields the all-off pattern, not a phantom 0, and no fixed-width parser can talk you into a digit that is not on the glass.

Reject the read before it counts

Validation belongs in the reader, not in the PLC's string handling. Five checks, cheapest first:

  1. Character set. Allow 0-9, "-" and "." and nothing else. Every letter removed widens the margin between the best and second-best candidate.
  2. Score floor. Most engines return a per-read score. Read about a hundred frames of known values plus a set of degraded ones — low contrast, glare, half the nominal exposure — then set two levels: accept above the worst good score, return no-read below the best bad score. The logic is the same as judging whether a barcode decode is trustworthy.
  3. Fixed decimal. Instruments hold a fixed number of decimal places. Configure the reader for that format and place the decimal in software rather than trusting the printed dot.
  4. Range check. A flow meter that physically cannot leave 0.0-99.9 should fail any read outside that window. Set the limits from the instrument's specification, not from values seen so far.
  5. Three identical frames. Latch a value only after three consecutive frames return the same string. At 30 fps that costs about 100 ms — nothing next to a wrong value in a quality log. PLC ladder logic to compare strings and count three reads shows the latch, and storing ASCII barcode strings in PLC memory covers the byte side if you pass strings instead of numbers.

Light, exposure and the polarizer

Keep the reader square to the display — tilting shifts LCD contrast with viewing angle — and light diffusely from near the camera axis; the light finder filters for diffuse geometries. Set exposure so the lit bars peak just below saturation, around 220-240 on an 8-bit image: clipping blooms the bars into the gaps, and crushed blacks pull ghosts up toward real ones. Quick test: the lit and unlit histogram peaks should sit roughly 40 gray levels apart or more. Closer than that, change light or exposure before touching any threshold.

Glare off the cover glass is largely unpolarized, while the segment light leaving an LCD is linearly polarized. A polarizer aligned with the display's axis passes the segments and suppresses the reflection; an ideal polarizer transmits half of unpolarized light, so budget for exposure to lengthen about a factor of two.

The MV-IDB005EXI-05NRP carries a polarizer on its 4.63 mm lens and focuses at 70 mm.

Fixed code readersHikrobot MV-IDB005EXI-05NRP Fully isolated version, 1.3 MP resolution, 4.63 mm focal length, 70 mm focus distance, Polarized industrial code readerMV-IDB005EXI-05NRP
Interface
Fast Ethernet
Resolution
Up to 3 MP
Shutter
Global
Lens mount
M5.8
$719.00 · quotedView and quote

Choosing the reader

Pixels disqualify nothing here: a 12 mm digit needs 50 px of height, and every reader in the fixed code readers category clears that at panel-meter distances with room to spare. Choose on standoff, mounting and output instead.

For a clean single-display job, the LS-CRD-0028 pairs a 2560 x 2048 global-shutter sensor with an 8 mm lens and reads 30 fps, which sustains the three-frame latch with time left in the cycle. At 30 fps, three identical frames take about 100 ms.

Fixed code readers2560 x 2048 fixed code reader, 30 fps, 60 codes/s, 8 mm lens (LS-CRD-0028)LS-CRD-0028
Interface
Fast Ethernet
Resolution
5 MP
Sensor format
1/1.7"
Shutter
Global
$920.00View part

Mounting depth decides the focal length: for the same display size a 12 mm lens sits farther back than a 4.9 mm one, so match the optics to the bracket, not the other way round. The 4.9 mm model carries integrated white light for close-in mounts.

Fixed code readersHikrobot MV-ID3013PM-12M-WBN 12mm focal length 1.3 MP Compact Industrial Code ReaderMV-ID3013PM-12M-WBN
Interface
Fast Ethernet
Resolution
Up to 3 MP
$1,979.00View part
Fixed code readersHikrobot MV-ID813M-05S-WBN-SR 1.3 MP resolution, 4.9 mm focal length, White light, SR, GigE, Static cableMV-ID813M-05S-WBN-SR
Interface
GigE
Resolution
Up to 3 MP
$719.00View part

When the display is small in the frame — a whole panel in view — buy pixels instead. The MV-ID5120RM-08M-RBN carries a 12 MP sensor on an M12 mount.

Fixed code readersHikrobot MV-ID5120RM-08M-RBN Industrial Code ReaderMV-ID5120RM-08M-RBN
Interface
GigE
Resolution
12 MP
Shutter
Rolling
Lens mount
M12
$1,969.00View part

A 12 MP frame holds a panel of instruments and still leaves every digit far above the 50 px floor. And if the same device must also judge pass or fail on the unit, the smart cameras & vision sensors run OCR and inspection tools on one processor.

Measure the window and digit height, drop them into the calculator above, then shortlist in the camera finder and walk mounting, light and trigger in the system configurator. The applications team reviews a photo of your display before you order — send it through the contact page. More reading sits on the code reading topic page.

Sign-off checklist

Before the reader goes on the line:

  • ROI includes the blank sign cell — otherwise negatives read positive.
  • ROI excludes unit symbols and neighboring print — phantom characters otherwise.
  • Margins total 10-20% of digit height, decimal dot inside — a clipped dot otherwise.
  • Character set is 0-9, "-" and "." only — letters otherwise smuggle in.
  • Sign proven on twenty forced negative frames — spot checks miss intermittent crops.
  • Blank value imaged and ghost cells checked — suppressed zeros otherwise invent digits.
  • Lit bars peak at 220-240 gray, peaks at least ~40 levels apart — blooming and threshold noise otherwise.
  • Decimal places fixed in software — factor-of-ten log errors otherwise.
  • Range limits set from the instrument's specification — out-of-range reads otherwise pass.
  • Three-frame latch with a no-read state the PLC treats as reject — single-frame guesses otherwise reach the log.

Questions

How many pixels tall does a seven segment digit need to be?

Give each digit 40-60 pixels of height; a typical segment bar is about a tenth of that, so bars stay 4-6 pixels wide and a one-pixel glare streak cannot merge neighbors. Below about 20 pixels of height, template matching degrades; switch to splitting the cell into seven segment boxes and decoding from the on/off pattern, which still works on smaller digits.

Where does the minus sign sit on a seven segment display?

Mid-height, inside the leading digit cell: the minus is the middle horizontal segment of that cell, not a symbol above the number. On 3.5-digit meters the cell is blank most of the time, which is why it gets cropped out. Cover the full cell with the ROI and enable the minus character in the OCR set, or every negative reads as positive.

Why does my reader return a digit where the display shows nothing?

Unlit LCD segments remain faintly visible, and any global threshold low enough to keep the real bars keeps the ghosts too, so a blank cell decodes as 0 or 8. Leading-zero suppression guarantees blank cells on real readings. Compare each segment with its own cell background instead of using one global threshold, and the ghosts fall out.

Should I include the decimal point in the OCR read?

Leave it out. Instruments hold a fixed number of decimal places, so configure the reader to expect that format and place the decimal in software. The printed dot is a few pixels across, easily confused with dust or a segment corner, and a one-place shift corrupts a logged value by a factor of ten while still looking plausible.

Can one camera read the display and do a pass/fail check on the unit?

Yes. Run the display ROI as an OCR tool and the rest of the frame as your inspection tools on the same smart camera, and send one combined result to the PLC. Check cycle time: OCR plus inspection on a full frame costs more processing than the OCR alone, so confirm the camera's processor holds your takt with both running.