OpenNI skeleton tracks only once each run


#1

Hey there.

I understand OpenNI is a bit out of date. But did’t find a better way for skeleton tracking.
After a few painful days, finally managed to get Kinect work on mac with Openframeworks(OF0.9.8, High Sierra 10.13.4) Didnt succeed with OF 0.10

The hand tracking is neat. Skeleton tracking is working, but the issue I am having is every time I go out of the picture, I cant be redetected when I go back. The detection only gives one shot for each run. This is a real pain for me, I have to rerun the app if I need to change the user. But the hand tracking is always there, even if I go to take a piss and come back.

I assume I have something to do with MaxNumUsers or getNumTrackedUsers… But did’t work out.

Can someone please help on this?
Thanks so much.

Or any better solution for Head Tracking? I know OpenCV would do that job, but I need it to work in dark and also a wider detecting range is preferred.


#2

Hi,
as you correcly say, OpenNI is super outdated. I have not used it on a mac for a long while, and even I dont remember how to fix the problems you are facing, although I can recall that I had to go through those at some point.
My advice to you is to run Windows and use the kinect sdk. it runs much better than openNi, specially if you use the kinect v2. OpenFrameworks runs very nicely with VisualStudio too.
If you insist on using OpenNi, there are several addons for it, as well as the openNi and Nite versions. Make sure you have the newest ones. as for the addons I remember that ofxNI2 was really good. check out in ofxaddons.com for all the available addons


#3

Thanks so much, man.

Got some USB3 controller issues with windows as well, the kinect V2 keeps switching on and off…
So I moved back to Mac and Kinect V1.

I am trying to install ofxNI2 now,
didn’t really understand the readme,
Add to Run Script

cp -R ../../../addons/ofxNI2/libs/OpenNI2/lib/osx/ "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/";
cp -R ../../../addons/ofxNI2/libs/NiTE2/lib/osx/ "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/";

Uncomment

//#define HAVE_NITE2

in ofxNI2.h to use NiTE2.

Just feel the all kinect things are old, how should people do tracking in these days?


#4

well yes. it is old stuff.
add to run script stuff you should add it to the xcode project configuration. clic on the xcode right pane, above the project files there is a blue icon with the project name. clic on it. From the main panel select “build Phases”. There is a plus sign, clic on it and choose to add a new run script phase. There you should paste thaat stuff,


#5

I’ve been keeping ofxOpenNI working in my fork: https://github.com/wouterverweirder/ofxOpenNI

Been using it with openframeworks 0.10.0 on OSX Mojave.

  1. Add it to your project with the projectgenerator
  2. copy the contents of copy_contents_to_data_folder to your data folder.

No need to add extra build scripts.


#6

Hey Wouter,

Yours is so cool, so easy to add and build.
But I still have the same issue, the first detection is instant.
But once I lost my detection, can not be redetected.

Could it be something wrong with my src code?

Here is my ofApp.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

    ofBackground(0);
    
    kinect.setup();
    kinect.setRegister(true);
    kinect.setMirror(true);
    kinect.addDepthGenerator();
    kinect.addUserGenerator();
    
    kinect.start();
    mode = false;
}

//--------------------------------------------------------------
void ofApp::update(){

    kinect.update();
    
}

//--------------------------------------------------------------
void ofApp::draw(){
    
    if(!mode){
        ofSetColor(255, 0, 0);
        ofDrawCircle(50,50, 10);
    }else{
        ofSetColor(0, 255, 0);
        ofDrawCircle(50, 50, 10);
    }
    
    
    ofPushMatrix();
    ofTranslate(200, 50, - 100);
    
    if(kinect.getNumTrackedUsers() > 0 ){
        
        ofxOpenNIUser user = kinect.getTrackedUser(0);
    
       ofSetColor(255);
        
        for(int i = 0; i < user.getNumLimbs(); i ++){
        
            ofxOpenNILimb limb = user.getLimb((enum Limb) i);
        
            if( limb.isFound()){
            
                float x1 = limb.getStartJoint().getProjectivePosition().x;
                float y1 = limb.getStartJoint().getProjectivePosition().y;
               float x2 = limb.getEndJoint().getProjectivePosition().x;
                float y2 = limb.getEndJoint().getProjectivePosition().y;
                ofDrawLine(x1, y1, x2, y2);
                
            }
        }
    
        ofVec2f pos;
        
        for( int i = 0 ; i < user.getNumJoints(); i ++){
            
            ofxOpenNIJoint joint = user.getJoint((enum Joint)i);
            
            if(joint.isFound()){
                
                mode = true;
                ofSetColor(0, 255, 0, 100  );
                float x = joint.getProjectivePosition().x;
                float y = joint.getProjectivePosition().y;
                
                pos.set(x, y);
                ofDrawCircle(pos.x, pos.y, 10);
                
            }else{
                mode = false;
            }
        }
        
    }
    ofPopMatrix();
}

#7

Hey,
Thanks so much., I’ve got it built successfully. But I guess it is because the library is too old or something, no picture is showing up…

Got some information from console

/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Common/ChunkCompression.cpp:50: Error: unsupported compressor 8

/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Exceptions.plist’

/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Common/ChunkCompression.cpp:50: Error: unsupported compressor 8

/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/AppExceptions.bundle/Exceptions.plist’

Could not find data file ./NiTE2/s.dat

current working directory = /Users/bian/Documents/of_v0.9.8_osx_release/apps/myApps/NI2test/bin

[ error ] ofxNiTE2:

[ error ] ofPixels: image type not supported

[ error ] ofPixels: image type not supported


#8

Hi, those are related to the file system. I dont use High Sierra so I cant tell. But certainly you are missing the ./NiTE2/s.dat file. I think that that one should be in the same directory as the executable, which I guess is /Users/bian/Documents/of_v0.9.8_osx_release/apps/myApps/NI2test/bin/NI2test.app/Contents/MacOS/