(probably stupid) PImage question
in
Programming Questions
•
1 years ago
Hi Guys,
Sorry if this is something idiotic I didn't get, but I'm stuck on it for a day now. So in this (overly simplified) version of my code, I'm trying to calculate the difference between the current depth image of a kinect, and the image taken when the program started. So it goes:
public void setup() {
[lots of useless stuff]
average = createImage(640,480,RGB);
difference=createImage(640,480,RGB);
average.pixels = kinect.getDepthImage().pixels;
}
public void draw() {
depth = kinect.getDepthImage();
depth.updatePixels();
for(int x=0;x<width;x++){
for(int y=0;y<height;y++){
int loc = x + y * depth.width;
difference.pixels[loc] = abs(average.pixels[loc]-depth.pixels[loc])>0?255:0;
}
}
difference.updatePixels();
}
I'm displaying all of the images, but the thing is that the value of the pixels of the "average" image is ALWAYS identical to the current depth image, although the image is not changing on the display. And so the "difference" image is always null.
Do you have an idea what can be doing this? I'm not writing in the "average" image anywhere else in my code, only reading.
Thanks in advance for any help!
Cheers.
Sorry if this is something idiotic I didn't get, but I'm stuck on it for a day now. So in this (overly simplified) version of my code, I'm trying to calculate the difference between the current depth image of a kinect, and the image taken when the program started. So it goes:
public void setup() {
[lots of useless stuff]
average = createImage(640,480,RGB);
difference=createImage(640,480,RGB);
average.pixels = kinect.getDepthImage().pixels;
}
public void draw() {
depth = kinect.getDepthImage();
depth.updatePixels();
for(int x=0;x<width;x++){
for(int y=0;y<height;y++){
int loc = x + y * depth.width;
difference.pixels[loc] = abs(average.pixels[loc]-depth.pixels[loc])>0?255:0;
}
}
difference.updatePixels();
}
I'm displaying all of the images, but the thing is that the value of the pixels of the "average" image is ALWAYS identical to the current depth image, although the image is not changing on the display. And so the "difference" image is always null.
Do you have an idea what can be doing this? I'm not writing in the "average" image anywhere else in my code, only reading.
Thanks in advance for any help!
Cheers.
1