
3D Scanning – Digitizing on the Cheap (2 of 2) - cinquemb
https://will-forfang.squarespace.com/3d-scanning-digitizing-on-the-cheap-2/
======
kefka
Good job.

There are a few things I've found that makes a better scan. First, lens
calibration from OpenCV is great at fixing lens deviations. Secondly, since
you are already using OpenCV, you can work in the colorspace that your
laser/camera works best in. Thirdly, the angle theta is really nasty to
calculate accurately. I've found you do not need to measure the angles. I'll
explain.

If you assume that your camera is floating in some angle horizontal and some
angle vertical, you need 3 pieces to figure out where your camera is. First,
you need to locate the center of your platter. Secondly, you need the angle of
the laser to vertical as viewed from the camera. These 2 constrain your data
to a ray that originates from the center of the platter (origin) outward.
Third, you use the checkerboard from calibration to determine your distance
from the center, thus constraining the camera in 3space. Here's my equations
I've derived:

    
    
        x = (current_col + 1 - turntable_center_horizontal)/( sin(cam_angle) ) * sin(angle_per_step * current_iteration) ;
        y = -1*((current_col + 1 - turntable_center_horizontal)/( sin(cam_angle) ) * cos(angle_per_step * current_iteration)) ;
        z = ( (turntable_center_vertical - current_row) - ((current_col - turntable_center_horizontal)/(tan(-cam_angle))));
    

cam_angle is the angle the line makes. I measured from 270degrees in positive
direction. Measure this offset, and the angle is cam_angle. The rest of the
variables should be clear.

One place I'd look at changing up is upgrading the laser. You can buy a cheap
burning laser for ~$10 on aliexpress. Just add that and a little motor+mirror
assembly, and you can generate a clean laser line. I'd recommend green lasers,
as green seems to be the most sensitive with the various webcams I've worked
with. They also generate lots of IR as well, so the line is really bright.

