DIY: How to Make a Low Cost 3D Scanner

by johnl375 in Workshop > 3D Printing

36157 Views, 94 Favorites, 0 Comments

DIY: How to Make a Low Cost 3D Scanner

Title_page.JPG
meshlabrender.png

For this tutorial I am assuming you have both math and coding knowledge!

Also for this tutorial you will need Mat Lab computer vision toolbox, an Arduino, a laser line and a webcam.

UPDATE:

Due to popular demand I bring you the official publication: https://www.researchgate.net/publication/321668948...

HUGE thanks to my great friend Bryer C. Sousa for making this possible. I hope this helps everyone who is interested in computer vision projects!

Building the Turn Table

Turntable.JPG

The first difficulty I had making this 3D laser scanner was finding a rotating platform I could control with MatLab. Instead of spending lots of money or time I went to eBay and bought 5v Stepper Motor 28byj-48 With Drive Test Module Board Uln2003 @ http://www.ebay.com/itm/like/371474310734?lpid=82&chn=ps&ul_noapp=true For almost no money at all. I included the 3D models of the turn table I created using the stepper motor and marbles i bought at the dollar store. Just hot glue the platform to the shaft of the stepper motor and place the stepper motor in the slot within the holder. The platform should be level with marbles but be aware the cheaper the marbles the more inconsistent the diameters which may make things not level.

Onerot() Function

TurnTableCode.JPG

The function onerot(Arduino, PauseTime, #of loops) does a basic full step sequence. If you are using the platform and stepper motor within this tutorial use a pause time of 0.005 for smooth rotation.

Code for the stepper motor found at : http://pastebin.com/7KVBUrvK

Downloads

Finishing the Setup

Picture of scanner.JPG

Once you have a method of getting an accurate rotation that can be controlled within Mat Lab set up a camera at any distance and height away from the turn table and a laser line to either the left or right of the camera at a similar distance away from the turn table. The angle of the laser should be placed optimally to cover as much of the turntable as possible but nothing has to be exact we will handle model scale difference within the code.

Calibrate the Camera

CalibrationProcess.JPG

The most important part to make this work accurately is to calibrate the camera properly. Using the MatLab computer vision toolbox I was able to obtain a accurate focal length and optical center of my camera within 0.14px accuracy. Keep in mind changing the the resolution of the camera will change the values of the calibration process.

The main values we are looking for are focal length measured in pixel units and the pixel coordinates of the optical center of the image plane.

First Equation

pinholeForm.png

Lets see how if this is true

Converting to Camera Coordinates

opticalCenter.JPG

In MatLab an image is represented as a matrix starting from 1,1 to max resolution. However we need to represent points in terms of camera coordinates with the optical center points at [0,0]

Using the Basic Pinhole Equation

mathOfPinholeequation.JPG

As we can see it works well and can be very useful if we do not know the initial value of the laser angle.

How the Scanner Model Is Represented

geometric camera model.JPG

As we can see lots of triangles to analyize

Using the Law of Sin

example1.JPG

Equations

example2.JPG

xiaomaxiao:
Ao=90 - atan(xo' / F) = 90 - atan( -225/919) = 90 - (-13.75) = 103.757

not 90-(-15.508) .

Thank you for catching that Xiaomaxiao!

Main Algorithm

depth algorithim.JPG

example3.JPG

example4.JPG

NewFilter Function

LaserlineFilter.JPG

Probably the hardest part of this scanner and the one thing i hope continues to work but this filter will do the trick to get a nice single laser line in most conditions regardless of light. The less ambient light the better.

Downloads

Variables to Change

whattochangeVAR.JPG

Modify these variables in the top of the calibration script to get the script to work accurately for you

Calibration code : http://pastebin.com/CCD6bdt7

Downloads

OutPut of the Last Script

process steps.JPG

The last script generates the 2D points cloud of the scene in the steps in the image.

Adjust the Y Axis Values

yadjusting.JPG

Adjust the Y Axis Values

yadjustingCONT.JPG

Transforming the Points

translationMatrix.JPG

Determine Your Turntable Platform Center

FindingTranslation.JPG

Determine How Many Loops for 360 Degrees

FindThetaPlat.JPG

Main Laser Scanner Code

mainscannerVARMOD.JPG

Modify the top line of the code to fit your model and adjustments.

Downloads

Scan Your First Object

pointcloudowlimg.png

At this point you should be scanning models

Creating Mesh From Point Cloud Step 1

step1.png

Creating Mesh From Point Cloud Step 2

step2.png

Creating Mesh From Point Cloud Step 3

step3.png

Creating Mesh From Point Cloud Step 4

step4.png

Creating Mesh From Point Cloud Step 5

step5.png

Creating Mesh From Point Cloud Step 6

step6.png

Congratulations You Have Successfully Created Your Own 3D Scanner!

meshlabrender.png