ofTheo / ofxKinect

legacy openFrameworks wrapper for the xbox kinect (OF pre-0.8.0+ only) - ofxKinect is now included and is being maintained in OF releases
MIT License
540 stars 105 forks source link

getCalibratedRGBPixels not correct?? #34

Closed ofTheo closed 12 years ago

ofTheo commented 13 years ago

See http://theo.tw/i/__calibratedpixels-issue.png Looks like the math is doing the opposite.

kylemcdonald commented 13 years ago

did this just break in a recent revision, or have you noticed this before?

ofTheo commented 13 years ago

this is with the latest version.
I hadn't checked it sense the new ofxKinectCall files were added.

Here is some sample code for reproducing the issue - move your mouse to compare the two images.

//--------------------------------------------------------------
void testApp::setup()
{
    //kinect.init(true);  //shows infrared image
    kinect.init();
    kinect.setVerbose(true);
    kinect.open();

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

    nearThreshold = 50;
    farThreshold  = 180;
    bThreshWithOpenCV = true;

    ofSetFrameRate(60);

    drawPC = false;
}

//--------------------------------------------------------------
void testApp::update()
{
    ofBackground(100, 100, 100);
    kinect.update();

    grayImage.setFromPixels(kinect.getDepthPixels(), kinect.width, kinect.height);
    colorImg.setFromPixels(kinect.getCalibratedRGBPixels(), kinect.width, kinect.height);
}

//--------------------------------------------------------------
void testApp::draw(){

    ofEnableAlphaBlending();

    ofSetColor(255, 255, 255, 255); 
    colorImg.draw(0, 0);

    ofSetColor(255, 255, 255, ((float)mouseX/ofGetWidth()) * 255.0);    
    grayImage.draw(0,0);

    ofSetColor(255, 255, 255);
    ofDrawBitmapString("accel is: " + ofToString(kinect.getMksAccel().x, 2) + " / " 
                                    + ofToString(kinect.getMksAccel().y, 2) + " / "
                                    + ofToString(kinect.getMksAccel().z, 2), 20, 658 );

    char reportStr[1024];
    sprintf(reportStr, "using opencv threshold = %i (press spacebar)\nset near threshold %i (press: + -)\nset far threshold %i (press: < >) num blobs found %i, fps: %f",bThreshWithOpenCV, nearThreshold, farThreshold, contourFinder.nBlobs, ofGetFrameRate());
    ofDrawBitmapString(reportStr, 20, 690);
    ofDrawBitmapString("tilt angle: " + ofToString(angle),20,670);
    ofDrawBitmapString("press p to switch between images and point cloud",20,680);
}
kylemcdonald commented 13 years ago

yeah i definitely see this.

http://oi53.tinypic.com/i43g5t.jpg

arturo is the one who added the calibrated color stuff in the first place i think so he's probably going to be able to solve this more easily.

i know he's been working a lot with calibrating the depth and color images, but i thought this part was already solved... so i'm not sure what's going on.

ofTheo commented 13 years ago

cool thanks for the sanity check! :)

ofTheo commented 13 years ago

just talked to arturo ( who is not able to connect to github ) it seems this function is meant for the particle demo and not for correctly mapping the depth image to the color image which makes sense now that I think about it.

might still need testing for the particle demo as I think Kyle's current code renders the particles in b&w.

danomatika commented 13 years ago

What's the status on this?

danomatika commented 13 years ago

It seems the calibration numbers vary slightly form Kinect to Kinect so the numbers we have now are not exactly perfect. We would need to provide a method to generate a calibration file using a pattern like openCV.

See here for an example: http://nicolas.burrus.name/index.php/Research/KinectRgbDemoV4?from=Research.KinectRgbDemoV2#tocLink10

danomatika commented 12 years ago

Check the develop branch to try the new libfreenect which includes calibration ... it's working!

ofTheo commented 12 years ago

awesome - when can we merge the current develop into master? btw the multi kinect stuff works great dan - thanks for hooking that up.