summaryrefslogtreecommitdiff
path: root/TRRSS_01_rec/src
diff options
context:
space:
mode:
Diffstat (limited to 'TRRSS_01_rec/src')
-rwxr-xr-xTRRSS_01_rec/src/testApp.cpp58
-rwxr-xr-xTRRSS_01_rec/src/testApp.h7
2 files changed, 52 insertions, 13 deletions
diff --git a/TRRSS_01_rec/src/testApp.cpp b/TRRSS_01_rec/src/testApp.cpp
index 6e8533a..a052ccc 100755
--- a/TRRSS_01_rec/src/testApp.cpp
+++ b/TRRSS_01_rec/src/testApp.cpp
@@ -50,7 +50,7 @@ void unbindTex(ofTexture &tex) {
//--------------------------------------------------------------
void testApp::setup(){
#ifdef NEWAPI
- openNIDevice.setup();//FromXML("openni/config/ofxopenni_config.xml");
+ openNIDevice.setup(false);//FromXML("openni/config/ofxopenni_config.xml");
openNIDevice.setLogLevel(OF_LOG_VERBOSE);
openNIDevice.addDepthGenerator();
openNIDevice.addImageGenerator(); // comment this out
@@ -59,15 +59,21 @@ void testApp::setup(){
openNIDevice.setMirror(true);
openNIDevice.start();
+ openNIDevice.setUseDepthRawPixels(true);
+
+ //openNIDevice.setSafeThreading(true); ?slower and still crashes?
+
openNIDevice.setMaxNumUsers(1);
ofAddListener(openNIDevice.userEvent, this, &testApp::userEvent);
ofxOpenNIUser user;
user.setUseMaskTexture(true);
user.setUsePointCloud(true);
- user.setPointCloudDrawSize(2); // this is the size of the glPoint that will be drawn for the point cloud
- user.setPointCloudResolution(2); // this is the step size between points for the cloud -> eg., this sets it to every second point
+ user.setPointCloudDrawSize(1); // this is the size of the glPoint that will be drawn for the point cloud
+ user.setPointCloudResolution(1); // this is the step size between points for the cloud -> eg., this sets it to every second point
openNIDevice.setBaseUserClass(user);
+
+
#else
recordContext.setup();
recordDepth.setup(&recordContext);
@@ -101,22 +107,50 @@ void testApp::draw(){
#ifdef NEWAPI
ofSetColor(255, 255, 255);
+
+
//openNIDevice.drawDebug(); // draws all generators
//openNIDevice.drawDepth(0, 0);
+
if (guiWin->drawPoints) {
+
+/*
+ glEnable( GL_POINT_SMOOTH );
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ glPointSize( guiWin->pointSize );
+
+ glBegin(GL_POINTS);
+ glColor3f( 1.0f, 1.0f, 1.0f );
+
+
+ //uint16_t *depth=openNIDevice.getDepthRawPixels().getPixels();
+ ofPoint p;
+ for (int i=0;i<640;i+=guiWin->drawStep){
+ for (int j=0;j<480;j+=guiWin->drawStep){
+ p=openNIDevice.cameraToWorld(ofVec2f(i,j));
+ glVertex3f(p.x,p.y,p.z);
+ }
+ }
+*/
+
+
ofPushMatrix();
ofEnableBlendMode(OF_BLENDMODE_ALPHA);
int numUsers = openNIDevice.getNumTrackedUsers();
for (int nID = 0; nID < numUsers; nID++){
- ofxOpenNIUser & user = openNIDevice.getTrackedUser(nID);
- user.drawMask();
- ofPushMatrix();
- ofTranslate((1024/2)-(640/2),(768/2)-(480/2),-500);
- user.drawPointCloud();
- ofPopMatrix();
- }
- ofDisableBlendMode();
- ofPopMatrix();
+ ofxOpenNIUser & user = openNIDevice.getTrackedUser(nID);
+ user.drawMask();
+ ofPushMatrix();
+ ofTranslate((1024/2)-(640/2),(768/2)-(480/2),-500);
+ user.drawPointCloud();
+ ofPopMatrix();
+
+ }
+ ofDisableBlendMode();
+ ofPopMatrix();
+
+
}
else {
openNIDevice.drawImage(0, 0,ofGetWidth(),ofGetHeight());
diff --git a/TRRSS_01_rec/src/testApp.h b/TRRSS_01_rec/src/testApp.h
index 3c5bea6..629ee98 100755
--- a/TRRSS_01_rec/src/testApp.h
+++ b/TRRSS_01_rec/src/testApp.h
@@ -40,6 +40,7 @@ class testApp : public ofxFensterListener{
#ifdef NEWAPI
ofxOpenNI openNIDevice;
void userEvent(ofxOpenNIUserEvent & event);
+
#else
ofxOpenNIContext recordContext;
ofxDepthGenerator recordDepth;
@@ -61,6 +62,8 @@ class guiWindow: public ofxFensterListener{
ofxParameter<float> distMin;
ofxFloatSlider dMax;
ofxParameter<float> distMax;
+ ofxIntSlider dStep;
+ ofxParameter<int> drawStep;
ofxToggle dPoints;
ofxParameter<bool> drawPoints;
ofxFloatSlider pSize;
@@ -75,10 +78,12 @@ class guiWindow: public ofxFensterListener{
gui.add(dMin.setup("min distance",distMin,0,5000,255));
distMax=2000;
gui.add(dMax.setup("max distance",distMax,0,5000,255));
+ drawStep=2;
+ gui.add(dStep.setup("draw step",drawStep,1,32,255));
drawPoints=false;
gui.add(dPoints.setup("draw points",drawPoints));
pointSize=2.0;
- gui.add(pSize.setup("point size",pointSize,1.0,20.0,255));
+ gui.add(pSize.setup("point size",pointSize,0.0,20.0,255));
insideOut=false;
gui.add(iOut.setup("inside out",drawPoints));
}