Introduction: DIY: How to Make a Low Cost 3D Scanner

Picture of DIY: How to Make a Low Cost 3D Scanner

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.

Step 1: Building the Turn Table

Picture of Building the Turn Table

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 @ 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.

Step 2: Onerot() Function

Picture of Onerot() Function

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 :

Step 3: Finishing the Setup

Picture of Finishing the Setup

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.

Step 4: Calibrate the Camera

Picture of Calibrate the Camera

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.

Step 5: First Equation

Picture of First Equation

Lets see how if this is true

Step 6: Converting to Camera Coordinates

Picture of Converting to Camera Coordinates

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]

Step 7: Using the Basic Pinhole Equation

Picture of Using the Basic Pinhole Equation

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

Step 8: How the Scanner Model Is Represented

Picture of How the Scanner Model Is Represented

As we can see lots of triangles to analyize

Step 9: Using the Law of Sin

Picture of Using the Law of Sin

Step 10: Equations

Picture of Equations

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

not 90-(-15.508) .

Thank you for catching that Xiaomaxiao!

Step 11: Main Algorithm

Picture of Main Algorithm

Step 12:

Picture of

Step 13:

Picture of

Step 14: NewFilter Function

Picture of NewFilter Function

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.

Step 15: Variables to Change

Picture of Variables to Change

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

Calibration code :

Step 16: OutPut of the Last Script

Picture of OutPut of the Last Script

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

Step 17: Adjust the Y Axis Values

Picture of Adjust the Y Axis Values

Step 18: Adjust the Y Axis Values

Picture of Adjust the Y Axis Values

Step 19: Transforming the Points

Picture of Transforming the Points

Step 20: Determine Your Turntable Platform Center

Picture of Determine Your Turntable Platform Center

Step 21: Determine How Many Loops for 360 Degrees

Picture of Determine How Many Loops for 360 Degrees

Step 22: Main Laser Scanner Code

Picture of Main Laser Scanner Code

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

Step 23: Scan Your First Object

Picture of Scan Your First Object

At this point you should be scanning models

Step 24: Creating Mesh From Point Cloud Step 1

Picture of Creating Mesh From Point Cloud Step 1

Step 25: Creating Mesh From Point Cloud Step 2

Picture of Creating Mesh From Point Cloud Step 2

Step 26: Creating Mesh From Point Cloud Step 3

Picture of Creating Mesh From Point Cloud Step 3

Step 27: Creating Mesh From Point Cloud Step 4

Picture of Creating Mesh From Point Cloud Step 4

Step 28: Creating Mesh From Point Cloud Step 5

Picture of Creating Mesh From Point Cloud Step 5

Step 29: Creating Mesh From Point Cloud Step 6

Picture of Creating Mesh From Point Cloud Step 6

Step 30: Congratulations You Have Successfully Created Your Own 3D Scanner!

Picture of Congratulations You Have Successfully Created Your Own 3D Scanner!


PARULAMBASTHA (author)2017-10-14

Hey John,hope you are well.Your project is very interesting,i am doing a similar project for my final year.Can you please send me the documentation of your project for my reference.Thanks


PavleR (author)2017-09-01

Hi I am doing project with 3D Scanner as a thesis, have you finished writing your documentation, I'd really like to read it once before and to include your reference. Thanks, email

byron.cuscoquinde (author)2017-05-28

Hello, how are you? I am doing a similar project in the university and I would serve yours as a reference, if you are kind enough to send me the documents to my email Thank you

This is the documentation so far, but I will be producing a written document sooner than later.

thanh hav (author)2017-02-03

I am doing a project in my university. It is the integration between 3D printers and 3D scanners. can you send me the specific documents on your 3D scanner. it will be a source of useful references for me. I would be very grateful to you and will share all process projects after completion. my email is . thanks for reading.

johnl375 (author)thanh hav2017-02-15

Send you an email

MariusD34 (author)johnl3752017-05-19

Can you also send me please those files? I'm trying to do a 3d scanner for a school project.


jakhongirm (author)2017-05-01

Hello John.

Great job! really inspired me.

I am doing a graduation project. İt is 3D foot laser scanner.And i need your help. Can you send me the specific documents on your 3D scanner. I would be very grateful. Thanks!


anwaralgacemy (author)2017-03-05

Hello John
Really it great job that you did , thank you sharing really it helps me a lot ...
I have some problems ::
1. How can I recover the color of the object that am scanning using meshlab ...
2. " is it possible to controller meshlab server from matlab,,
I want to build GUI in matlab that can able to open and run meshlab from matlab"
Please any help or guidance or any suggestion will be really approtiated
Thank you

johnl375 (author)anwaralgacemy2017-03-19

that's a lot harder sadly lol

parthindia47 (author)2017-03-14

Hi John, I have a question that how to extract Z coordinate if we using only single camera and no laser.

johnl375 (author)parthindia472017-03-19

Not easy.. it is doable but it requires having exact knowledge of the scene in-front of the camera, with multiple angles taken of object, and using point recognition to detect the similar points, and translate that into a rotation while keeping track, and measuring the changes in movement and surface orientation, and blah blah blah 1 camera is very difficult, because you are missing variable in the trigonometry that can only be determined with extra know data within the scene and how it changes.... I've seen some clever students use shadows to determine depth but that's a mystery to me as of this moment.

KamalH15 (author)2017-03-11

Hi John, this is an awesome project and I am sure people can learn a lot even from just following the tutorial. I am working on a project in college based on Arduino and I figured making a 3D scanner is a great idea. Can you email me more details about this project? Thanks a lot!

hacker0722 (author)2017-02-25

Hello John:) what's the difference between MATLAB coordinate and camera calibration? 495 ,5 is come from?
Does we need to crop the image to low down the resolution and ROI to speed up the process?

johnl375 (author)hacker07222017-02-28

Matlab saves matrix in such a way where the first information is in the top left of the matrix where the camera bases coordinates from the center as zero

hacker0722 (author)2017-02-09

Hi John, I am having some project in university about building microscope and optical instrument. Now that we have further goal to make a whole system using 3D scanner Structured light, Laser depth scanning. Can you send me more detail about your files? Wish I can more contact with you:") thanks.

Call me Hacker, thanks.

johnl375 (author)hacker07222017-02-15

I sent you an email

hacker0722 (author)johnl3752017-02-19

thanks for your reply

anwaralgacemy (author)2017-02-18

Dear johnl375

really grateful job it will helpful for all,

I have some question regarding using MeshLab for enhancing the result... how you fill up the hols at the top side and bottom of the object that undergoes the scanning process? what algorithm you use to fill the holes?

thank you

johnl375 (author)2017-01-18

Who thinks I should redo this with python? I cannot get OpenCV installed for me is why I haven't converted yet!

xiaomaxiao (author)johnl3752017-01-20

at step 10 : Ao=90 - atan(xo' / F) = 90 - atan( -225/919) = 90 - (-13.75)

not 90-(-15.508) .

or f !=F?

johnl375 (author)xiaomaxiao2017-01-20

Hey good eye, I'll have to fix that!

xiaomaxiao (author)johnl3752017-01-20 fact , the farther the ditance ,the greater the error .

+/-3mm is at whart distance?

whether tested a greater distance?

2. at bebgin , b (baseline ) and Z ( Physical distance) need to measure.

so , it ask the very accurate measurement.

if can use least sqares to reduce the error

3. after Calibrate the camera , we can get F , so we use

F/(x'+offset) = Z/b

measure of a set of d ,then we can fit b,because we can get x' from image.

above is my opinion, do you think is reasonable?

johnl375 (author)xiaomaxiao2017-01-21

I'm not exactly sure of the question. When I was building this originally I legit started with zero information on any of this. So most of these slides go over theoretically how these calculations can be calculated and measured for insight on how to improve or start to build. If you know the angle of the laser however and the angle of the camera you do not need to know the distance the back wall is.

The accuracy is dependent on the lasers amount of obstruction on the object.. if the object has very small features the laser may not be offset enough to detect a change in depth. Depending on what you are scanning you should find a optimal distance from the camera and laser or change the location of the set-up and recalibrate.

My algorithm is very versatile and works almost perfectly if you know the angle of laser and camera and the distance from the laser and camera. With the 3 known variables of a triangle I can figure out everything about that triangle.. however a lot of extra work was left out due to slowing down of the entire process with more calculations.

xiaomaxiao (author)johnl3752017-01-21

thank you for you replay ,

at step 10 , i don't kown the angle the laser , so i need to meause b and Z0 ? but how to make sure of the accuracy of the measurement .

Measured with a ruler?

in addition ,i found a paper maybe usefull to imporve the modle.

K. Konolige, J. Augenbraun, N. Donaldson, C. Fiebig, and P. Shah. A low-cost laser distance sensor. In Int. Conference on Robotics and Automation (ICRA), 2008.

johnl375 (author)xiaomaxiao2017-01-22

Woah, great source that uses the same mathematical equations, nice!

I used a ruler to measure my back wall at first or you can use multiple distances and calculate the angle with an average.

xiaomaxiao (author)xiaomaxiao2017-01-20

measure a set of Z(distance)

paulie_g (author)2016-08-15

Do you have an estimate of resolution and accuracy?

johnl375 (author)paulie_g2016-09-02

I would have to do some more testing but the model I created was roughly within

+/- 3mm of the actual size. The resolution is dependent on the camera resolution which can be easily adjusted in the code... I used 920x760 resolution to increase speed of the scanning.

DIY Hacks and How Tos (author)2016-07-17

Cool scanner.This would be really useful for a lot of 3D printing applciations.

Thank you very much! Hopefully the information is helpful.

JaredD23 (author)johnl3752016-08-12

Very great...thanks for putting forth the effort to share your hard work and thinking....working together creates a world in which we all can do much more together than individually!

zshwany (author)2016-07-30

Great Project Thank you for sharing your Experience...

About This Instructable




More by johnl375:DIY: How to make a Low Cost 3D Scanner
Add instructable to: