@Gallo wrote:
hello,
My purpose is to use a kinect to grab an RGB image. And from the depth image, create a mask to keep only an object on the front.
i really don't know how to achieve this but here is the solution that seems logical to me :
From the depth image i apply some threshold and use it to change the alpha of the RGB image... i hope i am making myself clear here... but the purpose here is to make some pixels transparent (basically the background) and keep only the object on the front.
// update() if (kinect.isFrameNew()) { ofPixels depthImage; depthImage = kinect.getDepthPixels(); kinectRGB = kinect.getPixels(); for (int y = 0; y < depthImage.getHeight(); y++) { for (int x = 0; x < depthImage.getWidth(); x++) { ofColor c = depthImage.getColor(x, y); if (c.getBrightness() > nearClip && c.getBrightness() < farClip) { ofColor newColor(kinectRGB.getColor(x, y)); newColor.a = 255; kinectRGB.setColor(x, y, newColor); } else { ofColor newColor(kinectRGB.getColor(x, y)); newColor.a = 0; kinectRGB.setColor(x, y, newColor); } } } kinectRGB.update(); }
then
// draw() compo.begin(); kinectRGB.draw(0, 0); compo.end();
where
// compo is an FBO compo.allocate(640, 480, GL_RGBA); compo.begin(); ofClear(0); compo.end(); // kinectRGB is an ofImage kinectRGB.allocate(640, 480, OF_IMAGE_COLOR_ALPHA);
it doesn't seem to work, i only end up with the full RGB image...
Is it the good way to go ?
Does setting alpha for pixels creates image transparency ?
thanks a lot
Posts: 9
Participants: 2