Help! Processing getting stuck at context.update();!

edited July 2015 in Kinect

Hello everyone! I am having a serious and mysterious issue with my kinect project for school. We're using an Kinect for Xbox 360, with Kinect SDK 1.7, and SimpleOpenNI Library 1.96 in Processing.

This program is much like the AR SandBox project done with Kinect, Linux and some kind of version of C, but for our project we are using processing so that we can add more onto the code (for example, have fish swim in the areas that are supposed to be blue).

Here is the most recent code: `

import SimpleOpenNI.*;


SimpleOpenNI context;
float        zoomF =0.5f;
float        rotX = radians(180);  // by default rotate the hole scene 180deg around the x-axis, 
                                   // the data from openni comes upside down
float        rotY = radians(0);
boolean      autoCalib=true;


ArrayList <PVector> darkGreenPoints = new ArrayList <PVector>();
ArrayList  <PVector> greenPoints = new ArrayList <PVector> ();
ArrayList <PVector> yellowPoints = new ArrayList <PVector>();
ArrayList <PVector> brightBluePoints = new ArrayList <PVector>(); 
ArrayList <PVector> bluePoints = new ArrayList <PVector>();
ArrayList <PVector> darkBluePoints = new ArrayList <PVector>();


///variables to modify the depth level colors
int dgreenStart=609;
int dgreenEnd=837;
int greenEnd=1065;
int yellowEnd=1293;
int bblueEnd=1521;
int blueEnd=1749;
int dblueEnd=1977;

void setup()
{

  size(1024,768,P3D); 
  println("start setup");
  context = new SimpleOpenNI(this);
  if(context.isInit() == false)
  {
     println("Can't init SimpleOpenNI, maybe the camera is not connected!"); 
     exit();
     return;  
  }
  if(context.isInit() == true)
  {
     println("done!"); 
  }

  // disable mirror
  context.setMirror(false);

  // enable depthMap generation 
  context.enableDepth();

  // enable skeleton generation for all joints

  stroke(255,255,255);
  smooth();  
  perspective(radians(45),float(width)/float(height),10,150000);     
  println("end setup");
 }

void draw()
{
  println("begin draw");
  // update the cam
  println("updating cam");
  /////Here is where I'm having problems, the program gets stuck at the update method.
  context.update();
  println("cam updated");
  background(0,0,0);

  // set the scene pos
  translate(width/2, height/2, 0);
  rotateX(rotX);
  rotateY(rotY);
  scale(zoomF);

  println("map vars");
  int[]   depthMap = context.depthMap();
  int     steps   = 3;  // to speed up the drawing, draw every third point
  int     index;
  PVector realWorldPoint;

  println("color dot code");
  depthColor();

  translate(0,0,-1000);  // set the rotation center of the scene 1000 infront of the camera
  println("original dot code");
  // draw the pointcloud
  beginShape(POINTS);
  for(int y=0;y < context.depthHeight();y+=steps)
  {
    for(int x=0;x < context.depthWidth();x+=steps)
    {
      index = x + y * context.depthWidth();
      if(depthMap[index] > 0)
      { 
        // draw the projected point
        realWorldPoint = context.depthMapRealWorld()[index];
        stroke(100);
        point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);
      }
    } 
  } 
  println("new dot code");
  for (int i=0;i<darkGreenPoints.size();i++){
   PVector d = darkGreenPoints.get(i);
   stroke(0,100,0);
   point(d.x,d.y,d.z); 
  }
  for (int i=0;i<bluePoints.size();i++){
   PVector d = bluePoints.get(i);
   stroke(0,0,200);
   point(d.x,d.y,d.z); 
  }
  for (int i=0;i<greenPoints.size();i++){
   PVector d = greenPoints.get(i);
   stroke(0,255,0);
   point(d.x,d.y,d.z); 
  }
  for (int i=0;i<yellowPoints.size();i++){
   PVector d = yellowPoints.get(i);
   stroke(255,255,0);
   point(d.x,d.y,d.z); 
  }
  for (int i=0;i<brightBluePoints.size();i++){
   PVector d = brightBluePoints.get(i);
   stroke(100,100,255);
   point(d.x,d.y,d.z); 
  }
  for (int i=0;i<darkBluePoints.size();i++){
   PVector d = darkBluePoints.get(i);
   stroke(0,0,100);
   point(d.x,d.y,d.z); 
  }
  endShape();  

  println("clearinglists");
  ///clearing lists to reset them, so that the drawing is exactly
  ///what the kinect sees in each current frame, not previous ones
  println(darkGreenPoints.size(), "before");
  darkGreenPoints.clear();
  bluePoints.clear();
  greenPoints.clear();
  yellowPoints.clear();
  brightBluePoints.clear();
  darkBluePoints.clear();
  println(darkGreenPoints.size(), "after");


  println("end draw");
}

void depthColor(){
    PVector b;
    println("depth color method");
    for(int i=0;i<context.depthMapRealWorld().length;i++){
     b=context.depthMapRealWorld()[i];
     if (b.z>dgreenStart && b.z<dgreenEnd){
      darkGreenPoints.add(b); 
     }
      if (b.z>dgreenEnd && b.z<greenEnd){
      greenPoints.add(b); 
      }
      if (b.z>greenEnd && b.z<yellowEnd){
      yellowPoints.add(b); 
     }
      if (b.z>yellowEnd && b.z<bblueEnd){
      brightBluePoints.add(b); 
     }
     if (b.z>bblueEnd && b.z<blueEnd){
      bluePoints.add(b); 
     }
     if (b.z>blueEnd && b.z<dblueEnd){
      darkBluePoints.add(b); 
     }
    }
  }

` This code was working beautifully a couple of weeks ago, and I have not made any drastic changes to it in between then, just some clean up. After adding in println() statements, I see that Processing doesn't go farther than context.update(). I get no errors in the code, and when I remove context.update(), the rest of the code is able to run. All I get is a grey screen.

I have been on the ultimate and extremely frustrating goose chase to find a way to fix this problem. The kinect is functional, as proven when plugged into a 360.

Please help me. I don't know what to do anymore.

Sincerely,

The incredibly defeated student

Answers

Sign In or Register to comment.