What decides where an inspection camera goes on a production line?
Camera placement is decided by whether the smallest rejectable defect is imaged with enough pixels, sharpness and a clear line of sight even in the part's worst position; the choice of model comes after that. A stronger model cannot recover a defect the camera never saw clearly. A camera mounted in the wrong place, discovered only after months of data collection and labelling, makes all of that work worthless.
Edmund Optics' note on the fundamental parameters of an imaging system names the variables of this decision: field of view (the area of the object the camera sees), working distance (from the front of the lens to the object), resolution (the smallest distinguishable detail), depth of field (the maximum object depth kept entirely in acceptable focus), sensor size, and magnification, defined as the ratio of sensor size to field of view. Choosing a camera position means solving these six together for your part and your line.
How do you calculate field of view and pixel resolution?
First derive the field of view from the area the part and its position tolerance occupy, then work out the millimetres per pixel from the sensor's pixel count. A hypothetical example: an 80 mm wide part can drift ±10 mm on the conveyor, and a 5 mm margin is left on each side. The field of view is 110 mm. On a sensor with 2,448 pixels across, each pixel covers about 0.045 mm, and the smallest defect of 0.3 mm spans about 6.7 pixels.
That calculation is necessary but not sufficient. Edmund Optics' note on resolution points out that dividing the object size by the pixel count shows how much of the object each pixel covers, but not whether the information in one pixel can be told apart from its neighbour. The highest frequency a sensor can resolve is two pixels, one line pair, and the real limit is often much lower than calculated because of lens contrast and lighting. So check the pixel calculation against images of real defective parts. A practical range for how many pixels the smallest defect needs, and a motion blur calculation, also appear in our article on vision-based quality control in production.
If the required pixel density does not let a single camera cover the whole part, there are two options: split the field of view across several cameras, or narrow the region where the defect is searched for. Lowering the resolution and hoping the model will compensate is not an option.
How do you choose working distance, depth of field and angle?
Choose the working distance and angle so the part stays in focus and at the same scale across its height differences and position drift. According to Basler's guide to optimizing image quality, when objects sit at different distances from the camera, the depth of focus has to cover all of them; closing the aperture increases depth of focus but reduces the light reaching the sensor, so the image gets darker. Lengthening the exposure to compensate brings motion blur on a moving part, which is why aperture, lighting and exposure are chosen together.
Scale also changes with distance. Edmund Optics' note on telecentric lenses explains that with conventional lenses magnification decreases as the object moves away, which creates parallax, or perspective error: if each part does not sit at the same working distance, the same dimension measures differently on every part. Telecentric lenses remove this error by keeping a constant field of view regardless of distance. If your acceptance rule depends on a measurement in millimetres and part height or position varies, account for that in the placement decision.
For the angle, the rule is simple: look as squarely as possible at the surface to be measured, and plan a separate view for defects on side faces. An oblique view changes the scale from one edge of the image to the other; on shiny surfaces it also changes where reflections fall.
How do you avoid motion blur on a moving part?
The exposure must be short enough that the image of the part does not move by more than one pixel during exposure; Basler's guide states the general rule exactly that way. In the example above each pixel covers 0.045 mm. If the conveyor moves at 500 mm per second, one pixel of movement allows an exposure of 0.045 / 500 seconds, about 90 microseconds. An exposure that short needs strong, usually strobed, light; if there is not enough light, raising the gain amplifies the noise in the same proportion as the signal.
Triggering is part of placement too. Measure where the part sits in the frame across 100 consecutive parts: if the position varies a lot, either widen the field of view or use a sensor or encoder that ties the trigger to the part's position.
How far upstream of the reject point should the camera be?
The camera must sit far enough upstream that the result reaches the reject mechanism before the part does. Divide the distance between the capture point and the reject gate by the line speed: with a hypothetical 400 mm and 500 mm per second, the part reaches the gate in 800 ms. Exposure, image transfer, preprocessing, inference, the message to the controller and the actuator's movement all have to fit inside that time, with a safety margin left over.
If the time is not enough, moving the camera upstream can be easier than speeding up the model. But the longer the distance, the more likely the part is to slide, rotate or change order between camera and gate. The decision then needs part tracking with the conveyor encoder so it is applied to the right part. Weigh the two effects together when choosing the position, and add tracking accuracy to the placement test.
A field-of-view and occlusion checklist
At the planned camera position, at real speed and with real parts, check one by one that every surface to be inspected stays visible in every position. A photo of a clean display part does not answer this. The checklist should cover:
- Surface map: every surface to be inspected is listed, with the camera that sees it marked.
- Worst position: the largest drift on the conveyor, rotation and a part loaded the wrong way round have been photographed.
- Mechanical occlusion: no fixture, gripper, guard, label, cable or neighbouring part covers the region of interest.
- People and robots: no operator's hand or robot arm is in frame at the moment of capture.
- Ambient light: windows, ceiling lights or welding light do not reflect into the region of interest.
- Image edges: lens distortion and darkening at the edges do not prevent grading defects that fall there.
- Maintenance access: camera and light can be cleaned, refocused and replaced safely; a camera nobody can reach drifts without correction.
- Environment: protection against vibration, dust, oil mist and splashes has been considered.
- Reference image: the framing after installation has been saved for later comparison.
If a surface cannot be seen from one point, consider a second camera, a station that rotates the part, or a fixture change. A second camera is often cheaper and easier to explain than a model trying to guess what it cannot see.
How do you calibrate the camera, and when do you repeat it?
Calibrate with the actual lens, focus, resolution and mounting position, and repeat whenever the camera's physical state changes. OpenCV's camera calibration tutorial covers radial and tangential lens distortion and explains that calibration also gives the relation between pixels and real-world units such as millimetres. Chessboard, ChArUco or circle patterns can be used; although two snapshots suffice in theory, the tutorial recommends at least 10 good snapshots in different positions in practice because of noise. The re-projection error it returns estimates the precision of the parameters found and should be as close to zero as possible.
If the acceptance rule defines a distance in millimetres from an edge, verify the pixel-to-millimetre conversion with a known reference across the whole field of view, not only at the centre. Add the calibration pattern or a reference part of known size to the maintenance procedure. Repeat calibration after a camera replacement, a focus adjustment or a mechanical knock, and version the calibration file with the model configuration. A weekly comparison against the stored reference image shows a drifting camera long before the model's results do; retraining the model should not be the first response to a camera that has physically moved.
Hypothetical example: comparing three placement candidates
The values below are invented to illustrate the method. On a flanged housing, the inspection looks for 0.3 mm scratches on the top face and burrs on the side edge. For each candidate, 100 consecutive parts were captured, and the quality team marked whether the defect could be seen and graded in 20 boundary samples:
| Criterion | A: one camera, top view | B: one camera, angled | C: two cameras, top and side |
|---|---|---|---|
| Pixels on the smallest scratch | 6.7 | 6.7 at the centre, fewer at the far edge | 6.7 |
| Parts with the side edge hidden (per 100) | 14 | 3 | 0 |
| Scale change across the image | Low | High | Low |
| Boundary samples that could be graded | 17/20 | 18/20 | 20/20 |
| Maintenance access | Easy | Guard must be removed | Easy and moderate |
A is the cheapest option, but in 14 of 100 parts it cannot see the edge where burrs are searched for. B sees the edge, but the oblique view changes scale across the image and makes the millimetre-based scratch rule harder to apply. C solves both occlusion and scale at the cost of a second camera. The decision follows the acceptance rule: if burrs are not critical and the edge can be checked by sampling, A may be enough; if they are critical, C is the only defensible option.
Our visual quality inspection service page shows where testing whether the defect is visible to the camera, before any model is trained, sits within a pilot.
Common mistakes
- Mounting the camera wherever there is free space on the line instead of choosing the position from the defect geometry.
- Doing the pixel calculation only for the image centre and the ideal part position.
- Lengthening the exposure to brighten the image and missing the motion blur it causes.
- Testing placement with a clean display part and never photographing the worst position.
- Calibrating once and not repeating it after a camera change or focus adjustment.
- Noticing that the camera has moved from the model's worsening results instead of from a reference image.