Kinect
Using KinectToStl
Kyle McDonald's
KinectToStl will take a rough image of what is in front of the Kinect sensor and export it to a printable .stl file.
created KinectToStl.
- Download and install Kyle McDonald's KinectToStl.
- Download and install MeshLab.
- Download and install Blender.
- Connect the Kinect to your computer
- Open KinectToStl
- Adjust the zCutoff (rotate the mouse around to get a sense of how deep the scan is)., and the fovWidth and fovHeight sliders to adjust the width and height of the field of view.
- Enable useRandomExport
- When you are in a good position, click exportStl to capture the frame
- The Kinect Export 2011... file will be stored in the KinectToStl data folder
- Quit Meshlab if it is running
- CTRL-click the STL file, and choose Open With>meshlab.
- CTRL+click on the file and open with MeshLab
- You should see a dialog box that asks you to Unify Duplicated Vertices. Say Ok
- Click on Filters:Remeshing, simplification and reconstruction:Quadratic Edge Collapse Decimation
- You want to reduce the number of faces to something around 20,000. Change the percentage reduction to .75. Click Apply
- Drag in the model to rotate it and inspect it. If it looks good, click Apply until you're close to 20,000 faces and still looking good.
- Close the dialog box and click File>Export mesh as Save the file as an stl
- Open Blender
- Zoom out until the cube is very small. Select the cube. Move the cursor close to the cube and press S for Scale. Drag until the cube fills the screen, then press Enter or Return.
- Import the stl file. (File>Import). You won't see it because it is inside the cube. Use the Scene panel on the right to select the stl. Press G for grab and move the mesh to the top of the cube.
- CTRL+click on the Cube, then SHIFT+click on the stl file.
- In the Modifier panel (click on the wrench on the right side to activate it).Click Add Modifier and select Boolean then select Difference. Click on the Cube on the right side. Wait.
- Click Apply, wait
- Press A to deselect everything
- Select the Cube. Press X and delete it
- If you need to, bring the model into Edit mode (press TAB) and delete extra vertices
- Press SHIFT CTRL ALT M
- Export the stl file
- Open ReplicatorG and open the stl file
- Print
Dan Shiffman
Dan Shiffman has a Processing sketch that will save data collected by the kinect and turn it into a 3D file:
- Download and install peasyCam library
- Download and installsupercad library
- Download and installkinect library
- Open Processing
- Paste in this code:
/*
Simple Kinect point-cloud demo v. 0.2
Henry Palonen <h@yty.net>
Using Daniel Shiffman’s great processing-library for Kinect:
http://www.google.com/url?sa=D&q=http://www.shiffman.net/2010/11/14/kinect-and-processing/&usg=AFQjCNH8kZWDMhFueeNBn5x97XoDR3v9oQ
Based on Kyle McDonalds Structure Light scanner:
http://www.openprocessing.org/visuals/?visualID=1014
Using also SuperCAD for outputting the .obj – files: http://labelle.spacekit.ca/supercad/
History
——-
17.11.2010 – 0.1 – First version, simple point-cloud working
18.11.2010 – 0.2 – Output to .obj for importing to Blender, gray-color for distance and small lines as output
*/
float zscale = 3;
float zskew = 100;
int inputWidth = 640;
int inputHeight = 480;
PeasyCam cam;
float[][] gray = new float[inputHeight][inputWidth];
PImage depth;
static final int gray(color value) {
return max((value >> 16) & 0xff, (value >> 8 ) & 0xff, value & 0xff);
}
void setup() {
size(inputWidth, inputHeight, P3D);
cam = new PeasyCam(this, width);
NativeKinect.init();
depth = createImage(640,480,RGB);
stroke(255);
}
int counter = 0;
void draw () {
background(0);
if (record == true) {
beginRaw("superCAD.ObjFile", "Model_" + counter + ".obj"); // Start recording to the file
}
depth.pixels = NativeKinect.getDepthMap();
depth.updatePixels();
NativeKinect.update();
for (int y = 0; y < inputHeight; y++) {
for (int x = 0; x < inputWidth; x++) {
// FIXME: this loses Z-resolution about tenfold …
// -> should grab the real distance instead…
color argb = depth.pixels[y*width+x];
gray[y][x] = gray(argb);
}
}
// Kyle McDonald’s original source used here
translate(-inputWidth / 2, -inputHeight / 2);
int step = 2;
for (int y = step; y < inputHeight; y += step) {
float planephase = 0.5 - (y - (inputHeight / 2)) / zskew;
for (int x = step; x < inputWidth; x += step)
{
stroke(gray[y][x]);
//point(x, y, (gray[y][x] – planephase) * zscale);
line(x, y, (gray[y][x] - planephase) * zscale, x+1, y, (gray[y][x]- planephase) * zscale);
}
}
if (record == true) {
endRaw();
record = false; // Stop recording to the file
}
}
void keyPressed() {
if (key == 'R' || key == 'r') {
// Press R to save the file
record = true;
counter++; //Thanks to Dr. Rhazes Spell for putting the counter in adding functionality.
}
}
- Open MeshLab
- Import the Mesh in the Processing Sketch folder
- Under the View tab select Layers
- Under the Filters tab select Sampling>Poisson -Disk Sampling.
- Choose the sample points in the prompted window. Pick something between 60000 and 100000 sample points.
- Check on the Base Mesh Subsampling box or you will get an error.
- Apply
- Select the Poison-disk Samples Layeris highlighted.
Make sure Poisson-disk Samples layer is highlighted
Next go to Filters —–>Normals, Curvatures and Orientation —> Compute Normals for Point Set. A menu box will appear .
Put a number more than 15 in the
Number of neighbors box. There is no hard fast rule so you will have to experiment to find what works for you.
Next go to Filters —> Points Set—>Surface Reconstruction Poisson. This will create a new layer
called Poisson Mesh. From there you can add surfaces to the Model. Finally save the model as a .OBJ. to be opened in Maya or Blender. MeshLab allows you to save in a number of other formats The file is ready to be opened in Maya or Blender. Meshlab allows you to save in a multitude of formats that are perfect for other 3D software such as 3D Max.While I haven’t tried it these files are supposedly great for 3D printing. It will take much experimentation to clean up the models. Have fun—-That’s an order.
Installing Processing Libraries
- Open Processing
- Open Preferences
- Locate where the sketchbook is
- Close Processing
- Open Processing folder where your Sketchbook lives
- Find the libraries folder. If it doesn't exist create one
- Move the library into the libraries folder
- Open Precessing
called
openkinect
OSX Kinect Application by CidVilas
This is a port/adaptation of Hector Martin's libfreenect for OS X made by Theodore Watson.