Building My Own Tool Scanner — Part 9: More Pixels Must Be Better... Right?

After the M12 lens experiment, I went back to the original C920.

It worked.

It was calibrated.

The physical results were good.

And after refitting the stock lens properly, the numerical calibration results were better than they'd ever been.

I could have stopped there.

Instead, I found an old Samsung Galaxy A3 2017.

The rear camera could give me approximately 8 megapixels, compared with the C920's roughly 2 MP.

Which raised the obvious question:

Would more pixels give me a more accurate scanner?

Turning a phone into a scanner camera

The A3 wasn't intended to be a machine-vision camera either.

But it did give me considerably more resolution to play with.

The images were around:

4144 × 3106 pixels

with the camera output itself around:

4128 × 3096.

I also had access to useful camera controls, including exposure, ISO and manual focus.

So I put together a small Android/ADB test setup that allowed me to trigger captures and experiment with the camera remotely.

The rectified scanner resolution was increased from the C920's:

4 pixels/mm

to:

10 pixels/mm.

On paper, this looked extremely promising.

And the numbers agreed

The first calibration results from the A3 were very good.

Reference bars came back extremely close to their known dimensions.

One test produced:

50 mm → 49.970 mm

100 mm → 99.965 mm

150 mm → 149.948 mm

200 mm → 199.918 mm

Another calibration gave:

50 mm → 50.007 mm

100 mm → 99.969 mm

150 mm → 149.936 mm

Those are tiny errors.

Then came the hold-out testing.

Trying different calibration models

With the higher-resolution image, I also started experimenting with different ways of modelling the calibration.

The cubic polynomial model I'd already been using performed well.

Across several runs, it produced roughly:

0.066 mm mean error

with P95 values around:

0.141–0.152 mm.

Then I tried a B-spline model.

That improved the mean to around:

0.060 mm

with P95 around:

0.120–0.130 mm.

Then a fifth-order polynomial.

That produced a mean around:

0.054 mm

with P95 around:

0.120–0.124 mm.

On the calibration grid, the old phone was looking bloody impressive.

In some metrics, better than the C920.

So...

Samsung wins?

Not quite.

The annoying bit: real objects

When I moved away from calibration points and started measuring actual physical objects, the picture became much less clear.

Earlier physical square and cube testing produced approximately:

A3 mean absolute error: 0.103 mm

compared with:

C920: 0.135 mm

Again, the A3 looked better.

Worst observed error was also lower:

A3: 0.405 mm

C920: 0.570 mm

Still looking good.

But individual objects and different areas of the workspace weren't always behaving as neatly as the calibration statistics suggested.

Some tests favoured the A3.

Some were effectively indistinguishable.

Some results simply didn't line up with what I'd expected from the dramatically better-looking calibration numbers.

And that was interesting.

A calibration result isn't the product

I'd already learnt this lesson once, but the A3 hammered it home.

A fantastic hold-out result tells me something important about the calibration model.

It does not automatically tell me that the complete scanner is proportionally better.

The actual system includes:

Camera optics.

Focus.

Image noise.

Segmentation.

Object height.

Parallax.

Vectorisation.

Physical reference measurements.

And eventually a 3D printer.

Improving one metric doesn't necessarily improve the entire chain.

Then there was height

Flat calibration targets are convenient.

Unfortunately, tools aren't flat.

A ratchet might be more than 10 mm tall.

A socket might be considerably taller.

The calibration grid exists at Z = 0, on the scanning surface.

But the visible edge of a real tool might exist several millimetres above that plane.

With a camera mounted a finite distance above the workspace, that creates another source of dimensional error:

Parallax.

And suddenly some of those strange physical-object results started becoming considerably more interesting.

The question was no longer simply:

Which camera has the best calibration numbers?

It became:

How much of the remaining error isn't calibration error at all?

More pixels weren't the answer

The Samsung A3 experiment was absolutely worthwhile.

It proved that the calibration system could work extremely well with a much higher-resolution camera.

It gave some excellent numerical results.

It let me experiment with B-splines and higher-order polynomial models.

And in several tests, it genuinely beat the C920.

But it didn't produce the enormous real-world improvement that the headline numbers initially suggested it might.

Meanwhile, the C920 was cheap, permanently mountable, easy to control from Linux, already integrated into the scanner and — most importantly —

already accurate enough.

So the C920 remained the baseline.

For now.

Because the slightly strange behaviour with real 3D objects had pointed towards something much more interesting than another camera upgrade.

The scanner knew X.

It knew Y.

But there was one coordinate I'd largely been ignoring.

Z.

And apparently Z had opinions. 😂


Next: Part 10 — The Scanner Was Right. The Surface Wasn't.

The calibration target lives at Z = 0.

Real tools don't.

So next came raised calibration targets, objects up to around 40 mm tall, moving the same object around the workspace and working out how much apparent size changes simply because the edge I'm measuring is closer to the camera.

In other words:

Parallax correction.