Permalink
Browse files

End of art&code

  • Loading branch information...
1 parent cd6b586 commit e82aef8d5d2357e38ec99464cde62d830d176d57 @elliotwoods committed Dec 2, 2011

Large diffs are not rendered by default.

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,4 @@
+#A. Calibrate projector test
+
+
+Simply test the maths
@@ -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,16 @@
+#include "ofMain.h"
+#include "testApp.h"
+#include "ofAppGlutWindow.h"
+
+//========================================================================
+int main( ){
+
+ ofAppGlutWindow window;
+ ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
+
+ // this kicks off the running of my app
+ // can be OF_WINDOW or OF_FULLSCREEN
+ // pass in width and height too:
+ ofRunApp( new testApp());
+
+}
@@ -0,0 +1,102 @@
+#include "testApp.h"
+
+testApp::testApp(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::setup(){
+ xyz.push_back(ofVec3f(0.4245337450, -0.3661487279, -0.4878357339));
+ xyz.push_back(ofVec3f(0.3506861092, 0.4697300799, 0.4053756632));
+ xyz.push_back(ofVec3f(-0.4230080058, 0.1083145491, 0.4126259645));
+ xyz.push_back(ofVec3f(-0.1698530512, -0.0650750778, 0.4814476264));
+ xyz.push_back(ofVec3f(0.2610632244, 0.3133410532, 0.1916766560));
+ xyz.push_back(ofVec3f(0.1478232923, 0.3995812254, -0.4930971479));
+ xyz.push_back(ofVec3f(0.0032118086, 0.1184657835, 0.2893070101));
+ xyz.push_back(ofVec3f(0.4964968562, 0.4479994180, -0.2135472880));
+ xyz.push_back(ofVec3f(-0.3507092523, 0.3956844574, 0.4353991777));
+ xyz.push_back(ofVec3f(0.1563462173, -0.4588385050, 0.4567027371));
+
+ xy.push_back(ofVec2f(0.0398886837, -0.0468833521));
+ xy.push_back(ofVec2f(0.0316718407, 0.0516602844));
+ xy.push_back(ofVec2f(-0.0379085615, 0.0206585843));
+ xy.push_back(ofVec2f(-0.0151045956, 0.0077264998));
+ xy.push_back(ofVec2f(0.0238197707, 0.0325947478));
+ xy.push_back(ofVec2f(0.0141222430, 0.0217483565));
+ xy.push_back(ofVec2f(0.0002901061, 0.0182518009));
+ xy.push_back(ofVec2f(0.0466207266, 0.0338115618));
+ xy.push_back(ofVec2f(-0.0315673873, 0.0459829457));
+ xy.push_back(ofVec2f(0.0138158584, -0.0260905977));
+
+ for (int i=0; i<xy.size(); i++) {
+ xy[i].x = (xy[i].x + 1.0f) / 2.0f * 1024;
+ xy[i].y = (1.0f - xy[i].y) / 2.0f * 768;
+ }
+
+ vector<Mat> boardRotations, boardTranslations;
+
+ vector<vector<Point3f> > vvo(1); //object points
+ vector<vector<Point2f> > vvi(1); //image points
+
+
+ int flags = 0;
+
+ flags |= CV_CALIB_USE_INTRINSIC_GUESS;
+ //flags |= CV_CALIB_FIX_PRINCIPAL_POINT;
+ flags |= CV_CALIB_FIX_ASPECT_RATIO;
+ flags |= CV_CALIB_ZERO_TANGENT_DIST;
+ flags |= CV_CALIB_FIX_K1;
+ flags |= CV_CALIB_FIX_K2;
+ flags |= CV_CALIB_FIX_K3;
+
+
+ //pull values into the 3d calibration
+ vvo[0] = *(vector<Point3f >*)&xyz;
+ vvi[0] = *(vector<Point2f >*)&xy;
+
+ //initialised throw ratio = 1.0f
+ float f = 1024;
+ cameraMatrix = (Mat1d(3, 3) <<
+ f, 0, f/2,
+ 0, f, f/2,
+ 0, 0, 1);
+ try {
+ error = calibrateCamera(vvo, vvi, cv::Size(1024, 768), cameraMatrix, distCoeffs, boardRotations, boardTranslations, flags);
+ } catch (...) {
+ ofLogError() << "Calibration threw exception. Check parameters.";
+ }
+
+ intrinsics.setup(cameraMatrix, cv::Size(1024, 768));
+
+ cout << cameraMatrix << endl;
+ cout << distCoeffs << endl;
+ cout << "Error: " << error << endl;
+
+}
+
+//--------------------------------------------------------------
+void testApp::update(){
+ }
+
+//--------------------------------------------------------------
+void testApp::draw(){
+ ofVec2f screen;
+ for (int i=0; i<xy.size(); i++) {
+ screen = project(xyz[i]);
+
+ ofCircle(screen.x, screen.y, 10);
+ }
+}
+
+ofVec2f testApp::project(ofVec3f v) {
+ vector<cv::Point3f> vo;
+ vo.push_back(toCv(v));
+ Mat mt = (Mat1d(3,1) << 0, 0, 0);
+ Mat mr = (Mat1d(3,1) << 0, 0, 0);
+
+ vector<Point2f> projected(1);
+
+ projectPoints(Mat(vo), mr, mt, cameraMatrix, distCoeffs, projected);
+
+ return toOf(projected[0]);
+}
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "ofMain.h"
+
+#include "ofxCV.h"
+
+using namespace cv;
+using namespace ofxCv;
+class testApp : public ofBaseApp{
+
+public:
+ testApp();
+
+ void setup();
+ void update();
+ void draw();
+
+ ofVec2f project(ofVec3f xyz);
+
+ vector<ofVec3f> xyz;
+ vector<ofVec2f> xy;
+
+ Mat cameraMatrix;
+ Mat distCoeffs;
+ Intrinsics intrinsics;
+
+ float error;
+};
@@ -22,7 +22,7 @@ void testApp::update(){
//--------------------------------------------------------------
void testApp::draw(){
if (fullscreen)
- vidGrabber.draw(0,0,ofGetWidth(), ofGetHeight());
+ vidGrabber.draw(ofGetWidth(),0,-ofGetWidth(), ofGetHeight());
else
vidGrabber.draw(0,0);
}
@@ -1279,6 +1279,7 @@
isa = PBXProject;
buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "PointcloudWriter" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
@@ -1584,6 +1585,7 @@
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_9 = "\"$(SRCROOT)/../../../addons/ofxOpenCv/libs/opencv/lib/android/armeabi\"";
PREBINDING = NO;
PRODUCT_NAME = PointcloudWriterDebug;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
WRAPPER_EXTENSION = app;
};
name = Debug;
@@ -1709,6 +1711,7 @@
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_6 = "\"$(SRCROOT)/../../../addons/ofxKinect/libs/libusb/osx/libs\"";
PREBINDING = NO;
PRODUCT_NAME = PointcloudWriter;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
WRAPPER_EXTENSION = app;
};
name = Release;
@@ -65,7 +65,7 @@ void ofxKinectPointcloudRecorder::threadedFunction(){
// }
//
- string filename = targetDirectory + "/" + targetFilePrefix + "_" + ofToString(currentFrame) + ".tga";
+ string filename = targetDirectory + "/" + targetFilePrefix + "_" + ofToString(currentFrame) + ".xkcd";
ofFile file(filename, ofFile::WriteOnly, true);
// int size = newpoints.size();
// file.write( (char*)&size, sizeof(int) );
@@ -106,14 +106,13 @@ void testApp::keyPressed(int key){
if(key == 'l'){
ofDirectory d("depthframes");
- d.allowExt("tga");
+ d.allowExt("xkcd");
d.listDir();
- vector<ofFile> files = d.getFiles();
frameRead = true;
// for(int f = 0; f < files.size(); f++){
for(int f = 0; f < 1; f++){
vector<ofVec3f> cloud;
- unsigned short* frame = recorder.readDepthFrame(files[f].getFileName());
+ unsigned short* frame = recorder.readDepthFrame(d.getName(f));
for(int y = 0; y < 480; y++){
for(int x = 0; x < 640; x++){
cout << frame[y*640+x] << endl;

0 comments on commit e82aef8

Please sign in to comment.