Permalink
Browse files

lots of changes while shooting documentation

  • Loading branch information...
kylemcdonald committed Nov 12, 2011
1 parent 17fd5dd commit 6054cc66515a67e2003d91e89712dcc5e4198a5c
@@ -10,7 +10,7 @@ const vec4 off = vec4(vec3(0.), 1.);
void main() {
float stages = 6.;
- float stage = mod(elapsedTime * .6, stages);
+ float stage = 5.;mod(elapsedTime * .6, stages);
if(stage < 1.) {
// diagonal stripes
const float speed = 50.;
@@ -58,7 +58,7 @@ bool nextState() {
void testApp::setup() {
ofSetVerticalSync(true);
ofHideCursor();
- ofSetDataPathRoot("../../../../../SharedData/");
+ ofSetDataPathRoot("../../../../../SharedData/skull/");
ofSetLogLevel(OF_LOG_VERBOSE);
camera.setup();
generate();

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -6,4 +6,4 @@ OF_PATH = ../../..
#include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
OTHER_LDFLAGS = $(OF_CORE_LIBS)
-HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) "../../../addons/ofxCv/libs/opencv/include/"
+HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) "../../../addons/ofxCv/libs/ofxCv/include/" "../../../addons/ofxCv/libs/opencv/include/"
View
@@ -3,6 +3,6 @@
int main() {
ofAppGlutWindow window;
- ofSetupOpenGL(&window, 1280, 960, OF_WINDOW);
+ ofSetupOpenGL(&window, 1024, 768, OF_FULLSCREEN);
ofRunApp(new testApp());
}
View
@@ -1,8 +1,14 @@
#include "testApp.h"
+using namespace ofxCv;
+using namespace cv;
+
void testApp::setup() {
ofSetVerticalSync(true);
ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
+ ofSetLogLevel(OF_LOG_VERBOSE);
+
+ cameraMode = EASYCAM_MODE;
FileStorage cfs(ofToDataPath("cam.yml"), FileStorage::READ);
cfs["cameraMatrix"] >> camMatrix;
@@ -18,18 +24,18 @@ void testApp::setup() {
pfs["rotation"] >> rotation;
pfs["translation"] >> translation;
- camImage.allocate(640, 480, OF_IMAGE_GRAYSCALE);
- proImage.allocate(512, 384, OF_IMAGE_GRAYSCALE);
+ camImage.allocate(3456, 2304, OF_IMAGE_GRAYSCALE);
+ proImage.allocate(1024, 768, OF_IMAGE_GRAYSCALE);
- getRemapPoints("skull/", proImage.getWidth(), proImage.getHeight(), camImagePoints, proImagePoints, colors);
- getProCamImages("skull/", proImage, camImage, proImage.getWidth(), proImage.getHeight());
+ getRemapPoints("skull/", proImage.getWidth(), proImage.getHeight(), camImagePoints, proImagePoints, colors, GRAYCODE_MODE_OPPOSITES);
+ getProCamImages("skull/", proImage, camImage, proImage.getWidth(), proImage.getHeight(), GRAYCODE_MODE_OPPOSITES);
camImage.update();
proImage.update();
camImage.saveImage("camImage.png");
proImage.saveImage("proImage.png");
- //proDistCoeffs = Mat::zeros(proDistCoeffs.size(), proDistCoeffs.type());
+ proDistCoeffs = Mat::zeros(proDistCoeffs.size(), proDistCoeffs.type());
//camDistCoeffs = Mat::zeros(camDistCoeffs.size(), camDistCoeffs.type());
resultPoints = triangulatePositions(
@@ -41,30 +47,75 @@ void testApp::setup() {
for(int i = 0; i < colors.size(); i++) {
mesh.addColor(ofColor(colors[i]));
}
+
+ proCalibration.setup(proMatrix, proSize);
+ camCalibration.setup(camMatrix, camSize);
}
void testApp::update() {
+ ofFile fragFile("shader.frag"), vertFile("shader.vert");
+ Poco::Timestamp fragTimestamp = fragFile.getPocoFile().getLastModified();
+ Poco::Timestamp vertTimestamp = vertFile.getPocoFile().getLastModified();
+ if(fragTimestamp != lastFragTimestamp || vertTimestamp != lastVertTimestamp) {
+ shader.load("shader");
+ }
+ lastFragTimestamp = fragTimestamp;
+ lastVertTimestamp = vertTimestamp;
}
void testApp::draw() {
ofBackground(0);
- cam.begin();
- ofScale(1, -1, -1);
+ if(cameraMode == EASYCAM_MODE) {
+ cam.begin();
+ ofScale(1, -1, -1);
+ } else if(cameraMode == PRO_MODE) {
+ ofSetupScreenPerspective(proSize.width, proSize.height);
+ proCalibration.loadProjectionMatrix();
+
+ // build and invert extrinsics
+ Mat r = rotation;
+ Mat t = translation;
+ Mat extrinsics = (Mat1d(4,4) <<
+ r.at<double>(0,0), r.at<double>(0,1), r.at<double>(0,2), t.at<double>(0),
+ r.at<double>(1,0), r.at<double>(1,1), r.at<double>(1,2), t.at<double>(1),
+ r.at<double>(2,0), r.at<double>(2,1), r.at<double>(2,2), t.at<double>(2),
+ 0, 0, 0, 1);
+ extrinsics = extrinsics.inv().t();
+ glMultMatrixd((GLdouble*) extrinsics.ptr(0,0));
+
+ } else if(cameraMode == CAM_MODE) {
+ ofSetupScreenPerspective(camSize.width, camSize.height);
+ camCalibration.loadProjectionMatrix();
+ }
glEnable(GL_DEPTH_TEST);
- ofTranslate(0, 0, -1200);
-
- ofSetColor(magentaPrint);
- drawCamera("camera", camMatrix, camSize, camImage);
- drawCamera("projector", proMatrix, proSize, proImage, rotation, translation);
+ if(cameraMode == EASYCAM_MODE) {
+ ofTranslate(0, 0, -1200);
+ ofSetColor(magentaPrint);
+ drawCamera("camera", camMatrix, camSize, camImage);
+ drawCamera("projector", proMatrix, proSize, proImage, rotation, translation);
+ }
ofSetColor(255);
+
+ shader.begin();
+ shader.setUniform1f("elapsedTime", ofGetElapsedTimef());
+ shader.setUniform1f("mouseX", mouseX);
+ shader.setUniform1f("mouseY", mouseY);
mesh.draw();
+ shader.end();
- cam.end();
+ if(cameraMode == EASYCAM_MODE) {
+ cam.end();
+ }
}
void testApp::keyPressed(int key) {
+ switch(key) {
+ case '1': cameraMode = EASYCAM_MODE; break;
+ case '2': cameraMode = PRO_MODE; break;
+ case '3': cameraMode = CAM_MODE; break;
+ }
}
View
@@ -12,14 +12,21 @@ class testApp : public ofBaseApp {
void decodeAndSave(string filename);
void keyPressed(int key);
+ enum CameraMode {EASYCAM_MODE, PRO_MODE, CAM_MODE};
+ CameraMode cameraMode;
+
ofImage camImage, proImage;
- vector<Point2f> camImagePoints, proImagePoints;
- vector<Point3f> resultPoints;
+ vector<cv::Point2f> camImagePoints, proImagePoints;
+ vector<cv::Point3f> resultPoints;
cv::Size proSize, camSize;
- Mat camMatrix, proMatrix;
- Mat camDistCoeffs, proDistCoeffs;
- Mat rotation, translation;
+ cv::Mat camMatrix, proMatrix;
+ cv::Mat camDistCoeffs, proDistCoeffs;
+ cv::Mat rotation, translation;
ofEasyCam cam;
ofVboMesh mesh;
vector<unsigned char> colors;
+
+ ofShader shader;
+ Poco::Timestamp lastFragTimestamp, lastVertTimestamp;
+ ofxCv::Intrinsics proCalibration, camCalibration;
};
@@ -63,6 +63,9 @@ void testApp::update() {
mesh.addColor(ofColor(colors[i]));
}
+ cout << "rotation: " << rotation << endl;
+ cout << "translation: " << translation << endl;
+
exportPlyCloud("output.ply", mesh);
}
}
View
@@ -19,6 +19,7 @@ using namespace cv;
void testApp::setup(){
ofSetVerticalSync(true);
ofSetBackgroundAuto(false);
+ ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
ofSetDataPathRoot("../../../../../SharedData/");
panel.setup();
@@ -39,14 +40,16 @@ void testApp::setup(){
panel.addSlider("fade", 0, 0, 1); //
panel.addPanel("Detection");
+ panel.addSlider("kinectNear", 500, 0, 2000);
+ panel.addSlider("kinectFar", 1500, 0, 2000);
panel.addSlider("kinectBlur", 16, 0, 32, true);
- panel.addSlider("threshold", 66, 0, 256);
+ panel.addSlider("threshold", 200, 0, 256);
panel.addSlider("minAreaRadius", 30, 0, 100);
panel.addSlider("maxAreaRadius", 200, 0, 200);
- panel.addSlider("minx", -65, -100, 100);
- panel.addSlider("maxx", +45, -100, 100);
- panel.addSlider("miny", -92, -100, 100);
- panel.addSlider("maxy", +46, -100, 100);
+ panel.addSlider("minx", -300, -1000, 1000);
+ panel.addSlider("maxx", +100, -1000, 1000);
+ panel.addSlider("miny", -100, -1000, 1000);
+ panel.addSlider("maxy", +100, -1000, 1000 );
panel.addSlider("touchOffset", -.4 * sceneHeight, -sceneHeight, sceneHeight);
sceneFbo.allocate(sceneWidth, sceneHeight);
@@ -133,7 +136,9 @@ void testApp::drawOverlay() {
ofVec2f curCenter = toOf(contourFinder.getCenter(i));
ofCircle(curCenter, 10);
ofVec3f cur = users[i];
+ ofVec3f curBefore = usersBefore[i];
drawHighlightString(ofToString(userLabels[i]) + ": " +
+ ofToString((int) curBefore.x) + "/" + ofToString((int) curBefore.y) + "->" +
ofToString((int) cur.x) + "/" + ofToString((int) cur.y),
curCenter);
}
@@ -173,6 +178,7 @@ void testApp::setFade() {
void testApp::findUserLocations() {
users.clear();
+ usersBefore.clear();
userLabels.clear();
int w = kinect.getWidth();
float* distancePixels = kinect.getDistancePixels();
@@ -199,6 +205,7 @@ void testApp::findUserLocations() {
}
}
ofVec3f cur = ConvertProjectiveToRealWorld(sum / count);
+ usersBefore.push_back(cur);
cur.x = ofMap(cur.x, panel.getValueF("minx"), panel.getValueF("maxx"), 0, 1);
cur.y = ofMap(cur.y, panel.getValueF("miny"), panel.getValueF("maxy"), 0, 1);
ofVec2f curNorm(cur.x, cur.y);
@@ -239,6 +246,10 @@ void testApp::updateScene() {
}
void testApp::update(){
+ if(panel.hasValueChanged("kinectFar") || panel.hasValueChanged("kinectNear")) {
+ kinect.setDepthClipping(panel.getValueF("kinectNear"), panel.getValueF("kinectFar"));
+ }
+
kinect.update();
if(kinect.isFrameNew()) {
contourFinder.setInvert(false);
@@ -265,6 +276,8 @@ void testApp::update(){
rightRemap.setOffset(sceneOffset);
updateScene();
+
+ panel.clearAllChanged();
}
void testApp::draw() {
View
@@ -60,7 +60,7 @@ class testApp : public ofBaseApp{
cv::Mat kinectAccumulator, kinectAccumulator8u;
ofxCv::ContourFinder contourFinder;
ofImage filled;
- vector<ofVec3f> users;
+ vector<ofVec3f> users, usersBefore;
vector<unsigned int> userLabels;
float startFadeTime;

0 comments on commit 6054cc6

Please sign in to comment.