diff options
| -rw-r--r-- | TRRSS_01_rec/bin/data/verdana.ttf | bin | 0 -> 171792 bytes | |||
| -rwxr-xr-x | TRRSS_01_rec/src/testApp.cpp | 2 | ||||
| -rw-r--r-- | TRSS_02_rec/bin/data/verdana.ttf | bin | 0 -> 171792 bytes | |||
| -rw-r--r-- | TRSS_02_rec/src/testApp.cpp | 106 | ||||
| -rw-r--r-- | TRSS_02_rec/src/testApp.h | 10 |
5 files changed, 101 insertions, 17 deletions
diff --git a/TRRSS_01_rec/bin/data/verdana.ttf b/TRRSS_01_rec/bin/data/verdana.ttf Binary files differnew file mode 100644 index 0000000..8f25a64 --- /dev/null +++ b/TRRSS_01_rec/bin/data/verdana.ttf diff --git a/TRRSS_01_rec/src/testApp.cpp b/TRRSS_01_rec/src/testApp.cpp index 555118a..82affcb 100755 --- a/TRRSS_01_rec/src/testApp.cpp +++ b/TRRSS_01_rec/src/testApp.cpp @@ -363,7 +363,7 @@ void testApp::keyPressed(int key){ whichImage=&recordImage; } break; - } + } } //-------------------------------------------------------------- diff --git a/TRSS_02_rec/bin/data/verdana.ttf b/TRSS_02_rec/bin/data/verdana.ttf Binary files differnew file mode 100644 index 0000000..8f25a64 --- /dev/null +++ b/TRSS_02_rec/bin/data/verdana.ttf diff --git a/TRSS_02_rec/src/testApp.cpp b/TRSS_02_rec/src/testApp.cpp index 20954ed..5aad050 100644 --- a/TRSS_02_rec/src/testApp.cpp +++ b/TRSS_02_rec/src/testApp.cpp @@ -5,25 +5,56 @@ void testApp::setup() { ofSetLogLevel(OF_LOG_NOTICE); - numDevices = openNIDevices[0].getNumDevices(); + numDevices = openNIRecorders[0].getNumDevices(); for (int deviceID = 0; deviceID < numDevices; deviceID++){ - //openNIDevices[deviceID].setLogLevel(OF_LOG_VERBOSE); - openNIDevices[deviceID].setup(); - openNIDevices[deviceID].addDepthGenerator(); - openNIDevices[deviceID].addImageGenerator(); - openNIDevices[deviceID].setRegister(true); // this registers all the image pixels to the depth pixels - openNIDevices[deviceID].setMirror(true); // flips the image and depth sensors - openNIDevices[deviceID].start(); + //openNIRecorders[deviceID].setLogLevel(OF_LOG_VERBOSE); + openNIRecorders[deviceID].setup(); + openNIRecorders[deviceID].addDepthGenerator(); + openNIRecorders[deviceID].addImageGenerator(); + openNIRecorders[deviceID].setRegister(true); // this registers all the image pixels to the depth pixels + openNIRecorders[deviceID].setMirror(true); // flips the image and depth sensors + openNIRecorders[deviceID].start(); + + openNIPlayers[deviceID].setup(); + openNIPlayers[deviceID].start(); + + filenames[deviceID]=""; } + isLive=true; + isRecording=false; + verdana.loadFont(ofToDataPath("verdana.ttf"), 24); } + +string testApp::generateFileName(int cam) { + + string _root = "kinectRecord_"; + + string _timestamp = ofToString(ofGetDay()) + + ofToString(ofGetMonth()) + + ofToString(ofGetYear()) + + ofToString(ofGetHours()) + + ofToString(ofGetMinutes()) + + ofToString(ofGetSeconds()); + + string _filename = (_root + ofToString(cam)+"_"+_timestamp + ".oni"); + + return _filename; + +} + //-------------------------------------------------------------- void testApp::update(){ for (int deviceID = 0; deviceID < numDevices; deviceID++){ - openNIDevices[deviceID].update(); + if (isLive) { + openNIRecorders[deviceID].update(); + } + else { + openNIPlayers[deviceID].update(); + } } } @@ -35,9 +66,14 @@ void testApp::draw(){ for (int deviceID = 0; deviceID < numDevices; deviceID++){ ofTranslate(0, deviceID * 480); - openNIDevices[deviceID].drawDebug(); // draws all generators - //openNIDevices[deviceID].drawDepth(0, 0); - //openNIDevices[deviceID].drawImage(640, 0); + if (isLive) { + openNIRecorders[deviceID].drawDebug(); // draws all generators + //openNIRecorders[deviceID].drawDepth(0, 0); + //openNIRecorders[deviceID].drawImage(640, 0); + } + else { + openNIPlayers[deviceID].drawDebug(); + } } ofPopMatrix(); @@ -50,26 +86,66 @@ void testApp::draw(){ //-------------------------------------------------------------- void testApp::exit(){ for (int deviceID = 0; deviceID < numDevices; deviceID++){ - openNIDevices[deviceID].stop(); + openNIRecorders[deviceID].stop(); } } //-------------------------------------------------------------- void testApp::keyPressed(int key){ switch (key) { + case 's': + case 'S': + if (isRecording) { + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIRecorders[deviceID].stopRecording(); + } + isRecording = false; + break; + } else { + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + filenames[deviceID]=generateFileName(deviceID); + openNIRecorders[deviceID].startRecording(generateFileName(deviceID)); + } + isRecording = true; + break; + } + break; + case 'p': + case 'P': + if (filenames[0] != "" && !isRecording && isLive) { + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIRecorders[deviceID].stopRecording(); + } + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIPlayers[deviceID].startPlayer(filenames[deviceID]); + } + isLive = false; + //whichUser=&playUser; + //whichImage=&playImage; + } else { + isLive = true; + //whichUser=&recordUser; + //whichImage=&recordImage; + } + break; + } + + /* why do this? + switch (key) { case 't': for (int deviceID = 0; deviceID < numDevices; deviceID++){ - openNIDevices[deviceID].toggleRegister(); + openNIRecorders[deviceID].toggleRegister(); } break; case 'x': for (int deviceID = 0; deviceID < numDevices; deviceID++){ - openNIDevices[deviceID].stop(); + openNIRecorders[deviceID].stop(); } break; default: break; } + */ } //-------------------------------------------------------------- diff --git a/TRSS_02_rec/src/testApp.h b/TRSS_02_rec/src/testApp.h index 715e406..16bba9a 100644 --- a/TRSS_02_rec/src/testApp.h +++ b/TRSS_02_rec/src/testApp.h @@ -21,11 +21,19 @@ public: void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); + string generateFileName(int cam); int numDevices; - ofxOpenNI openNIDevices[MAX_DEVICES]; + ofxOpenNI openNIRecorders[MAX_DEVICES]; + ofxOpenNI openNIPlayers[MAX_DEVICES]; + string filenames[MAX_DEVICES]; + + bool isLive, isRecording; ofTrueTypeFont verdana; + + ofSoundPlayer startSound; + ofSoundPlayer stopSound; }; |
