Tag Archives: 3D scanner

3D Scanner – Software Overhaul

So I’ve been having a tinker with the 3D scanner again and I’ve got it working with my Cannon SX200 + a custom CHDK remote trigger script. This means the actual scan time is now about 3/4 of an hour and I only get about 2 scans per camera charge, but! (and this is a big but) I get glorious 12 mega-pixel resolution and awesome image quality.

This has meant I’ve had to have a rather massive overhaul of the model generating software to reduce memory usage, add more controls to the GUI, remove the OpenCV dependency, and generally make it more usable. It’s not finished yet, but here’s is a look at an early version of the new GUI:

Still need to beautify the layout a bit and write a considerable chunk of code. But it hopefully should be worth it.

As always the code is open source and available from the repository, but be warned the current committed version is massively broken, so if you want a working version checkout revision 2 (yeah, I know it’s probably terrible practice to break the main repo’s code, but what the hell, it’s not like anyone besides me is actually using this stuff).

Advertisements

3D Scanner – Some Results

Here are a few scan results:

A Selection of 3D Models Displayed in Meshlab

From top left clockwise: Box of Swan filters, bottom half of a glue bottle, roll of solder , nodding monkey, candle in holder on coaster, bottom half of frijj bottle.

Slight disclaimer: The models are shown from there “best” angles. Some are deformed, due to not being able to set the centre of rotation yet in the scanning software, some have slightly dark meshes in places, due to the LED lights not being good enough, and all of them have had a laplacian filter applied to smooth out the meshes a bit. Also most of the objects were chosen because they produce good models given the scanners limitations . So there’s still plenty of room for improvement.

3D Scanner – C++ Code Available

The code is now available via svn. The URL is https://code.google.com/p/splinesweep/. Be warned! the code is awful….i mean really really pre pre alpha awful. Compile at your own risk, use at your own risk, and feel free to contribute if you can make any sort of sense out of the code (give me a shout first). The code is developed under netbeans, and is therefore structured as a netbeans project, there is probably a much more elegant way of setting up the svn so it doesn’t matter what IDE you use, but I don’t know it….so unfortunately it’s not set up in any such way.

In order to generate the models you’ll need 2 sequences of 100 images taken at 3.6 degree intervals around the object in question (atm its fixed at 100, sucks i know,will be changing this very shortly), one for the texture and one for the mesh points. They’ll probably look very much like this:

The Input Images

The Input Images

Start up the splinesweep program and click “Load Images” and select all the 100 laser spline images, then click “Load Textures” and select all 1oo full colour images. Hit “Generate Model” wait for a bit, and a .obj , .mtl and .png images should be created in the folder that the splinesweep program is located in.

SplineScan Screenshot

SplineScan Screenshot

There is one pretty major limitation at the moment that I’ll probably get round to fixing within a week, currently the program assumes the centre of rotation of the platform to be at point that’s sort of at the middle of the image, and unfortunately this can only be changed within the code.

A few notes on dependencies:

The program requires QT4 and OpenCV2.0, but OpevCV1.0 may work, all-though the program does expect to find the opencv libraries in /usr/local/lib as opposed to /usr/lib. Soon as Ubuntu 10.04  is released i’ll build a version that works nicely with things you can apt-get.

How the code works:

First a sobel filter is run on all the spline images to produce edge images, then a threshold is taken of all the images to produce a binary image. To produce the 3D points for the mesh a series of points up the height of the image are taken and moved along the length of the image until a maximum pixel value is found or the edge of the image is reached, if the edge of the image is reached the point is discarded. The 2D points for each image are then placed in a rotated fashion around a central 3D axis to produce the 3D point cloud.

Holes in the point cloud are then filled in and a surface mesh is calculated. The RGB values in the colour images of every corresponding 2D point are found then placed into an image to create the texture, and the mappings between the 3D points and points in the texture are calculated.

This is all then written out to 3 files, an obj file which stores the vertexs,faces, and texture UV coordinates, a .mtl file which lists and describes properties of the materials used to texture the model, and  a .png file which is the actual texture.

There’s probably a bunch of little things going on that I can’t remember but this is as near as damnit to what’s actually going on.

3D Scanner – Textured Models!

Here is the nodding monkey with his texture on.

Textured Monkey

Textured Monkey

As you can probably see the texture is not that detailed. Each of the small faces that make up the model is textured with only 4 pixels worth of information. I’m going to try and work out a way to get a more detailed texture using the images captured during the scan (there’s a hella lot of information being thrown away creating the texture…admittedly a lot of it is repeated info…but there’s definitely enough to get a way better texture).

Edit: Here’s an animated gif of the scanning process. The laser-line and lights should alternate every frame, but i couldn’t be bothered ordering the frames in the gif.

Edit 2: Mesh smoothed with Laplacian filter and a white balance performed on the texture. Some of the finer details of the scan are lost due to the filter, but it does provide nice smooth surfaces. The texture seems slightly twisted to one side for some reason.

3D Scanner – Nuther MiniUpdate

Started working on adding a texture to the generated models. To do this I’ve added an array of LEDs  to the inside of the scanner that can be turned on to illuminate the model via the serial port on the arduino. A full colour image is captured for every laser spline image, then for every point along the laser spline the corresponding rgb value from the full color is found. The rgb values for all the splines are then mapped onto a 2D image creating the texture.

I need to brush up on some 3D modelling theory and the .obj and .mtl file formats and I should be able to create fully textured 3D models.

For now here is the image of the texture I captured for the nodding monkey model I’ve been using.

3D Scanner – ExtraMini Update

Just finished a pretty sketchy algorithm to fill in the holes left by scanning errors so i can now create surfaces on the models. Been hittin the JW red label while coding in celebration of the purchase of some wheels, so can’t be bothered to write an explanation of how it works just yet.

Here is a picture of a full model, algorithm isn’t perfect, needs more work. But for now it gives a fairly rough but almost respectable skinned model.

Skinned 3D model

I think a lot of the nosie issues are related to the laser line being to diffuse. Gonna try and do something about that, not sure what yet.

3D Scanner – Mini Update “Scan Time!!”

It works!!

Admittedly not so well, but….it works!! still a lot of tweaking to do on the software side, need to work out a good way to add a skin to the model and need to tweak the spline finding algorithm a bit.  I’ll be  doing a bigger post later with the final mods to the scanner body and releasing the code.

The First Scan

The object that was scanned and the model produced side by side.

It’s quite hard to see all the features on a static  view of the model, but when you can rotate it round it you can see quite a few of the smaller details. Hopefully when it’s skinned some more of the details will be visible.

Bonus shot of the scanner with added bonus of my feet.

The Scanner