Skip to content

Commit

Permalink
Added near/far for Kinect2
Browse files Browse the repository at this point in the history
  • Loading branch information
robotconscience committed Apr 30, 2015
1 parent eceb4c3 commit facd421
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/ofxTSPS/libs/ofxTSPS/include/ofxTSPS/source/Kinect2.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ namespace ofxTSPS {
// https://github.com/rickbarraza/KinectV2_Lessons/blob/master/3_MakeRawDepthBrigther/src/testApp.cpp
static vector<unsigned char> depthLookupTable;

if ( nearCached != nearClipping || farCached != farClipping){
depthLookupTable.clear();
}

if ( depthLookupTable.size() == 0){

// IF YOU WANT NEAR TO BE BLACK AND FAR TO BE WHITE, SWITCH THESE
Expand Down Expand Up @@ -85,6 +89,8 @@ namespace ofxTSPS {
}
}
}
nearCached = nearClipping;
farCached = farClipping;
}

ofPixelsRef getPixelsRef(){
Expand Down Expand Up @@ -117,6 +123,7 @@ namespace ofxTSPS {
float nearClipping, farClipping;

protected:
float nearCached, farCached;
ofPixels outputPixels;
bool bDepthInited;
};
Expand Down
11 changes: 11 additions & 0 deletions addons/ofxTSPS/libs/ofxTSPS/src/GuiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@ namespace ofxTSPS {
panel.addToggle("use amplification (video gain)", "USE_AMPLIFICATION", false);
panel.addSlider("amplification amount:", "AMPLIFICATION_AMOUNT", 1, 1, 100, true);

#ifdef TSPS_KINECT2
guiTypeGroup * k2Group = panel.addGroup("kinect settings");
k2Group->setBackgroundColor(148,129,85);
k2Group->setBackgroundSelectColor(148,129,85);
k2Group->seBaseColor(244,136,136);
k2Group->setShowText(false);

panel.addSlider("near threshold:", "K2_NEAR", 30., 0., 5000., false);
panel.addSlider("far threshold:", "K2_FAR", 1000., 0., 5000., false);
#endif

// end setup source panel

// setup sensing panel
Expand Down
8 changes: 8 additions & 0 deletions addons/ofxTSPS/libs/ofxTSPS/src/PeopleTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ namespace ofxTSPS {
// update source
bool bNewFrame = false;
if ( currentSource != NULL && currentSource->isOpen() ){
#ifdef TSPS_KINECT2
if ( currentSource->getType() == CAMERA_KINECT ){
Kinect2 * kRef = dynamic_cast<Kinect2*>(currentSource);
kRef->nearClipping = gui.getValueF("K2_NEAR");
kRef->farClipping = gui.getValueF("K2_FAR");
}
#endif

currentSource->update();
bNewFrame = currentSource->doProcessFrame();
}
Expand Down

0 comments on commit facd421

Please sign in to comment.