ofxBlobTracker + Kinect

I’m trying to run ofXBlobTracker with Kinect. I took a look at the example that comes with the addon, which uses the laptop camera. When I tried to translate the same example using kinect I ran into an error. Here’s my code:

ofApp.h

#include "ofMain.h"
#include "ofxOpenCv.h"
#include "ofxBlobTracker.h"
#include "ofxKinect.h"

class ofApp : public ofBaseApp{

public:
void setup();
void update();
void draw();

void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);

void blobAdded(ofxBlob &_blob);
void blobMoved(ofxBlob &_blob);
void blobDeleted(ofxBlob &_blob);

ofxKinect kinect;

ofxCvColorImage colorImg;

ofxCvGrayscaleImage grayImage;
ofxBlobTracker blobTracker;

int threshold;

};

ofApp.cpp:

void ofApp::setup(){

ofSetLogLevel(OF_LOG_VERBOSE);

kinect.setRegistration(true);
kinect.init();
kinect.open();


colorImg.allocate(kinect.width , kinect.height);
grayImage.allocate(kinect.width, kinect.height);

threshold = 80;

ofAddListener(blobTracker.blobAdded, this, &ofApp::blobAdded);
ofAddListener(blobTracker.blobMoved, this, &ofApp::blobMoved);
ofAddListener(blobTracker.blobDeleted, this, &ofApp::blobDeleted);

}

void ofApp::update(){

ofBackground(100, 100, 100);    

kinect.update();

if( kinect.isFrameNew()){
    
    colorImg.setFromPixels(kinect.getPixels(),kinect.width, kinect.height);
    
    grayImage = colorImg;
    blobTracker.update(grayImage, threshold);
    
 }    
}

void ofApp::draw(){

ofSetHexColor(0xffffff);
colorImg.draw(420, 320, 400, 300);
grayImage.draw(10, 320, 400, 300);


blobTracker.draw(420, 320, 400, 300);


for (int i = 0; blobTracker.size(); i++){
    
    ofFill();
    ofSetColor(255,0,0);
    ofCircle(blobTracker[i].centroid.x * ofGetWidth(),
             blobTracker[i].centroid.y * ofGetHeight(),
             10);
    ofSetColor(0);
    ofDrawBitmapString(ofToString( blobTracker[i].id ),
                       blobTracker[i].centroid.x * ofGetWidth(),
                       blobTracker[i].centroid.y * ofGetHeight());
 }
}

When I compile I get the following error:

blobtracker_kinectDebug(15405,0xa0d2f1a8) malloc: *** error for object 0x4822600: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Thread 1: signal SIGABRT.

Any ideas? Thanks in advance.

For some reason, when I pass the grayImage to the blobTracker update doesn’t like it.

blobTracker.update(grayImage, threshold);

very late but how did you go with this?