Skip to content
LexDataLexData
PlatformIndustriesCustomers
DocsThe Field GuideBlogWhy models drift
AboutCareersSecurityContact
Log inStart now
← All posts

Operations · 6 min read

Machine vision lens selection worked back from the smallest defect in pixels

The lens is chosen from the defect, not from the drawer. Start with how many pixels a torn seal needs, and a later lens swap is a new camera to the model.

Summary

This post works through specifying the lens for a new inspection station on a packaging line, from the smallest defect that has to be visible in pixels to the field of view, working distance, mount and sensor coverage that follow from it. It concludes that the arithmetic is done once and that a later lens swap is a sensor replacement as far as the model is concerned. It is for the engineers commissioning a camera over a line.

Finn Ellingwood · Engineer · Sep 30, 2026

Cartons passing a scanner on a packaging line, generated scene with detections from our model

The new inspection station on packaging line 2 has a camera, because the camera was ordered first, and a lens, because there was one in the drawer. The drawer holds eleven lenses from three decommissioned stations and none of them is labelled. The defect the station exists to catch is a torn heat seal on a carton, a tear that can be as short as two millimetres, and on the monitor at commissioning the tear is a smudge a person can see if told where to look.

The model cannot be told where to look. It gets the pixels, and the lens decides how many of them the tear gets.

Start from the smallest defect and count its pixels

Before any lens arithmetic, the question is how many pixels across the smallest defect must be for the model to have something to learn. A tear that lands on 2 px is a change in the noise. At 6 px it has an edge and a direction. At 10 px or more a reviewer can label it without squinting, and a reviewer who cannot see the defect cannot check the label, which matters because a person checks every label before the model trains.

So the two-millimetre tear sets the resolution the station needs: a tear that small must cover at least ten pixels, which fixes how many pixels each millimetre of carton gets, and from there the rest is geometry. Written down as one line on the station's drawing, it is the number every other choice is checked against.

The field of view and the working distance set the focal length

The belt on line 2 is four hundred millimetres wide and the cartons ride anywhere on it, so the frame has to cover the belt with a margin either side. That is the field of view. The guard over the belt leaves half a metre between the camera mount and the carton top, and it cannot be moved without a new guard. That is the working distance.

The sensor's width, the field of view and the working distance together give the focal length, and the arithmetic is a ratio a person does on paper in a minute. What matters more than the formula is the order: the field of view came from the belt, the distance came from the guard, and the focal length is whatever falls out. A station where the focal length was chosen first, because the lens was in the drawer, ends up with a field of view that clips one edge of the belt, and the cartons that ride that edge are never inspected.

Then check the resolution line against the result. If the belt fills the sensor and the two-millimetre tear still gets its ten pixels, the sensor is big enough. If it does not, either the camera changes or the station gets two cameras, each covering half the belt, and the second choice is often cheaper than the first.

The mount and the sensor have to fit the lens

A lens draws a circle of light on the sensor, and the sensor has to sit inside it. A lens made for a small sensor on a camera with a large one draws a bright circle with dark corners, and a carton at the corner of the belt sits in the dark. The mount has to agree too. The station on line 2 has a C-mount camera, and two of the eleven lenses in the drawer are CS-mount and will never reach focus on it, which is a fact somebody discovers at 5 pm on the commissioning day.

The drawer gets labels after that. It should have had them before.

The aperture decides whether the tall carton is sharp

Cartons on line 2 come in two heights, and the camera is focused on one of them. The aperture sets how much either side of that focus is still sharp. Wide open, the lens lets in the most light and the tall carton's seal is soft. Stopped down, both heights are sharp and the frame is darker, so the light has to come up or the exposure has to lengthen, and a longer exposure on a moving belt smears the tear the station is looking for.

My own view is that a zoom lens has no place on a fixed inspection station. It is heavier, softer at the edges than a fixed lens of the same price, and the ring drifts when the guard vibrates, so the field of view the calibration was done for is not the field of view in March. The station on line 2 got a fixed lens, chosen from the arithmetic, and the surface defect detection it does is the same job at a different scale: a small, low-contrast thing on a surface where a lighting artefact looks like a flaw.

Computer vision applications on a line inherit the lens

Everything the model learns about the torn seal, it learns at this focal length, at this working distance, through this glass. Its boxes are drawn on frames where the tear covers ten pixels and the belt's edge is at a known place. Computer vision applications on a line are built on that consistency, and it is invisible until it changes.

LexData takes the seal model through its whole life. You type what to look for, Lexi puts a box on every frame, and a person checks each label before anything trains on it. The model then watches the line 2 camera, in the cloud, on your servers, or on a runner beside the recorder. Frames it is unsure of come back to a person, the corrections retrain it, and the new version replaces the old one with no downtime. That review queue is where the lens shows up again, months later.

A later lens swap is a new camera as far as the model is concerned

The lens on line 2 gets knocked in a wash-down the following year and the maintenance crew fits one from the drawer. Same mount, roughly the same focal length, different glass. The frame on the monitor looks the same. The tear now covers eight pixels rather than ten, the edges of the belt are a little softer, and the colour has shifted towards warm.

The drift catalog calls this a camera was replaced, and it looks the same whether the sensor or the lens changed: one station changes character on the day it was serviced, as a step rather than a slope, while the stations either side hold. The review queue for line 2 fills with seals the model doubts. The fix is a short window of frames through the new lens, labeled and folded in, and the arithmetic from the commissioning drawing checked against the new lens before the model is asked to learn it.

See it on your own footage.

Start with your footage

More in Operations

Operations · 6 min read

Camera calibration for computer vision, and why the part at the edge of the frame measures wrong

A straight edge bows at the corner of the frame, so a part that passes in the centre fails at the edge. Calibrate once, and again the day the lens changes.

Stephen Biswas · Sep 30, 2026

Operations · 6 min read

Evaluating a computer vision platform once the pilot ends

The feature spreadsheet cannot tell you which platform survives the second year. Walk the lifecycle instead, from import to a retrain that keeps the old frames.

Ayman Quadir · Sep 30, 2026

Operations · 6 min read

Face blurring for privacy in computer vision, done before the frame is stored

A blur applied after the request arrives is a blur applied to a frame that has already been copied. The step belongs at ingestion, beside the recorder.

Esdras Ntuyenabo · Sep 30, 2026

LexData
LexData

Product

  • Platform
  • Industries
  • Use cases

Resources

  • Docs
  • The Field Guide
  • Blog
  • Why models drift

Industries

  • Energy & utilities
  • Oil & gas
  • Agriculture
  • Manufacturing
  • Insurance
  • Retail
  • Robotics

Company

  • About
  • Customers
  • Careers
  • Contact

Trust

  • Security
  • Privacy
  • Terms

Stay updated

What we learn running vision models in production.

See everything.
Miss nothing.

Stay updated

What we learn running vision models in production.

Terms of use & Privacy policy

© 2026 LexData Labs · All rights reserved