Kinect depthImage, using own color schema trouble, library dLibs

edited April 2015 in Kinect

Hi, I am currently using the 'basics frame' file from the dLibs library for Kinect from Thomas Diewald. I use the black/white depth image from the kinect to read the brightness of each pixels. I than assign a color depending on the brightness of that pixel to create my own color map. See image 1.

However, once a while -every 8 sec or so- a blue overlay is shown, see Image 2. I think this blue overlay has a relation with the frameRate. I have no clue why the sketch is showing this blue overlay. Does somebody knows if this has to do something with my current code or it is something that has a relation with the library?

Thank you in advance.

The code:

import dLibs.freenect.toolbox.*;
import dLibs.freenect.constants.*;
import dLibs.freenect.interfaces.*;
import dLibs.freenect.*;

Kinect kinect_;                     
KinectFrameDepth kinect_depth_;     

int kinectFrame_size_x = VIDEO_FORMAT._RGB_.getWidth();   /
int kinectFrame_size_y = VIDEO_FORMAT._RGB_.getHeight(); 

PImage video_frame_, depth_frame_;  

boolean setupDone = false;

void setup(){
  frameRate(10);
  size(kinectFrame_size_x, kinectFrame_size_y);  
  kinect_ = new Kinect(0);  

  kinect_depth_ = new KinectFrameDepth(DEPTH_FORMAT._11BIT_);         
  kinect_depth_.connect(kinect_); 
  kinect_depth_.setColorMode(0);
  kinect_depth_.setFrameRate(10);

  depth_frame_ = createImage(DEPTH_FORMAT._11BIT_.getWidth(), DEPTH_FORMAT._11BIT_   .getHeight(), RGB);
  depth_frame_.loadPixels();
}

void draw(){
  assignPixels( depth_frame_, kinect_depth_);
  image(depth_frame_, 0,0);
}

  void assignPixels(PImage img, KinectFrameDepth kinect_dev){ 
  color[] pxls = kinect_dev.getRawDepth();  
  int amountOfPixels = 640*480;
  for(int i = 0;i<amountOfPixels;i++){
    float value = brightness(pxls[i]);
    if(value <= 80){
      pxls[i] = color(104, 151, 115); 
    } else if( value <= 120 ){    
      pxls[i] = color(113, 172, 104);       
    } else if( value <= 180 ){    
      pxls[i] = color(216, 224, 123);       
    } else if( value <= 240 ){    
      pxls[i] = color(254, 125, 86);       
    } else{
      pxls[i] = color(254, 175, 96);
    } 
  }
  img.pixels = pxls;
  img.updatePixels();
}

void dispose(){
  Kinect.shutDown(); 
  super.dispose();
}

Image 1 Image 2

Sign In or Register to comment.