Computer vision mishaps

I was planning to add a Raspberry Pi camera on my soldering machine. I used a camera board from China which has the M12 lens mount. There is a variety of M12 lenses and one can play with the focus.

This is the camera board mounted on the soldering head

I finally got everything set up. I discovered this very nice camera streaming web interface package here is a picture of the web interface

The UI is simplistic, but allows control of the camera settings and while streaming is consumes only 3-5% CPU. Well done to the Raspberry Pi foundation and the RPi Cam Web Interface team.

Here is an image I captured with the camera

The focus looks good and the image resolution is very nice. However the vertical blue edge of the plastic mount is supposed to be straight. Not so much on the image. The 3.6mm M12 lens I used on the camera adds quite a bit of distortion around the edged. My other lenses are more on the telephoto side: 6mm, 8mm, 12mm and 16mm. I tired the 6mm lens and the distortion was better, but the field of view was too narrow and wan not capturing the soldering head. I ordered some more lenses which claim “low distortion”. We’ll see it they produce better result.

My initial goal was to capture a series of images and then “stitch” them together with OpenCV. Initial experiments failed miserably. First the lens distortion was confusing the stitching algorithm. I know that OpenCV has camera calibration option which can correct lens distortion, but I’ll try better lens first.

The other issue with the stitching was inconsistent lighting. I tried using my LED photo light, which helped initially. Still the lighting on some spots was low and some spots were too bright and getting lots of reflection from the PCB board surface.

I constructed this new camera head, which allowed me to mount a small ring of LEDs close to the camera.

I seemed like a good idea at the time, however it makes terrible reflections onto the PCB. So back to square one. I’ll make some combination of external photo light as well as some white LED strips. The goals is to have uniform light with minimal reflection and not to obstruct the movement of the machine.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.