Quantcast
Channel: Kinect - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 530

Shape primitive flickering while multithreading

$
0
0

Hello everyone!

First time posting so a little bit nervous :-)

The thing is that I'm doing an application with kinect and my first approach was to have both depth detection/processing and drawing in the same thread. Worked fine but sometimes it draws a bit slow.

Now I moved the Kinect detection/processing part to another thread. This has the typical loop of going through the kinect.getRawDepth() array and draw in another PImage the pixels which are enough close to the camera. So I'm doing ther pixel manipulation etc. The problem is that since I did that, the primitive shapes drawed in the main loop are flickering like hell. This only happens with primitives, pictures, images are totally fine.

Also, if I comment only the part of the for loop, everything is fine. Any ideas why this is happening? How to solving it? Thank you very much in advance!

This is the code of run() inside thread:

void run(){
  while(true){
    if(!calibrating){
      raw_depths = kinect.getRawDepth();
      for (int i = 0; i < raw_depths.length; i++) {
        if(raw_depths[i] > LIMIT) depth_image.pixels[i] = color(0);
        else depth_image.pixels[i] = color(255);
      }

      depth_image.updatePixels();

      opencv.loadImage(depth_image);
      opencv.threshold(ERODE_THR);
      opencv.erode();
      depth_image = opencv.getSnapshot();
      // Compute BLOBS
      theBlobDetection.computeBlobs(depth_image.pixels);
    }
  }
}

Viewing all articles
Browse latest Browse all 530

Trending Articles