Getting Started with Kinect and Processing

So, you want to use the Kinect in Processing. Great. This page will serve to document the current state of my Processing Kinect library, with some tips and info.

Before you proceed, however, you may want to instead consider using the wonderful SimpleOpenNI library and Greg Borenstein’s Making Things See book! OpenNI has lots of features (skeleton tracking, gesture recognition, etc.) that are not available in this library.

I’m ready to get started right now

What hardware do I need?

First you need a “stand-alone” kinect. You do not need to buy an Xbox. If you get the stand-alone kinect listed below, it will come with a USB adapter and power supply.

Standalone Kinect Sensor

If you have a kinect that came with an XBox, it will not include the USB adapter. You’ll need to purchase this separately:

Kinect Sensor Power Supply

Um, what is Processing?

I’m going to assume you are familiar with Processing, but just in case you are not, I suggest checking out: processing.org (Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Initially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production.)

What if I don’t want to use Processing?

If you are comfortable with C++ I suggest you consider using openFrameworks or Cinder with the Kinect. At the time of this writing, these environments have some features I haven’t implemented yet and you also get a C++ speed advantage when processing the depth data, etc.:

ofxKinect
Kinect CinderBlock

More resources from: The OpenKinect Project

I’ve got Processing, how do I download and install the library?

By default Processing will create a “sketchbook” folder in your Documents directory, i.e. on my machine it’s:

/Users/daniel/Documents/Processing/

If there isn’t already, create a folder called “libraries” there, i.e.

/Users/daniel/Documents/Processing/libraries/

Then go and download openkinect.zip and extract it in the libraries folder, i.e. you should now see

/Users/daniel/Documents/Processing/libraries/openkinect/
/Users/daniel/Documents/Processing/libraries/openkinect/library/
/Users/daniel/Documents/Processing/libraries/openkinect/examples/
etc.

Restart Processing, open up one of the examples in the examples folder and you are good to go!

More about installing libraries:

http://wiki.processing.org/w/How_to_Install_a_Contributed_Library
http://www.learningprocessing.com/tutorials/libraries/

At the moment, my library only works with Mac OS X (intel, 10.5 or 10.6 should both be ok). Hopefully this will be remedied soon enough. However, if you are interested in working with Kinect on windows, I recommend SimpleOpenNI.

What code do I write?

To get started using the library, you need to include the proper import statements at the top of your code:

import org.openkinect.*;
import org.openkinect.processing.*;

As well as a reference to a “Kinect” object, i.e.

// Kinect Library object
Kinect kinect;

Then in setup() you can initialize that kinect object:

  kinect = new Kinect(this);
  kinect.start();

Once you’ve done this you can begin to access data from the kinect sensor.

Currently, the library makes data available to you in four ways:

  1. RGB image from the kinect camera as a PImage.
  2. Grayscale image from the IR camera as a PImage
  3. Grayscale image with each pixel’s brightness mapped to depth (brighter = closer).
  4. Raw depth data (11 bit numbers between 0 and 2048) as an int[] array

Let’s look at these one at a time. If you want to use the Kinect just like a regular old webcam, you can request that the RGB image is captured:

  kinect.enableRGB(true);

Then you simply ask for the image as a PImage!

  PImage img = kinect.getVideoImage();
  image(img,0,0);

Alternatively, you can enable the IR image:

  kinect.enableIR(true);

Currently, you cannot have both the RGB image and the IR image. They are both passed back via getVideoImage() so whichever one was most recently enabled is the one you will get.

Now, if you want the depth image, you can:

  kinect.enableDepth(true);

and request the grayscale image:

  PImage img = kinect.getDepthImage();
  image(img,0,0);

As well as the raw depth data:

  int[] depth = kinect.getRawDepth();

If you are looking at the raw depth data only, you can turn off the library’s behind the scenes depth image processing to make it slightly more efficient:

  kinect.processDepthImage(false);

Finally, you can also adjust the camera angle with the tilt() function, i.e.:

float deg = 15;
kinect.tilt(deg);

So, there you have it, here are all the useful functions you might need to use the Processing kinect library:

  1. enableRGB(boolean) — turn on or off the RGB camera image
  2. enableIR(boolean) — turn on or off the IR camera image
  3. enableDepth(boolean) — turn on or off the depth tracking
  4. processDepthImage(boolean) — turn on or off the depth image processing
  5. PImage getVideoImage() — grab the RGB or IR video image
  6. PImage getDepthImage() — grab the grayscale depth map image
  7. int[] getRawDepth() — grab the raw depth data
  8. tilt(float) — adjust the camera angle (between 0 and 30 degrees)

Where’s the javadoc?

Stay tuned, I’ll get something up soon. All the source is here:

https://github.com/shiffman/libfreenect/tree/master/wrappers/java/processing

So now what?

So far, I only have three basic examples:

Display RGB, IR, and Depth Images


Code:RGBDepthTest

(NOTE: KNOWN BUG IN IR IMAGE RIGHT NOW)

This example does nothing but use all of the above listed functions to display the data from the kinect sensor.

Point Cloud


Code: PointCloud

Here, we’re doing something a bit fancier. Number one, we’re using the 3D capabilities of Processing to draw points in space. You’ll want to familiarize yourself with translate(), rotate(), pushMatrix(), popMatrix(). This tutorial is also a good place to start. In addition, the example uses a PVector to describe a point in 3D space. More here: PVector tutorial.

The real work of this example, however, doesn’t come from me at all. The raw depth values from the kinect are not directly proportional to physical depth. Rather, they scale with the inverse of the depth according to this formula:

depthInMeters = 1.0 / (rawDepth * -0.0030711016 + 3.3309495161);

Rather than do this calculation all the time, we can precompute all of these values in a lookup table since there are only 2048 depth values.

float[] depthLookUp = new float[2048];
for (int i = 0; i < depthLookUp.length; i++) {
  depthLookUp[i] = rawDepthToMeters(i);
}
 
float rawDepthToMeters(int depthValue) {
  if (depthValue < 2047) {
    return (float)(1.0 / ((double)(depthValue) * -0.0030711016 + 3.3309495161));
  }
  return 0.0f;
}

Thanks to Matthew Fisher for the above formula. (Note: for the results to be more accurate, you would need to calibrate your specific kinect device, but the formula is close enough for me so I’m sticking with it for now. More about calibration in a moment.)

Finally, we can draw some points based on the depth values in meters:

  for(int x = 0; x < w; x += skip) {
    for(int y = 0; y < h; y += skip) {
      int offset = x+y*w;
 
      // Convert kinect data to world xyz coordinate
      int rawDepth = depth[offset];
      PVector v = depthToWorld(x,y,rawDepth);
 
      stroke(255);
      pushMatrix();
      // Scale up by 200
      float factor = 200;
      translate(v.x*factor,v.y*factor,factor-v.z*factor);
      // Draw a point
      point(0,0);
      popMatrix();
    }
  }

Average Point Tracking

The real magic of the kinect lies in its computer vision capabilities. With depth information, you can do all sorts of fun things like say: "the background is anything beyond 5 feet. Ignore it!" Without depth, background removal involves all sorts of painstaking pixel comparisons. As a quick demonstration of this idea, here is a very basic example that compute the average xy location of any pixels in front of a given depth threshold.

Source: AveragePointTracking

In this example, we declare two variables to add up all the appropriate x's and y's and one variable to keep track of how many there are.

float sumX = 0;
float sumY = 0;
float count = 0;

Then, whenever we find a given point that complies with our threshold, we add the x and y to the sum:

  if (rawDepth < threshold) {
    sumX += x;
    sumY += y;
    count++;
  }

When we're done, we calculate the average and draw a point!

if (count != 0) {
  float avgX = sumX/count;
  float avgY = sumY/count;
  fill(255,0,0);
  ellipse(avgX,avgY,16,16);
}

Why don't the RGB images and depth values correspond properly?

Unfortunately, b/c the RGB camera and the IR camera are not physically located in the same spot, we have a stereo vision problem. Pixel XY in one image is not the same XY in an image from a camera an inch to the right. I'm hoping to stretch my brain to try to understand this better and work out some examples that calibrate the data in Processing. Stay tuned!

If you are interested in more (and software that will do this very job!) check out Nicolas Burrus' amazing work:

Theory on depth/color calibration and registration
version 0.3 of RGBDemo

What's missing?

Lots! Open a github issue if you want to add an item to my to do list!

https://github.com/shiffman/libfreenect/issues

FAQ

1. What are there shadows in the depth image?

Kinect Shadow diagram

2. What is the range of depth that the kinect can see?

~0.7–6 meters or 2.3–20 feet. Note you will get black pixels (or raw depth value of 2048) at both elements that are too far away and too close.

  • Francesco

    Thank you! I’m really looking forward to try it once i have bought a kinect.
    Bookmarked! ;)

  • http://Www.ait-SA.com Mike Alport

    Hi Dan,
    Thanks for your tutorial. Intending to try it soon.
    But I am really not finding anyone who describes how the depth measurement works. Does the depth camera just use the divergence of each of the IR beams as a measure of the distance to the reflecting surface?
    Mike

  • hardik

    hey daniel,
    awesome work!! :)

  • shooperman

    Hi Dan,

    Very nice work. Going to give it a shot and buy a Kinect soon!
    BTW, if I wanted to build a video wall interface with this, do you think Processing is fast enough?

  • Andrea

    Hi Daniel,
    could you tell me what is the accuracy in the depth image? I would like to use it to scan some 3d models.

    Thanks
    Andrea

  • knutl

    @mike
    you can get all the technical information here
    http://www.primesense.com/?p=486

  • http://www.shiffman.net Daniel

    @shooperman, indeed, it all depends on what you are doing, but lots of video wall projects are implemented in Processing. See: http://itp.nyu.edu/bigscreens2010/

  • Matt

    Hi Daniel.
    This is fantastic,thanks for sharing.

    I do have one issue though that I would love some info about if you could help.
    I am running this on a pretty old laptop (one of the first macbook pros so its only Intel Core Duo with 2Gig RAM).
    Getting the depth data freezes pretty regularly If i disable depth then re enable it again it starts going again for a short while.

    Do you have any ideas on what might cause this, could it be a hardware issue ? What are you running your code on and how stable is it ?

    It seems the more programs try to do the more unstable it becomes, running your point cloud example will run for several minutes, but the AveragePointTracking example is lucky to give me a couple of seconds.

    Your very first version of your kinect processing library (although quite a bit slower) was pretty stable for me, this one is soo much faster so I would love to use it for my experiments.

    Any ideas on what steps if any I could take to make this more robust would be greatly appreciated.

    Thanks
    Matt

  • http://fox-gieg.com Nick Fox-Gieg

    Hi, I’m testing out the new library, and it seems like it’s actually grabbing less depth information than before–visually, the depth map goes from light gray to medium gray, instead of white to black. Do you know why this is?

    Thanks,
    Nick

  • http://www.shiffman.net Daniel

    Hmm, I must have done something weird in the mapping by accident. I will double-check. Still, the full raw info is there, I suggest using the getRawDepth() function which returns an int[] array with the full 0-2047 depth range.

  • http://www.shiffman.net Daniel

    @Matt Hmmm, I’ve heard of this on older machines, I will definitely look into it when I get a chance. I think it’s a threading problem, alas. If you run from the source in eclipse, you might be able to play with the code and see if you can get it to work. i’ll keep you posted

  • http://fox-gieg.com Nick Fox-Gieg

    Thanks! How would you suggest mapping the raw depth ints to make a full-range grayscale image? My attempts so far have produced some awesome ’80s color cycling, but not much useful. :)

    Nick

  • http://www.shiffman.net Daniel

    Try using the map() function.

    float b = map(depth,0,2048,255,0);
    color c = color(b);
    
  • http://fox-gieg.com Nick Fox-Gieg

    Great–using map() gets me close enough for a short-term fix.

    FYI, if you investigate this further…I have to cut the input range roughly in half–map(0,1100,255,0)–to more closely match the full black-to-white grayscale range shown by your old library, Jitter, or the OpenNI test utilities. (A side-by-side comparison grabbing a depth image using first your old, then your new library should make the difference visually clear.)

    Thanks!
    Nick

  • http://eliseelsacker.wordpress.com Elise

    Hi Daniel,

    I’m having the same problem as Matt (also running on a older Mac). Did you find a solution yet?

    Thanks,
    Elise

  • Matt

    Hi Elise
    I was hoping to look at the project in eclipse but really I’m have quite a few issues building the project in eclipse to even start looking for a solution. I have managed to get a few other kinect demos running on my mac and th all hang up pretty much the same as this processing one does. So I dont think its Daniels code but the libfreenect libraries.

    Interestingly Daniels very first processing example was fairly stable but (quite slower than later ones) if you just want to get proof of concept then maybe getting hold of one of those early builds will at least give you the chance to have a bit of a play.

    In the latest version I found that the point cloud example would stay running for the longest time quite good form a reboot with nothing else running.
    \
    Also setting and unsetting kinect.enableDepth() would restart the apps to see that things are working (albiet very briefly)

    Every possible version I have managed to run has kinect with this mac has been pretty unstable. I also noticed a kinect app at the app store just refused even try to install.
    So Im almost at the stage of giving up. (It is about time I upgraded) I would love to know if you get anywhere with your issues.

    But if you do want to see some results try installing Daniels first build for processing.

    Hope this helps

    Matt

  • Bill Hsu

    First, thanks to Dan for making this available!

    I just started playing with a kinect, and have also been trying to
    get a decent image out of just the depth data. While the depth
    range is 0-2047, the usable range seems to be smaller. Also,
    the resolution (not the spatial resolution in the image plane,
    but the depth resolution, sorry if I’m not making myself clear)
    doesn’t seem to be great.

    After a lot of tweaking position and range mapping, I came up
    with this face capture, using just the depth data.

    http://userwww.sfsu.edu/~whsu/KinectFaceTest.mov

    I understand people have seen better examples then this; I’d
    love to see some links. Thanks!

    Bill

  • http://fox-gieg.com Nick Fox-Gieg

    @Bill–cool, can you post the rules you used to remap the depth range? Your results look a lot better than mine! (Are you using the old or new library?)

    Thanks,
    Nick

  • Bill Hsu

    Hi Nick, I’m pretty sure I’m using the new library; my openkinect.jar file is
    dated 1/14/11. I hacked Daniel’s AveragePointTracking sketch. This is the
    mapping code, embedded into the kinectTracker class, display() method.
    depth[] is the array of raw depth values. display is the image, based on depth values,
    to be displayed in the window:

    b = map(depth[offset], 600, 650, 255, 0);
    display.pixels[pix] = color(b);

    I really had to be positioned right around the 600-650 depth range, since
    it’s so tiny…

    Bill

  • http://www.shiffman.net Daniel

    @Matt and @Elise. Sadly if you are experiencing the same issue with, say, the openframeworks code as well, I don’t there’s anything I can do. . there seem to just be issues on older machines.

  • Dsquare

    I am interfacing this with arduino is there any way you can make what it reads like a cartesian plane

  • Jon

    Hi Daniel,

    Thanks for your work on this! I seem to be having the same problem as Matt and Elise. I’ve found this code, but I’m unsure how to go about compiling the library incorporating this “hack.” Would it be possible for you to build a version of the library incorporating this for those of us having the issue? Thanks!

    http://groups.google.com/group/openkinect/msg/9d78e24063033a6c

    Jon

  • http://www.theestateovcreation.co.uk hagbard

    Hi Daniel,
    Thanks for all of your hard work. Im on a mac, and just started with processing, and a kinect [1 day compiling experience vrs 16 years of motion graphics experience] so im taking wee steps here ; )
    downloaded ur library, I think Ive installed homebrew ; ), downloading xcode as wee speak.

    Just ran ur examples in processing and they look great, only issue Im having is that in theRGB depth test when I try to turn on the IR camera I get this crash everytime
    http://www.theestateovcreation.co.uk/ssprocessing_.jpg

    also is there a web resource for absolute munters like myself for using processing/mac/kinect
    so I dont have to bother the big boys ; )

    many thanks in advance

    osx 10.6.6 ma cpro quadcore 32gig ram

  • http://www.shiffman.net Daniel

    @hagbard, odd that error has come up with older machines, but I’m surprised you are having it. Are all the examples crashing or just that one? Feel free to file an issue at github, I’m busy with a few other projects but hope to get to looking at the library more soon.

  • http://www.shiffman.net Daniel

    @Jon, oh that looks promising, i’ll add it as an issue to github and try to get to it soon!

  • http://www.theestateovcreation.co.uk hagbard

    hi daniel, only that example does that, yup 2month old mac and 32 gig ram so shouldnt be an issue, however I am a first timer at this so I fully take the blame for all idiocy ; ) ive downloaded homebrew, ofxkinect and openkinect libreenect.. currentlty trying to understand how to “install” these downloads without mangling things, so im slowly trying to understand wrappers etc. this is not the place for me I need
    “downloading and installing openkinect complicated coding stuff for dummies”

  • http://iwearshorts.com Mike

    Hi Daniel,

    First off thanks for the great library! I am wondering if I could find an older version of your library with the “kinect.update()” function? I pulled some code from here:

    http://davidleonardtv.wordpress.com/2011/02/02/turn-kinect-into-3d-scanner-explained-full-tutorial-with-code/

    but it seems he’s using an old library of yours:

    http://www.google.com/url?sa=D&q=http://www.shiffman.net/2010/11/14/kinect-and-processing/

    Could you please point me in the right direction or tell me what current function I could use that is compatible to the “update” function?

    Thanks for your help on this! We are trying to build a 3d printer/scanner combo!

    Mike

  • http://twitter.com/YoannM Yoann MOINET

    I think I could help you with the RGB/Depth problem… it take a lot of hard tweaking to achieve that, but I finally did it. I wanted to do a point cloud, but with real colors. So I make a little function to recalibrate RGB coordinates. Here is what I have.

    PVector colorToWorld(int x, int y, int depthValue)
    {
    final double fx_rgb = 5.2921508098293293e+02;
    final double fy_rgb = 5.2556393630057437e+02;
    final double cx_rgb = 3.2894272028759258e+02;
    final double cy_rgb = 2.6748068171871557e+02;

    PVector v = depthToWorld(x, y, depthValue);
    v.x = (v.x/9.9984628826577793e-01) – 1.9985242312092553e-02;
    v.y = (v.y/9.9984628826577793e-01);
    v.z = (v.z/9.9984628826577793e-01) – 1.9985242312092553e-02;
    PVector result = new PVector();

    result.x = (float)((v.x*fx_rgb/v.z)+cx_rgb);
    result.y = (float)((v.y*fy_rgb/v.z)+cy_rgb);

    return result;
    }

    Hope this help, it works exactly the same as your depthToWorld function in PointCloud example.

  • http://www.facebook.com/profile.php?id=6420353 Corey Gwin

    Hey Daniel! Hoping you can help me out. I’m succesfully using your Kinect library with Processing on Ubuntu 10.04 but not while trying to communicate with an Arduino via the Processing serial library. If I run your Kinect library alone, I don’t have any issues but as soon as I add the serial library object myPort = new Serial(this, Serial.list()[0], 9600); “I get the following error: RXTX fhs_lock() Error: creating lock file: /var/lock/LCK..ttyUSB0: File exists”.

    I believe it has something to do with both the serial object and your kinect object running in the same Processing sketch because if I run a simple Processing serial example I don’t have the problem.

    Are you doing something with your library that may be causing my issue? Really appreciate your help. Hoping to use the library for a school project.

  • vali

    Hello Yoann, I try to apply your calculations, but I get a big shift.
    As I get it right. I read the pixel from position x and y from your calculations and put them on to the point x y from where I would expect them?

  • http://twitter.com/YoannM Yoann MOINET

    Hi Vali, I’m not sure to understand your problem.
    If it can help, here is the example Point Cloud made by Daniel Shiffman that I change with this function. Try to paste it in a new sketch, plug your kinect and launch it.

    import org.openkinect.*;
    import org.openkinect.processing.*;
    import processing.opengl.*;

    Kinect kinect;

    PImage imgRGB = createImage(640,480, RGB);
    PImage imgDepth = createImage(640,480, RGB);
    PImage imgRGB_min = createImage(160,120, RGB);
    PImage imgDepth_min = createImage(160, 120, RGB);

    int w = 640;
    int h = 480;

    float deg = 15;

    float a = 0;

    float[] depthLookUp = new float[2048];

    int skip = 4;

    int treshold = 800;

    double rotate_fact = 0.015f;

    int profondeur = 150;

    void setup()
    {
    size(1000,800, OPENGL);
    background(0);
    kinect = new Kinect(this);
    kinect.start();

    kinect.enableRGB(true);
    kinect.enableDepth(true);
    kinect.processDepthImage(true);

    for(int i = 0; i < depthLookUp.length; i++)
    {
    depthLookUp[i] = rawDepthToMeters(i);
    }

    imgRGB.loadPixels();
    imgDepth.loadPixels();
    }

    void draw()
    {
    background(0);

    image(imgRGB_min,10,10);
    image(imgDepth_min,180,10);
    int[] depth = kinect.getRawDepth();

    translate(width/2, height/2, profondeur);
    rotateY(a);

    imgRGB = kinect.getVideoImage();
    imgRGB.updatePixels();

    imgDepth = kinect.getDepthImage();
    imgDepth.updatePixels();

    for(int i = 0; i<w; i+=skip)
    {
    for(int j = 0; j<h; j+=skip)
    {

    int offset = i+j*w;

    int rawDepth = depth[offset];

    int temp_w = w – i;
    PVector rgb = colorToWorld(i,j,rawDepth);
    color colRGB = imgRGB.get((int)rgb.x,(int)rgb.y);
    color colDepth = imgDepth.get(i,j);
    PVector v = depthToWorld(i,j,rawDepth);
    stroke(colRGB);
    fill(colRGB);
    pushMatrix();

    float factor = 500;
    translate(v.x*factor,v.y*factor, factor-v.z*factor);
    sphereDetail(3);
    if(rawDepth<treshold)
    {
    float temp_depth = map(rawDepth,0,2047,0,skip);

    point(0,0);
    }

    popMatrix();

    imgDepth_min.set(temp_w/4,j/4,colDepth);
    imgRGB_min.set(temp_w/4,j/4,colRGB);
    }
    }

    translate(0,0,0);

    a += rotate_fact;

    kinect.tilt(deg);
    }

    // These functions come from: http://graphics.stanford.edu/~mdfisher/Kinect.html
    float rawDepthToMeters(int depthValue) {
    if (depthValue < 2047) {
    return (float)(1.0 / ((double)(depthValue) * -0.0030711016 + 3.3309495161));
    }
    return 0.0f;
    }

    PVector depthToWorld(int x, int y, int depthValue) {

    final double fx_d = 1.0 / 5.9421434211923247e+02;
    final double fy_d = 1.0 / 5.9104053696870778e+02;
    final double cx_d = 3.3930780975300314e+02;
    final double cy_d = 2.4273913761751615e+02;

    PVector result = new PVector();
    double depth = depthLookUp[depthValue];//rawDepthToMeters(depthValue);
    result.x = (float)((x – cx_d) * depth * fx_d);
    result.y = (float)((y – cy_d) * depth * fy_d);
    result.z = (float)(depth);
    return result;
    }

    PVector colorToWorld(int x, int y, int depthValue)
    {
    final double fx_rgb = 5.2921508098293293e+02;
    final double fy_rgb = 5.2556393630057437e+02;
    final double cx_rgb = 3.2894272028759258e+02;
    final double cy_rgb = 2.6748068171871557e+02;

    PVector v = depthToWorld(x, y, depthValue);
    v.x = (v.x/9.9984628826577793e-01) – 1.9985242312092553e-02;
    v.y = (v.y/9.9984628826577793e-01);
    v.z = (v.z/9.9984628826577793e-01) – 1.9985242312092553e-02;
    PVector result = new PVector();

    result.x = (float)((v.x*fx_rgb/v.z)+cx_rgb);
    result.y = (float)((v.y*fy_rgb/v.z)+cy_rgb);

    return result;
    }

    void keyPressed()
    {
    if(key == 'w')
    {
    if(deg-37)deg –;
    }

    else if(key == ‘d’)
    {
    rotate_fact += 0.002f;
    }
    else if (key == ‘a’)
    {

    rotate_fact -= 0.002f;
    }
    else if(key==’q')
    {
    if(treshold> 100)treshold -= 10;
    }
    else if(key==’e')
    {
    if(treshold<2047)treshold += 10;
    }
    else if(key=='ù')
    {
    profondeur += 5;
    }
    else if(key =='z')
    {
    profondeur -= 5;
    }
    }

    void stop() {
    kinect.quit();
    super.stop();
    }

    It may not work with any kinect. I just know that it works with mine, but I can't test it with another one. So if it doesn't work with yours, notify me.
    Hope it helps.

  • vali

    thank you,
    i also found a solution. I tried to calculate float to int after the offset-calcualtion.
    I also moved the offset 14 x to left and 16 y to get the depth and RGB congruent.

    int w_rgb = (int(p.x)+14)+(int(p.y)+16)*w;

  • Adri

    Hey Yoann,

    Is there a simply way to draw a vertex mesh, instead of a point cloud? For example with:

    beginShape (TRIANGLE_STRIP);
    vertex (0,0,0);
    endShape ();

    best wishes,

    Adri

  • http://twitter.com/YoannM Yoann M.

    Well, I think it must be possible with the Delaunay triangulation. You should select, like 1 point over 20 on the Point Cloud, or the process will take too long. And try to apply Delaunay’ algorithm.

    Demonstration : http://www.youtube.com/watch?v=vEOmzjImsVc
    Source : http://en.wikipedia.org/wiki/Delaunay_triangulation

    I don’t know if this is playable in real time, but worth the try.

  • Adri

    A quick search gave me this results relating to processing.

    http://www.gvu.gatech.edu/~jarek/demos/Delaunay

    http://www.creativeapplications.net/processing/faceless-void-processing

    I will give it a try. Thanks!

  • http://www.therandomlab.com dasaki

    Hi Daniel,

    I’ve been experimenting with the Kinect’s raw depth conversion to grayscae and depth in meters.
    It seems the 0-2047 raw depth scale isn’t fully usefull due to the minimum (530?) and maximum (1040?) disparity. So mapping the 0-2047 to (for example) 0-255 grayscale (grayscale = 255*raw/2047), is a lost of accuracy. It seems better to do something like: grayscale = ( depth – 530) * 255 / 1040 ( as seen in http://pastebin.com/KzxEDSp1 by someone called “r0sw3l”).

    Here is a little Processing code to plot of raw depth (0-2047) an the corresponding depth in meters (in three different ways seen in the net):

    http://pastebin.com/i0LTgrxp

    You can see above a raw depth of 1040 the meters make no sense.

    Regards,

    David.

  • thomas_d

    Hi all,

    http://forum.processing.org/topic/kinect-library-dlibs-freenect

    (kinect-library, also based on the openkinect-driver, but for windows)

    thomas

  • Gerry Straathof

    Hello. I’v been using your library with processing for a few months now (and it’s a major part of my grad piece) Is there a way to get it to recognize multiple Kinects. We’re going to be using a system with multiple kinects this, and being able to do wireframe mockups in processing to hand to the computer guy will be very useful.

  • cosmo

    hey guys, i am trying to trigger VIDEO files with kinectprocessing. with blob detection depending on the movement i want to trigger a recorded video for every movement. before i start digging into it i would like to know if it is possible. i know i can trigger images to open but im not sure about recorded videos. if any of you guys can help it will be appreciated and any code will be referenced in the project. it is a university project exposed to many recognised artists. 

  • David Sanz

    @686f3be8ca22e76224bbed037d799ac7:disqus 

    It is not difficult to trigger videos in processing. What system are you using (OSX, WIN, LINUX)?  For OSX it is straightforward, see the video examples. For win you will need Winvdig to make it work. For Linux I use the gsvideo library (http://gsvideo.sourceforge.net/).
    More info: http://wiki.processing.org/w/Video_Issues.

  • David Sanz

    @facebook-6420353:disqus 

    Can you please share the steps you took to compile the library under Ubuntu?

  • David Sanz

    @Daniel:twitter  Shiffman

    Hi Daniel,

    I’ve updated the Ubuntu modified version of your wrapper, to make it work with the current version of OpenKinect. Had to change a few lines of the JNI, etc.
    The IR issues are now solved for me. You may want to test the new code in OSX.

    Here is the new processing library compiled in Ubuntu 10.10:
    http://www.4shared.com/file/hBAxxv3m/processing_OpenKinect-libfreen.html

    And here the modified wrapper source and build.sh files (adjust this one for your local files):
    http://www.4shared.com/file/_b04fVFO/processing_OpenKinect-libfreen.html

  • Misan

    This way worked for me: http://fightpc.blogspot.com/2011/05/use-processing-and-kinect-in-ubuntu.html

  • David Sanz

    Ok I reviewed the code and made some changes to make it work with the latest (OpenKinect-libfreenect-4a159f8). See the post and code for details: http://therandomlab.blogspot.com/2011/02/kinect-with-processing-on-ubuntu.html

  • Ventoline

    Did you get anywhere with the mesh experiement? I am interested in this to..

  • Pieterjan Peeters

    Hi, thanks for the code and examples for the kinect, its really helping me to understand how its work because i’m really just a beginner to programming

    I’m Looking for a way to extract the point cloud raw data into a file that can be used in mesh lab, any thoughts as to were i can find a good processing sketch to this ? i found some scripts to install in blender but i just can’t get it to work… :)

    cheers
    PJ

  • Pieterjan Peeters

    Hi, thanks for the code and examples for the kinect, its really helping me to understand how its work because i’m really just a beginner to programming

    I’m Looking for a way to extract the point cloud raw data into a file that can be used in mesh lab, any thoughts as to were i can find a good processing sketch to this ? i found some scripts to install in blender but i just can’t get it to work… :)

    cheers
    PJ

  • Bryce Beamer

    I was wondering if you have had any luck removing the IR glitch.  Do you know the root of the problem or where I might start?

  • Tsnilsen

    Hi, Just starting to play with processing and the kinect sensor, really enjoying messing with the examples, but feel ready to move on.

    Is there any api available for kinect in processing?

  • Tsnilsen

    Hi, Just starting to play with processing and the kinect sensor, really enjoying messing with the examples, but feel ready to move on.

    Is there any api available for kinect in processing?