Sunday, 10 July 2016

3D Scanner


Background
So, the technique I covered in a previous post for copying 3D objects from photographs works well if the object you're trying to copy is fairly flat, but it's not really suitable for more nuanced and complex objects.

For the past few years I've been working on a game, on-and-off, and while I'm fine with the programming side of most game engines, 3D modelling is something of a downfall for me.

I am also working with non-technical people to design the game, so rather than them design characters and I then re-create them as best I can in Blender, what if I could them use real-world everyday objects to model the characters, and then scan them into a 3D mesh?


Hardware
The scanner is going to comprise of three main parts:
  • The platform/turntable. Made from old bike parts, a bearing plate taken from one of those rotating laptop tables, and a windscreen wiper motor.
  • The line-laser. A laser pointer and a wine glass. I will 3D print a mount for more accurate positioning.
  • A camera. A simple webcam will suffice. Higher resolution the better, though to begin with I'll be working with whatever I have to hand.

Software
I am creating some image processing software for a different project (my dissertation), which has some common processes to what will be required for this, so once that's done I will be able to re-use some of the generic code for this project.

I'll be programming in Java, the webcam will be accessed using the Sarxos Webcam-Capture library, and the 3D aspects will be implemented using the JMonkeyEngine games library.

A photo posted by Anthony (@darkmidnight_diy) on

Platform/Turntable

One of the key measurements for being able to create a 3D mesh from a system like this is knowing the amount of rotation. A common way to knowing this would be to use a stepper motor - each step being x degrees of rotation.














A photo posted by Anthony (@darkmidnight_diy) on

As I'm using a 'dumb' windscreen wiper motor, I can't use this method. What I plan to do is use a optical rotary encoder (like the kind found in mouse scroll wheels), so that I can mark each complete rotation of the turntable.

From there, I can look at the number of webcam frames obtained, and divide 360 by the number of frames, to get the degrees per frame (this is assuming that the motor speed stays constant, as does the webcam frame rate. The motor is not variable speed, and the webcam frame rate can be controlled in software, so I don't forsee this being an issue)







Line-laser
The laser itself is a standard red laser pointer, nothing special. However for this task, I need a line, not a dot. Shining the laser through a glass stem refracts the light in such a way as to produce a line.

However the positioning is quite critical - the laser has to line up with the centre point of the turntable, and be angled through the glass so that the bottom of the line is on the turntable.