Kinect Corner Detection

Hi, I'm currently trying to develop a program for a final year University project that uses Processing and a Kinect with an Arduino controlled turntable to scan a room and create a 3D mesh for acoustic analysis. I'm having some trouble writing a code that will detect corners of objects and record their coordinates into a .stl that I can import into MeshLab. The idea is that the code will record the corners of objects instead of scanning every depth point the Kinect can see. Has anyone tried looking in to this before?

I've included the code below just incase it helps to see how I'm working so far. Its to satisfy my project's minimum objective of being a glorified range finder. I'm using v.1.5.1 as it supports the macbook I'm working on, so sorry if this is in the wrong place.

import SimpleOpenNI.*;
import unlekker.util.*;
import unlekker.modelbuilder.*;
import processing.opengl.*;
import processing.serial.*;

SimpleOpenNI kinect;
UGeometry model;
UVertexList vertexList;
Serial myPort;

boolean scanning = false;
boolean printval = false;

boolean turn1 = false;
boolean turn2 = false;
boolean turn3 = false;
boolean turn4 = false;
boolean firstcontact = false;

String val;
PrintWriter output;

void setup ()
{
  size (940, 480);
  background(0);

  kinect = new SimpleOpenNI(this);
  kinect.enableDepth();

  model = new UGeometry();
  vertexList = new UVertexList();

  output = createWriter("depths.csv");

  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 57600);
  myPort.bufferUntil('\n');
}

void draw ()
{
  kinect.update();

PImage depthImage = kinect.depthImage();
image(depthImage, 0 ,0);

int furthestValue = 0;

if (turn1 && !scanning)
{
  myPort.write('1');
  myPort.readStringUntil('\n');
  scanning = true;
}

if (turn2 && !scanning)
{
  myPort.write('2');
  myPort.readStringUntil('\n');
  scanning = true;
}

if (turn3 && !scanning)
{
  myPort.write('3');
  myPort.readStringUntil('\n');
  scanning = true;
}  

if (turn4 && !scanning)
{
  myPort.write('4');
  myPort.readStringUntil('\n');
  scanning = true;
  output.close(); //finishes the csv file
}

if (scanning)
{
// get the depth array from the kinect  
int[] depthValues = kinect.depthMap();
// for each row in depth image
for (int y = 0; y < 480; y++){
//look at each pixel in the row
  for(int x = 0; x < 640; x++){
// pull out the corresponding value from the depth array
    int i = x + y * 640;
    int currentDepthValue = depthValues[i];    
//if that pixel is the furthest so far
    if(currentDepthValue > 0 && currentDepthValue > furthestValue){
//save the value
      furthestValue = currentDepthValue;
    }
  }
scanning = false;
}
printval = true;
}

if (printval){
  float centimeters = furthestValue / 10;
  float inches = furthestValue / 25.4;
  println("Furthest Depth: " + furthestValue + " mm / "  
  + centimeters + " cm / " + inches + " inches");
//  output. println(centimeters + " cm"); 
  printval = false;
}
//output.close(); //finishes the csv file
// exit(); //exits program
}

void keyPressed() {
  if (key == ' ') {
    turn1 = true;
  }
}
Sign In or Register to comment.