Skip to content

Commit

Permalink
adding some new apps. of special importance is CaptureAppKinect, whic…
Browse files Browse the repository at this point in the history
…h is the starting point for the new capture app. i decided to do it from scratch because there are like 4 older projects floating around influencing the current capture app and it's an absolute mess.
  • Loading branch information
kylemcdonald committed Apr 7, 2011
1 parent 1d0533b commit 82a1b91
Show file tree
Hide file tree
Showing 40 changed files with 6,950 additions and 31 deletions.
8 changes: 0 additions & 8 deletions CalibrateFromDisk/src/ofxProcessing.h

This file was deleted.

21 changes: 14 additions & 7 deletions CalibrateFromDisk/src/testApp.cpp
@@ -1,20 +1,27 @@
#include "testApp.h"

void testApp::setup() {
void calibrate(Calibration& calib, string dir) {
ofDirectoryLister dirList;
Calibration calib;
ofImage cur;

dirList.listDir("images/");

calib.setBoardSize(6, 9);
dirList.listDir(dir);
calib.setBoardSize(10, 7);
calib.setSquareSize(1);

int total = 0;
for(int i = 0; i < dirList.size(); i++) {
cur.loadImage(dirList.getPath(i));
calib.add(cur);
if(calib.add(cur)) {
total++;
}
}
calib.calibrate();

cout << "calibrated with " << total << "/" << dirList.size() << endl;
}

void testApp::setup() {
Calibration calib;
calibrate(calib, "images/");
calib.save("calibration.yml");

cout << "reprojection error: " << endl << calib.getReprojectionError() << endl;
Expand Down
8 changes: 0 additions & 8 deletions CalibratedUndistort/src/ofxProcessing.h

This file was deleted.

5 changes: 4 additions & 1 deletion CalibratedUndistort/src/testApp.cpp
Expand Up @@ -6,10 +6,13 @@ void testApp::setup() {
lasti = 0;

calib.load("calibration.yml");

cout << "reprojection error: " << endl << calib.getReprojectionError() << endl;
cout << "distortion coefficients: " << endl << calib.getDistortionCoefficients() << endl;
cout << "camera matrix: " << endl << calib.getCameraMatrix() << endl;
cout << "fov: " << endl << calib.getFov() << endl;
cout << "sensor size: " << endl << calib.getSensorSize() << endl;
cout << "focal length: " << endl << calib.getFocalLength() << endl;

updateImage();
}
Expand Down
10 changes: 5 additions & 5 deletions CaptureApp/CaptureApp.xcodeproj/project.pbxproj
Expand Up @@ -103,7 +103,7 @@
E4B95F2C11D2C79C001A61C5 /* ThreePhaseDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B95F1C11D2C79C001A61C5 /* ThreePhaseDecoder.cpp */; };
E4B95F2D11D2C79C001A61C5 /* ThreePhaseGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B95F1E11D2C79C001A61C5 /* ThreePhaseGenerator.cpp */; };
E4B95F2E11D2C79C001A61C5 /* ThreePhaseWrap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B95F2011D2C79C001A61C5 /* ThreePhaseWrap.cpp */; };
E4C2422B10CC554B004149E2 /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2421E10CC549C004149E2 /* openFrameworksDebug.a */; };
E4C2422B10CC554B004149E2 /* openFrameworks.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2421E10CC549C004149E2 /* openFrameworks.a */; };
E4C2424710CC5A17004149E2 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424410CC5A17004149E2 /* AppKit.framework */; };
E4C2424810CC5A17004149E2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424510CC5A17004149E2 /* Cocoa.framework */; };
E4C2424910CC5A17004149E2 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424610CC5A17004149E2 /* IOKit.framework */; };
Expand Down Expand Up @@ -449,7 +449,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E4C2422B10CC554B004149E2 /* openFrameworksDebug.a in Frameworks */,
E4C2422B10CC554B004149E2 /* openFrameworks.a in Frameworks */,
E45BE0AA0E8CC67C009D7055 /* GLee.a in Frameworks */,
E45BE2E40E8CC69C009D7055 /* rtAudio.a in Frameworks */,
E45BE97B0E8CC7DD009D7055 /* AGL.framework in Frameworks */,
Expand Down Expand Up @@ -1400,7 +1400,7 @@
E4C2421710CC549C004149E2 /* Products */ = {
isa = PBXGroup;
children = (
E4C2421E10CC549C004149E2 /* openFrameworksDebug.a */,
E4C2421E10CC549C004149E2 /* openFrameworks.a */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -1534,10 +1534,10 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
E4C2421E10CC549C004149E2 /* openFrameworksDebug.a */ = {
E4C2421E10CC549C004149E2 /* openFrameworks.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = openFrameworksDebug.a;
path = openFrameworks.a;
remoteRef = E4C2421D10CC549C004149E2 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
Expand Down
2 changes: 1 addition & 1 deletion CaptureApp/bin/data/serialSettings.xml
@@ -1 +1 @@
<serialPort>/dev/cu.usbserial-A3000XSL</serialPort>
<serialPort>/dev/cu.usbmodemfa141</serialPort>
1,024 changes: 1,024 additions & 0 deletions CaptureAppKinect/CaptureAppKinect.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Empty file.
20 changes: 20 additions & 0 deletions CaptureAppKinect/openFrameworks-Info.plist
@@ -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>
8 changes: 8 additions & 0 deletions CaptureAppKinect/src/main.cpp
@@ -0,0 +1,8 @@
#include "testApp.h"
#include "ofAppGlutWindow.h"

int main() {
ofAppGlutWindow window;
ofSetupOpenGL(&window, 640, 480 * 2, OF_WINDOW);
ofRunApp(new testApp());
}
83 changes: 83 additions & 0 deletions CaptureAppKinect/src/testApp.cpp
@@ -0,0 +1,83 @@
#include "testApp.h"

void testApp::setup() {
ofSetVerticalSync(true);

capturedFrame = 0;
recording = false;
recordingLength = 128;

setupKinect();
setupCanon();
setupArduino();
}

void testApp::setupKinect() {
kinect.init();
ofxKinectCalibration::setClippingInCentimeters(40, 110);
kinect.open();

cout << "allocating " + recordingLength + " frames for kinect" << endl;
kinectBuffer.resize(1);
kinectBuffer[0].allocate(kinect.getWidth(), kinect.getHeight(), OF_IMAGE_GRAYSCALE);
kinectBuffer.resize(recordingLength);
}

void testApp::setupCanon() {
camera.setup();

cout << "allocating " + recordingLength + " frames for canon" << endl;
cameraBuffer.resize(1);
cameraBuffer[0].allocate(camera.getWidth(), camera.getHeight(), OF_IMAGE_COLOR);
cameraBuffer.resize(recordingLength);
}

void testApp::update() {
ofBackground(100, 100, 100);

camera.update();

kinect.update();
if(kinect.isFrameNew()) {
}

if(recording) {

kinectBuffer[capturedFrame].setFromPixels(kinect.getDepthPixels(), kinect.getWidth(), kinect.getHeight(), OF_IMAGE_GRAYSCALE);
cameraBuffer[capturedFrame] = camera.getPixelsRef();

capturedFrame++;

if(capturedFrame == recordingLength) {
for(int i = 0; i < capturedFrame; i++) {
ofSaveImage(kinectBuffer[i], "kinect/" + ofToString(i) + ".png");
ofSaveImage(cameraBuffer[i], "canon/" + ofToString(i) + ".png");
}

recording = false;
}
}
}

void testApp::draw() {
ofSetColor(255);
int cw = camera.getWidth() * (640. / 1056);
int ch = camera.getHeight() * (640. / 1056);
camera.draw(0, 0, cw, ch);
kinect.drawDepth(0, ch);

ofSetColor(ofColor::red);
ofLine(320, 0, 320, ofGetHeight());
ofLine(0, ch / 2, ofGetWidth(), ch / 2);
ofLine(0, ch + 240, ofGetWidth(), ch + 240);
}

void testApp::exit() {
kinect.close();
}

void testApp::keyPressed(int key) {
if(key == ' ') {
recording = true;
}
}
31 changes: 31 additions & 0 deletions CaptureAppKinect/src/testApp.h
@@ -0,0 +1,31 @@
#pragma once

#include "ofMain.h"
#include "ofxOpenCv.h"
#include "ofxKinect.h"
#include "ofxEdsdk.h"

class testApp : public ofBaseApp {
public:
void setup();
void setupKinect();
void setupCanon();
void setupArduino();

void update();
void draw();
void exit();
void keyPressed(int key);

ofxKinect kinect;
ofxEdsdk::Camera camera;

int capturedFrame;

bool recording;
int recordingLength;
vector<ofPixels> kinectBuffer;
vector<ofPixels> cameraBuffer;

ofSerial arduino;
};

0 comments on commit 82a1b91

Please sign in to comment.