Hi, I want to isolate the user’s silhoutte contour using ofxNI2 (OpenNI2, NiTE2).
ofxNI2 , OpenNI2 and NiTE2 examples are working fine.
Ubuntu 12.04 64 bits
oF 0.8.4
I did read a post about doing the same using ofxOpenNI (OpenNI), but I want to use OpenNI2 advantages over OpenNI.
If anyone has experienced with this addon maybe could help me.
As I understood getUserMap() has the information I need: any value different from 0 is the user ID and otherwise is the background.
I added this function inline nite::UserMap getUserMap() {return user_map;}
to the ofxNiTE2::UserTracker class to get the user map (I didn’t see where to get it in the addon)
I noticed that depth.getWidth() = userTracker->getUserMap().getWidth and the it’s the same for the Height, which I think it’s right.
The core code is posted beolw. As a result I get a black screen which it shouldn’t happend, but *userPixel is always 0 (background) that’s the reason for the black screen.
I appreciate any hint of what I am doing wrong. Thanks!
//variables initialized/ within setup()
ofImage img;
ofxNiTE2::UserTracker *userTracker
//variable that correspond to the object
ofxNI2::DepthStream depth;
void testApp::update()
{
const short int *userPixels = (userTracker->getUserMap()).getPixels();
ofShortPixels &depthPixels = depth.getPixelsRef();
long total = depthPixels.getWidth()*depthPixels.getHeight();
unsigned char maskPixels[total];
//userPixels has more elements than the "total" value calculated above.
for (long i =0 ;i < total; i++) {
if (depthPixels[i] != 0){
if (*userPixels != 0) {
maskPixels[i] = 255;
else
maskPixels[i] = 0;
userPixels++;
}
}
img.setFromPixels(maskPixels,320,240,OF_IMAGE_GRAYSCALE);
img.update();
device->update();
}
//--------------------------------------------------------------
void testApp::draw()
{
//color.draw();
img.draw(0,0)
}