Permalink
Browse files

ProCamSample code for libdc+edsdk. gray code generator in shared code…

…. scene.h was missing from the repo.
  • Loading branch information...
1 parent 5eeff67 commit ca27d00130cc630fa5a6b44443441cfba494e2b1 @kylemcdonald kylemcdonald committed Nov 2, 2011
Oops, something went wrong.
@@ -0,0 +1,9 @@
+//THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
+//THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
+OF_PATH = ../../..
+
+//THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
+#include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
+
+OTHER_LDFLAGS = $(OF_CORE_LIBS)
+HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.openFrameworks</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
@@ -0,0 +1,9 @@
+#include "testApp.h"
+#include "ofAppGlutWindow.h"
+
+int main() {
+ ofAppGlutWindow window;
+ //ofSetupOpenGL(&window, testApp::tw * 2, testApp::th, OF_FULLSCREEN);
+ ofSetupOpenGL(&window, testApp::tw, testApp::th, OF_FULLSCREEN);
+ ofRunApp(new testApp());
+}
@@ -0,0 +1,105 @@
+#include "testApp.h"
+
+#include "GrayCodeGenerator.h"
+GrayCodeGenerator generator;
+bool capturing = false;
+int totalProjectors = 1;
+int totalDirection = 2;
+int totalInverse = 2;
+
+// every combination of these four properties
+// for a total of: 10x2x2x2 = 80 images
+int projector = 0; // 0-1, 2 values
+int direction = 0; // false/true, 2 values
+int inverse = 0; // false/true, 2 values
+int pattern = 0; // 0-9, 10 values
+
+string curDirectory;
+long bufferTime = 100;
+bool needToCapture = false;
+long captureTime = 0;
+
+void generate() {
+ generator.setSize(testApp::tw, testApp::th);
+ generator.setOrientation(direction == 0 ? PatternGenerator::VERTICAL : PatternGenerator::HORIZONTAL);
+ generator.setInverse(inverse == 0);
+ generator.generate();
+ stringstream dirStr;
+ dirStr <<
+ (projector == 0 ? "left/" : "right/") <<
+ (direction == 0 ? "vertical/" : "horizontal/") <<
+ (inverse == 0 ? "inverse/" : "normal/");
+ curDirectory = dirStr.str();
+ ofDirectory::createDirectory(curDirectory, true, true);
+}
+
+bool nextState() {
+ pattern++;
+ if(pattern == generator.size()) {
+ pattern = 0;
+ inverse++;
+ if(inverse == totalInverse) {
+ inverse = 0;
+ direction++;
+ if(direction == totalDirection) {
+ direction = 0;
+ projector++;
+ if(projector == totalProjectors) {
+ projector = 0;
+ return false;
+ }
+ }
+ }
+ generate();
+ }
+ return true;
+}
+
+void testApp::setup() {
+ ofSetVerticalSync(true);
+ ofHideCursor();
+ ofSetDataPathRoot("../../../../../SharedData/");
+ ofSetLogLevel(OF_LOG_VERBOSE);
+ camera.setup();
+ generate();
+}
+
+void testApp::update() {
+ if(!capturing) {
+ camera.update();
+ }
+ if(camera.isPhotoNew()) {
+ camera.savePhoto(curDirectory + ofToString(pattern) + ".jpg");
+ if(nextState()) {
+ captureTime = ofGetElapsedTimeMillis();
+ needToCapture = true;
+ } else {
+ capturing = false;
+ }
+ }
+}
+
+void testApp::draw() {
+ ofBackground(0);
+ generator.get(pattern).draw(projector * tw, 0);
+ if(!capturing) {
+ ofPushMatrix();
+ ofScale(.25, .25);
+ camera.draw(0, 0);
+ ofPopMatrix();
+ }
+ if(needToCapture && (ofGetElapsedTimeMillis() - captureTime) > bufferTime) {
+ camera.takePhoto();
+ needToCapture = false;
+ }
+}
+
+void testApp::keyPressed(int key) {
+ if(key == ' ') {
+ camera.takePhoto();
+ capturing = true;
+ }
+ if(key == 'f') {
+ ofToggleFullscreen();
+ }
+}
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "ofMain.h"
+
+#include "ofxEdsdk.h"
+
+class testApp : public ofBaseApp {
+public:
+ void setup();
+ void update();
+ void draw();
+ void keyPressed(int key);
+
+ const static int tw = 1024;
+ const static int th = 768;
+
+ ofxEdsdk::Camera camera;
+};
@@ -0,0 +1,9 @@
+//THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
+//THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
+OF_PATH = ../../..
+
+//THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
+#include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
+
+OTHER_LDFLAGS = $(OF_CORE_LIBS)
+HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
Oops, something went wrong.
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.openFrameworks</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
@@ -0,0 +1,8 @@
+#include "testApp.h"
+#include "ofAppGlutWindow.h"
+
+int main() {
+ ofAppGlutWindow window;
+ ofSetupOpenGL(&window, testApp::tw * 2, testApp::th, OF_FULLSCREEN);
+ ofRunApp(new testApp());
+}
@@ -0,0 +1,118 @@
+#include "testApp.h"
+
+#include "GrayCodeGenerator.h"
+GrayCodeGenerator generator;
+bool capturing = false;
+int totalProjectors = 1;
+int totalDirection = 2;
+int totalInverse = 2;
+
+// every combination of these four properties
+// for a total of: 10x2x2x2 = 80 images
+int projector = 0;
+int direction = 0;
+int inverse = 0;
+int pattern = 0;
+
+string curDirectory;
+long bufferTime = 500;
+bool needToCapture = false;
+unsigned long captureTime = 0;
+
+void generate() {
+ generator.setSize(testApp::tw, testApp::th);
+ generator.setOrientation(direction == 0 ? PatternGenerator::VERTICAL : PatternGenerator::HORIZONTAL);
+ generator.setInverse(inverse == 0);
+ generator.generate();
+ stringstream dirStr;
+ dirStr <<
+ (projector == 0 ? "left/" : "right/") <<
+ (direction == 0 ? "vertical/" : "horizontal/") <<
+ (inverse == 0 ? "inverse/" : "normal/");
+ curDirectory = dirStr.str();
+ ofDirectory::createDirectory(curDirectory, true, true);
+}
+
+bool nextState() {
+ pattern++;
+ if(pattern == generator.size()) {
+ pattern = 0;
+ inverse++;
+ if(inverse == totalInverse) {
+ inverse = 0;
+ direction++;
+ if(direction == totalDirection) {
+ direction = 0;
+ projector++;
+ if(projector == totalProjectors) {
+ projector = 0;
+ return false;
+ }
+ }
+ }
+ generate();
+ }
+ return true;
+}
+
+void testApp::setup() {
+ ofSetVerticalSync(true);
+ ofHideCursor();
+ //ofSetDataPathRoot("../../../../../SharedData/");
+ ofSetLogLevel(OF_LOG_VERBOSE);
+
+ camera.setup();
+ camera.setBrightness(0);
+ camera.setGain(0);
+ camera.setExposure(1);
+ camera.setGammaAbs(1);
+ camera.setShutter(1);
+ camera.printFeatures();
+
+ generate();
+}
+
+void testApp::update() {
+ unsigned long curTime = ofGetSystemTime();
+
+ // instead of a fixed delay, we could just wait until a frame after we see a difference
+ bool needToCapture = capturing && (curTime - captureTime) > bufferTime;
+ if(camera.grabVideo(curFrame) && needToCapture) {
+ curFrame.saveImage(curDirectory + ofToString(pattern) + ".png");
+ if(nextState()) {
+ captureTime = curTime;
+ } else {
+ stopCapture();
+ }
+ }
+}
+
+void testApp::draw() {
+ ofBackground(0);
+ generator.get(pattern).draw(projector * tw, 0);
+ if(!capturing) {
+ ofPushMatrix();
+ //ofScale(.25, .25);
+ curFrame.update();
+ curFrame.draw(0, 0);
+ ofPopMatrix();
+ }
+}
+
+void testApp::startCapture() {
+ capturing = true;
+ captureTime = ofGetSystemTime();
+}
+
+void testApp::stopCapture() {
+ capturing = false;
+}
+
+void testApp::keyPressed(int key) {
+ if(key == ' ') {
+ startCapture();
+ }
+ if(key == 'f') {
+ ofToggleFullscreen();
+ }
+}
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "ofMain.h"
+
+#include "ofxLibdc.h"
+
+class testApp : public ofBaseApp {
+public:
+ void setup();
+ void update();
+ void draw();
+ void keyPressed(int key);
+
+ void startCapture();
+ void stopCapture();
+
+ const static int tw = 1024;
+ const static int th = 768;
+
+ ofxLibdc::PointGrey camera;
+ ofImage curFrame;
+};
Oops, something went wrong.

0 comments on commit ca27d00

Please sign in to comment.