Skip to content
Back to blog
DocumentsHow we built CMR reading that can refuse

A legibility check before reading freight document photos

A vision model that produces confident-sounding fields from an illegible scan is worse than no automation. Here is a legibility gate that measures the image in code before any model sees it.

The most dangerous failure of document reading is confident-sounding fields from an illegible image. Our answer: a deterministic legibility measurement before the model, and an explicit refusal below the threshold.

5 min read

Freight document photos come from the road: taken with a phone in the cab, under a warehouse lamp, in the rain on a ramp. Some are legible. Some are overexposed, blurred, or cropped frames from which fields cannot safely enter the process.

A vision model asked to extract fields from an illegible image may still return a confident, correctly formatted result. An invented record can then travel through the process and surface only during invoicing.

Measure the image before extraction

A common design sends the image to a model and assesses the result afterward. This incurs a model cost for every attempt and asks the model to help judge its own work.

In our freight document control system we inverted it. The test uses seven controlled variants of one generated CMR and no client photos. Before any model sees the image, deterministic code measures five features: brightness, contrast, edge energy, overexposure share, and frame coverage. The measurements compose a legibility score. The same image always gets the same score, and the threshold is a number in configuration that can be calibrated on the client's corpus.

Below the threshold, the run ends in an explicit refusal: no extraction attempt, no model call, and no model-text usage. The refusal carries the measured values and a request for a new shot, so the driver knows what to fix. Above the threshold, the image gets one structured extraction, with fields pinned to regions of the photo, and an operational record exists only after the operator approves.

The gate's economics

This order separates model-call cost from the handling cost of an illegible input. None of the five blocked images triggered the model or used any model-text units. The recorded extraction of one legible document used 2,095 such units, took 15.92 seconds, and cost about PLN 0.028.

There is a less obvious benefit too: the gate protects data quality better than any prompt. A model that receives only post-measurement images works in a range where its outputs can be verified, because the fields stand next to their source regions on the operator's screen.

What the seven-image test showed

The controlled test uses seven variants of one synthetic CMR: two legible and five degraded in different ways. The gate matched every prepared label, and extraction on the legible variant scored 1.0 on the combined precision-and-recall measure (F1) across four fields.

The test uses one blank Polish CMR form with generated field values, transformed into seven variants. It contains no photos from drivers' phones. The gate behaved as expected on those variants; every deployment still needs threshold calibration against the client's real mix of blur, glare, framing, and camera quality.

Calibrating the threshold on company documents

The threshold should come from a labeled sample of actual photos rather than one visually pleasing example. Operators identify images from which the required fields can be read safely and images that require a new shot. The gate's decision is then compared with that review.

The comparison creates four groups:

Gate resultActual stateOperational meaning
passedlegiblecorrect route to extraction
heldillegiblecorrect request for a new image
passedillegiblerisk of plausible but incorrect fields
heldlegibleunnecessary driver work and settlement delay

The two error types have different costs. A carrier may choose a conservative threshold when one wrongly accepted document delays invoicing or creates a dispute. At high volume, unnecessary rejections also become expensive. The process owner needs to choose this tradeoff explicitly.

Calculating the gate's economics

A complete cost model needs four inputs:

workflow cost =
  model extractions × cost per extraction
  + manual reviews × review time × labor rate
  + repeat-photo requests × delay and contact cost
  + incorrectly accepted documents × average correction cost

The gate can reduce the first and fourth terms while increasing the third when its threshold is too strict. This is why model-call cost alone does not evaluate the whole document workflow.

Pilot checklist

Collect images from different phones, shifts, locations, and lighting conditions. Keep natural defects such as glare, motion blur, cropping, folded paper, shadow, and multiple pages in one frame. For each photo, retain the operator's decision and the confirmed values of the required fields.

During the pilot, measure:

  • illegible images incorrectly passed and legible images incorrectly held,
  • extraction quality for each field separately,
  • time from a repeat-photo request to the new submission,
  • the share of documents requiring manual review,
  • end-to-end case cost including contact and correction,
  • differences by source, device, and operating conditions.

Rerun this set after changing the threshold, the driver's capture app, or the extraction mechanism.

What to apply in another document workflow

For document reading from images, assess input quality in code before the model runs and treat refusal as a normal result. This reduces unnecessary calls and gives operators a clear reason to request a better image.

Details and full measurements are on the case page, and on a free process scan we will show the gate live, refusals included.

Free process scan

Start with a free process scan.

  • A 30-minute call with the engineer who would lead the work.
  • A review of the processes that cost you the most time and money.
  • A written summary of what to automate first and the likely cost range.

The scan is free and creates no obligation. If automation is unlikely to pay off, the written recommendation will say so.

€0

30 minutes · written takeaway within 2 business days

Book a free process scan (30 min)

Times are shown in your own time zone. We work with clients across time zones.

Describe the process in the form