3D Printable 3D Scanner Using Intel Realsense D435

9,766

75

57

Introduction: 3D Printable 3D Scanner Using Intel Realsense D435

For a school project a co-student (Wouter Drost wouterdrost01@gmail.com) and I (Sander Boelen s.boelen@hotmail.com) made a 3D scanner using an Intel Realsense D435 depth camera. Our goal was to make a scanner for hobbyists and educational purposes. With commercially available 3D scanners costing around €1000+ we wanted to stand out by making our scanner cheaper so it's more accessible to a broader group of people. Due to the D435 resolution our goal was not to make 3D scans to be able to perfectly replicate machine parts with tight tolerances. This scanner would be for making scans to derive parts from (like scanning a can of beer to make a beer holder) or to 3D print replicas of scanned items (for example for making miniature items for in a dollhouse). This would make 3D printing more accessible to more people since a lot of people are not able to make their own 3D models. With this 3D scanner, even kids are able to make their own STL files by tinkering whatever they want and then 3D scanning it.

Supplies

The total costs of this project will be around €250 (the main cost will be the camera) and consists out of the following parts:

- Intel Realsense D435 (with USB-C cable)

- Arduino Uno (with USB-B cable)

- MF-6402411 Stepper motor with ULN2003 Driver

- 7 male-female jumper cables

- Skateboard/Fidget spinner ball bearing (8mm (inner diameter) x 22mm (outer diameter) x 7mm (width))

- 20x20mm extrusion profile 30cm

- M4 bolts and nuts (screw heads prefered)

- Camera mount bolt

- 3D printed PLA parts (minimal 150*150 print bed required)

- Glue

Step 1: 3D Printing All Parts

All parts for the 3D scanner can be 3D printed in PLA on basic 3D printers without brims or supports. For all parts 3 wall layers, 0.2mm layers and at least 15% infill is recommended.

For the camera stand there are multiple variants available. Since my own 3D printer can't make the stand in 1 part its split in 2 parts (without support needed). When a printer with a print bed longer then 220mm is used, the stand can be printed in 1 part (support needed). All parts found in the parts folder are given names which clearly show what parts should be printed in which case.

Step 2: Arduino Wiring

The wiring to the Arduino should be connected as shown in the picture above using male-female jumper cables.

5V to +

GND to -

D8 to IN1

D9 to IN2

D10 to IN3

D11 to IN4

Step 3: Assembly

When all parts are printed and the Arduino is wired up it is time to start assembling the 3D scanner.

1. Start by pressing the small gear on the stepper motor.

2. Place the Arduino, Stepper driver and Stepper motor inside the frame. When the Arduino or the Stepper driver don't stay in place by themselves it is possible to glue them in or keep them in place using double-sided tape.

3. Use 2 M4 bolts to lock the Stepper motor in place.

4. Press the ball bearing inside the ball bearing holder.

5. Assemble the ball bearing holder on the frame using 4 M4 bolts. Pay attention to the orientation since the ball bearing isn't symmetric. The middle of the bearing should align with the middle of the frame. (It might also be handy to put the cables underneath the ball bearing holder to keep them in place)

6. Connect the USB-B cable to the Arduino.

7. Slide the extrusion profile into the frame and secure it using glue.

8. If the camera stand in 2 parts is chosen, connect the 2 parts using 2 M4 bolts and nuts.

9. Put 2 M4 nuts in the nut holder.

10. Slide the nut holder into the bottom groove of the extrusion profile with the nuts facing up.

11. Slide the extrusion profile into the camera stand.

12. Drive 2 bolts in the bottom of the camera stand into the nuts inside the nut holder. Be careful not to tighten the bolts to strong!

13. Secure the camera on the stand using the camera mount bolt.

14. Press the turning top inside of the bearing.

15. Connect the USB-C cable to the camera.

Step 4: Installing Software

1. Download the required software:

https://drive.google.com/file/d/13C6lw7JpJqJhClPOJ2-UYpganLNdpdcL/view?usp=sharing

2. Unpack the "3D scanner.rar"

3. The "Main program" folder should be placed on a location from where you want to run the scanner. Make sure to keep all the files in the same folder.

4. "Arduino 3D scanner.ino" script should be uploaded to the Arduino.

Step 5: Using the 3D Scanner

Execute the "3Dscanner.exe" file to start the program. From here on everything should be straight forward on how to use. Enjoy!

To change the code you can use the "3D scanner.py" file, which is the source file for the program.

First Time Author Contest

Participated in the
First Time Author Contest

Be the First to Share

    Recommendations

    • Science Fair Challenge

      Science Fair Challenge
    • Electronics Contest

      Electronics Contest
    • Stick It Challenge

      Stick It Challenge

    57 Comments

    0
    Syed Hasnain
    Syed Hasnain

    21 days ago

    3dscanner.exe file can't open. Instead of .py file is opened

    0
    CharlesL3
    CharlesL3

    Question 5 weeks ago

    Hi, Thanks for this project

    I have an Intel D455 and the image is not centered. How can I change the code and which parts ?

    Thanks



    Capture.PNG
    0
    SanderBoelen
    SanderBoelen

    Answer 5 weeks ago

    You can take the .py file and change it. I don't know the exact lines from my head and I can't look it up since I am on vacation. You should be able to find the lines somewhere in the other comments. Otherwise you'd have to wait a few more weeks for me to be able to look it up. Hope you get it to work!

    Ps. It might also be possible to change it in the camera settings btw, but I never looked into that, but it might be worth a try.

    0
    DannyV1
    DannyV1

    Question 11 months ago on Step 5

    Hi, thanks for going and sharing this with us. This is my first instructable, finally got a 3d printer last week. My top was going in the wrong direction so I made the change as suggested. However I'am going one step over 360 so I'm getting some cool LSD looking scenes. I was tinkering with the code but am unable to find how to make it go 1 less. Right now it does 360 in 49 steps, while I need 48 steps. Which line controls that?
    Thanks!

    0
    hjonsson1
    hjonsson1

    Answer 4 months ago

    Hi, did you manage to solve the "LSD"-effects? Decrease the overstepping with one step did not help me. I also went through the hassle of calibrating my D435i (the latest UWP-driver does not work with the calibration tool - must be removed first), but still no luck. I've positioned the camera at the end of the extrusion profile but the STL-files and point clouds are all funny. See attached pics. This was my first instructable and I got some nice printing done to set up "the hardware" but I'm close to giving up on this one as I don't have time-resources to go through the theory, programs and coding for understanding what has gone wrong. Plate is turning nicely step-wise full circle, images/point clouds are being produced but the outcome can at most be used for some modern art. Any suggestions/tip on what I have done wrong in settings, calibration or something that should be tuned? I think I've done everything according to plan.
    Thanks for inspiring project though!

    3DscannerFail.PNG3DscannerFail2.PNG3DscannerFail3.PNG
    0
    SanderBoelen
    SanderBoelen

    Reply 4 months ago

    You have come so far, would be a shame to give up now! it looks like you just need some better calibration, and everything will be alright. The problem is that apperently you can callibrate your camera coordinate system, which I didnt know at the time. I borrowed a camera from school so I dont know how that one was calibrated, and I dont have a camera now, so I cant fix it, you would have to calibrate the program for your camera configuration.

    do you know any python? I will help you out, no worries man :D

    As a small sidenote, your platform is supposed to rotate clockwise, does it do that?

    0
    hjonsson1
    hjonsson1

    Reply 4 months ago

    Hi SanderBoelen, yes it would at least bother my self esteem to give up now so thanks for the hints and quick response :D I got the turn table to rotate clockwise (which seems to have been the root cause) and now the result looks at least similar to the object. I guess I now have to look at the settings/calibration in the D435 in more detail to get better quality.
    Sorry for missing your earlier answer regarding the clockwise rotation in one of the threads below, the initial question didn't really hint to it. A friendly suggestion would be, if possible, to update your excellent project/instruction with some of the NOOBS common failure me and others have done and how to troubleshoot/verify already in the description - then you have to spend less time replying to the posts here ;-)

    Other question, one person in the comments asked about resolution of the scan and you mentioned sub-millimeter - is that granularity really possible with the D435? What in order of priority needs to be looked into to set up the scanner for higher resolution?
    Also on that topic, how do you measure/define the distances along the axis's - is it from the centre of the turn table along axis of interest to the front screen of the camera (projected position) or is it at some point further back like the mounting point or similar?

    0
    SanderBoelen
    SanderBoelen

    Answer 11 months ago

    I noticed the extra step as well when scanning, and to be honnest, I dont really know where it came from, but since it didnt give any problems to me, so I didnt look further into it. Maybe you can try scanning with fewer steps. What happens for example when you scan with only 4 steps. Does that make things better, or only worse? Can you show me what your pointcloud looks like?

    0
    woland2k
    woland2k

    Reply 8 months ago

    It does extra rotation due to this line (line #255)
    self.ard.rotate(int(self.dictionary["stepSize"]))
    Basically it starts rotation before it detects that the circle is done.
    So simply add this line before to prevent extra step:
    if angle < 360:

    so it will look like this:
    if angle < 360: self.ard.rotate(int(self.dictionary["stepSize"]))

    The extra step doesn't have any affect on the quality since image is not taken anyway.
    0
    DannyV1
    DannyV1

    Reply 11 months ago

    Hi. Where do I modify the number of steps? Does the camera have to be a specific number of mm's from scanning bed? I've included the stl and pics of the pointclouud and my screen. Thanks for the help!

    Pic of scan screen.pngpointcloud.png
    0
    AliE18
    AliE18

    5 months ago

    I would like to congratulate you on the awesome work. I hope you do not mind me asking a few questions about the code. I recently got a RealSense L515. I would like to replicate the project using the new camera. I am no expert in RealSense and Open3D but I got myself to understand almost everything. However, I still do not understand some variables and numbers in the code below.
    0.035, self.distance , 0.165, 112.5, self.o, self.a, self.t

    def getcameraLocation(self):
    self.x = np.sin(self.angle*self.dtr) * self.distance - np.cos(self.angle*self.dtr) * 0.035
    self.y = -np.cos(self.angle*self.dtr) * self.distance - np.sin(self.angle*self.dtr) * 0.035
    self.z = 0.165
    self.o = self.angle
    self.a = 112.5
    self.t = 0

    def rMatrix(self):
    self.o = self.o * self.dtr
    self.a = (-self.a) * self.dtr
    self.t = self.t * self.dtr
    self.R = [[np.cos(self.o)*np.cos(self.t)-np.cos(self.a)*np.sin(self.o)*np.sin(self.t),-np.cos(self.o)*np.sin(self.t)-np.cos(self.a)*np.cos(self.t)*np.sin(self.o),np.sin(self.o)*np.sin(self.a)],
    [np.cos(self.t)*np.sin(self.o)+np.cos(self.o)*np.cos(self.a)*np.sin(self.t),np.cos(self.o)*np.cos(self.a)*np.cos(self.t)-np.sin(self.o)*np.sin(self.t),-np.cos(self.o)*np.sin(self.a)],
    [np.sin(self.a)*np.sin(self.t),np.cos(self.t)*np.sin(self.a),np.cos(self.a)]]

    I also very much appreciate any information on the coordinate system you used and the sequence of rotation (How did you deduce the rotation matrix R).

    0
    SanderBoelen
    SanderBoelen

    Reply 5 months ago

    First off lets start with the numbers you are asking about, the 0,035 is the sideways offset in the camera (relative to the center of the camera), as it turned out later, this is dependent on camera settings and thus not the same for each camera,

    self.distance was initialy used as a variable where you could slide the camera over the extrusion rod to change the location of the camera, self.distance would then be the offset on the axis of the extrusion rod.

    0,165 is the height of the camera relative to the platform

    112,5 is the angle of the camera looking down relative to the z axis.

    self.o, self.a and self.t are the translated angles in the used cordinate system.

    We used an euler coordinate system. https://en.wikipedia.org/wiki/Euler_angles here you first rotate around the z axis with angle o, then around the new x axis (x'), and then around the new y axis (y''). (wikipedia will explain it more clearly) the bottom of the wikipedia page has convertion matrixes which we used to get the correct matrix in the format open3D expects it. We used this coordinate system because we previously used it in a robotics project, and thus where already familiar with it. Once you get used to OAT systems, it gets very intuative, thats why robotics use it a lot. Basically you dont only discripe the position of the camera, but also the orientation

    0
    evgeny.levin96
    evgeny.levin96

    Question 1 year ago on Step 5

    Hello, tell me why the script does not open in arduino ide? Error: Unable to create sketch. And the program when you open the image from the camera is not, black background. Thank you!


    0
    SanderBoelen
    SanderBoelen

    Answer 1 year ago

    I answered this question on the private message you send me, but for any other users experiencing the same problem, you would need to open the arduino IDE and open the sketch from there. The picture only changes as soon as the first frame is taken for a scan.

    0
    TriSix
    TriSix

    Reply 9 months ago

    I also can't open the .ino file in the Arduino IDE. I think the file you uploaded is corrupted.

    0
    Chr1stoph
    Chr1stoph

    10 months ago

    Thanks for this nicely done project! I used your python implementation as reference to get started with the Realsense D435i. Could you tell a bit about the software processing part? Did you have any reference for the calculations?

    I've done some image processing / stereo reconstruction years ago but have not done anything since then. Currently I'm struggling to get started with the D435i ... want to get into 3D Scanning for some fun projects. I thought the Realsense SDK demo Applications can do some basic 3D scanning, apparently that was only true for the old SDK. So far your project is the only one that made me get some sort of reasonable result.

    0
    olivier.saraja
    olivier.saraja

    Question 11 months ago on Introduction

    Hello, congratulations for this nice looking device.
    What would be the expected resolution with it? The resulting scan of the bear lacks details (especially fur) but it is unclear if it is due to the RealSence capacity or because of the scan parameters you used for showcasing your device.
    Many thanks for your answer.
    Cheers,
    Olivier

    0
    SanderBoelen
    SanderBoelen

    Answer 11 months ago

    The dimensions are spot on the scans, if tuned correctly you can get this to sub millimeter level. In the settings menu there is an option to smooth out any spikes in the scan due too grain in the image. The downside of this is that you remove surface details as well, I guess you can get quite some details if you tune the settings a bit more, but it would be difficult to get super fine details like the fur on the bear.

    0
    olivier.saraja
    olivier.saraja

    Reply 11 months ago

    Many thanks for your answer!
    Regards,
    Olivier

    0
    coatsoblogger
    coatsoblogger

    Question 1 year ago

    Hi, when I click start scan it hangs and then goes straight to start scan some times just closes. Is this a problem with my code on the uno?