Building My Own Tool Scanner — Part 12: The Maths Was Mapping a Bent Surface
The calibration had become good at describing the target it could see.
That didn't guarantee the target was lying on the stable, flat plane I wanted to measure.
The Perspex had a significant bow. On 3 October, it was replaced with glass and the Samsung A3 returned for a fresh calibration of that working plane.
Give zero somewhere sensible to live
There is something particularly annoying about spending time refining a mathematical model only to discover that part of what it's faithfully modelling is a physical problem in the setup. The software can be doing exactly what you asked and still be leading you in the wrong direction. If the reference surface isn't flat, a sophisticated mapping can follow that shape beautifully. Unfortunately, I'm trying to measure tools on a plane, not build a detailed survey of a slightly bent sheet.
A calibration target establishes a relationship between camera pixels and known physical positions.
If the sheet rises or falls across the bed, a sufficiently flexible mapping can absorb some of that shape. The residuals can look attractive while the physical reference remains less useful than the statistics suggest.
Removing the sheet and putting another object down doesn't guarantee the new object reproduces the same warped surface.
Glass addressed a practical mechanical variable. It didn't prove that every earlier corner error had been caused exclusively by Perspex. It provided a better reference plane on which to repeat the work.
Changing the plane also meant the old calibration wasn't the calibration of the machine now in front of me. The full chain needed running again.
The A3 configuration came together
That was why the move to glass mattered. It wasn't a cosmetic change to make the scanner look more professional. It gave the calibration target a more dependable physical reference. I still needed to capture it properly, detect the dots and validate the mapping, but at least I wasn't asking the maths to compensate for a surface that could move or bow. Sometimes the best software improvement is fixing the thing the software is looking at.
The saved capture used 4128 × 3096 pixels, fixed 0.3 dioptre focus and 1.0× zoom. Orientation and preview behaviour were addressed, and fixed daylight/night white-balance presets were retained.
The complete target could now be checked as observed geometry rather than filled in to satisfy an expected count.
| Accepted glass-target observation | Result |
|---|---|
| Distinct dots and unique grid sites | 14,400 |
| Expected neighbour links recovered | 28,556 of 28,556 |
| Conflicting links | Zero |
| Interpolated dots | Zero |
| Excluded print sites | Zero |
This was different from the early masked 5 mm target and the restored C920 session with its explicit exclusions. The observation contract had changed, and the documentation needed to say so.
The models weren't interchangeable
The model comparison was worth keeping honest too. A cubic fit that behaves badly because of large raw coordinate values isn't proof that cubic polynomials are fundamentally useless. Normalising the inputs changed the numerical behaviour substantially. The B-spline still had to earn its place through independent tests and physical measurements. I wanted to choose the method that worked for this scanner, not declare a favourite algorithm and massage the evidence until it agreed.
There were also two distinct numerical stories.
The raw-coordinate cubic route had suffered numerical instability at the larger image coordinates. Normalising those coordinates improved the cubic fit. Its corrected V6 P95 residual was 0.2909 mm, compared with the legacy unnormalised result of 3.5311 mm.
That was a real correction to that model's implementation.
The B-spline was another mapping approach, with different validation and physical-object evidence. Its figures shouldn't be mixed with the cubic residuals to produce one flattering accuracy claim.
| Glass A3 evidence | Mean | P95 | Maximum |
|---|---|---|---|
| Normalised V6 cubic all-point residual | 0.1492 mm | 0.2909 mm | 1.3354 mm |
| B-spline holdout | About 0.0253 mm | About 0.0523 mm | About 0.1089 mm |
The first row is a fit to the calibration observations. The second concerns withheld interpolation evidence for its specified test. Neither row is the same as measuring a physical tool.
Remove the dots and measure something
Sixteen physical targets provided the separate object check. Their independently reported side sizes were around 25.66–25.70 mm; the validator used 25.68 mm as its nominal comparison.
The best reported result was a mean measured side of 25.6937 mm, a mean absolute error of 0.0697 mm and a maximum error of 0.1956 mm.
That gave the new setup a useful physical-object check as well as good dot results.
The interface briefly went backwards
And I was increasingly interested in the difference between a lovely dot-grid result and an actual object measurement. A model can predict withheld dots to a tiny fraction of a millimetre. That tells me something valuable about how it maps the bed. It doesn't tell me whether the mask has found the chrome edge of a ratchet or whether a cube standing above the bed will appear too large. So the dots had to come out of the way and the physical targets had to go back in.
The A3 migration also reorganised the scanner into calibration inputs, pipeline scripts, result stages and an APK location.
During that cleanup, the interface became calibration-focused and the old production scanning route was disabled. A working calibration system wasn't yet a replacement production scanner.
Scanning was then restored using direct B-spline rectification from the complete V2 grid, with segmentation and tracing performed on the 10 pixels/mm rectified image.
The normalised V6 artifacts remained useful calibration evidence. They weren't the coefficients driving this B-spline production path.
A useful new baseline
The result was a much more credible baseline for the A3. Not because every number was perfect, but because I could explain what each test meant, where it applied and what it didn't prove. That is a lot more useful than one headline accuracy figure. I could now spend time on the next real source of error instead of constantly wondering whether the reference surface itself was moving the goalposts.
This was the point where the A3, glass, complete observed target and B-spline route became the accepted direction.
The C920 comparison remained valuable history, but it wasn't the camera performing the subsequent accepted glass and ratchet work.
I now had a much better-defined reference plane.
Unfortunately, the tools continued to insist on existing above it.
Next: Part 13 — Z Has Entered the Chat
