Loading...
Logo
Processing Forum
Hey guys,

I'm having difficulty getting the Kinect to track at full screen — I can manage static images to display at full screen but motion-sensitive activity is isolated to the standard Kinect 640 x 480 depth camera parameters in the upper left hand corner of the screen.

I tried swapping out all "int" values to match the screen size (or pretty much any size larger than 640 x 480) but always get an error message: "ArrayIndexOutOfBoundsException". Any ideas for how to solve this?

Thanks in advance for your help!

Library: SimpleOpenNI
Mac OS 10.7.4

Copy code
  1. import SimpleOpenNI.*;
    SimpleOpenNI kinect;

    int closestValue;
    int closestX;
    int closestY;

    float lastX;
    float lastY;


    void setup() {
      size(screen.width, screen.height);
      kinect = new SimpleOpenNI(this);
      kinect.enableDepth();
      smooth();
     
      background(128, 128, 142);
    }

    void draw() {
      for (int y = 10; y < screen.height; y += 10) {
        for (int x = 10; x < screen.width; x +=10) {
          point(x, y);
         
        }
      }
     
     
      closestValue = 8000;
     
      kinect.update();
     
      int[] depthValues = kinect.depthMap();
     
      for(int y = 0; y < 480; y++){
        for(int x = 0; x < 640; x++){
         
          // reverse x by moving in from
          // the right side of the image
          int reversedX = 640-x-1;
         
          // reversed x to calculate
          // the array index
          int i = reversedX + y * 640;
          int currentDepthValue = depthValues[i];
         
          // only look for the closestValue winin a range
          // 610 (or 2 feet) is the minimum
          // 1525 (or 5 feet) is the maximum
          if(currentDepthValue > 610 && currentDepthValue < 1525
          && currentDepthValue < closestValue){
           
            closestValue = currentDepthValue;
            closestX = x;
            closestY = y;
          }
        }
      }
     
     float interpolatedX = lerp(lastX, closestX, 0.3f);
     float interpolatedY = lerp(lastY, closestY, 0.3f);
     
      if(closestX != 4 && closestY != 4 && pmouseX !=0 && pmouseY != 0) {
        float s = dist(closestX, closestY, pmouseX, pmouseY) + 1;
        noStroke();
        fill(0, 198, 163, 10);
        ellipse(closestX, closestY, s, s);
        stroke(255);
        point(closestX, closestY);
      }
    }

    void mousePressed(){
      background(128, 128, 152);
    }

Replies(6)

the kinect as a piece of hardware will not pickup anything bigger than a 640 x 480 image. its hardcoded into the firmware of that device. Theres no thing you can do to get it to full screen. you can interpolate and scale up that data set to cover a full screen space.

The reason why i suspect they did that is because 640 x 480 is probably the highest resolution they can go and still be able to send that much data about the image through the usb cable smoothly without lag.
Thanks for your response, Kobby.

I assumed that I would need some code to interpolate the data to fill the screen. Will do some more research and look into that now.
i'd look into using something like the map() function for a quick conversion of scales

ex:

Copy code
  1. float xMapped = map(xKinectCoord, 0, 640, 0, screenWidth);
  2. float yMapped = map(yKinectCoord, 0, 480, 0, screenHeight);
by no means a complete fix but its a start.

Hope this helps,
Kobby
Great! Will give that a shot. Thanks again.
I also found this library. It isn't perfect, and it clearly bumps up resolution so the images are pixelated, but it does the trick for my purposes.

http://www.superduper.org/processing/fullscreen_api/
Hi

Im having exactly the same problem with tracking in fullscreen with kinect. tried to implement this code but where do I scale the tracking area in SimpleOpenNI. where and how do I immplement this code?

Copy code
  1. float xMapped = map(xKinectCoord, 0, 640, 0, screenWidth);
  2. float yMapped = map(yKinectCoord, 0, 480, 0, screenHeight);
but guess it would be like this nowadays:
Copy code
  1. float xMapped = map(xKinectCoord, 0, 640, 0, displayWidth);
  2. float yMapped = map(yKinectCoord, 0, 480, 0, displayHeight);