Permalink
Browse files

Merge branch 'master' of github.com:elliotwoods/artandcode.Camera-and…

…-projector-calibration
  • Loading branch information...
2 parents d360b1f + e0cb69f commit 115f90b54e2b1134b40664fdb7478bc6c95fc74d @elliotwoods committed Oct 20, 2011
Showing with 8,103 additions and 307 deletions.
  1. +0 −34 DepthExternalRGB/src/ofxDepthRGBAlignment.cpp
  2. +0 −45 DepthExternalRGB/src/ofxDepthRGBAlignment.h
  3. +301 −219 ...rnalRGB/DepthExternalRGB.xcodeproj → PointcloudWriter/PointcloudWriter.xcodeproj}/project.pbxproj
  4. 0 {DepthExternalRGB → PointcloudWriter}/Project.xcconfig
  5. BIN {DepthExternalRGB → PointcloudWriter}/emptyExample_vs2010.sdf
  6. 0 {DepthExternalRGB → PointcloudWriter}/emptyExample_vs2010.sln
  7. BIN {DepthExternalRGB → PointcloudWriter}/emptyExample_vs2010.suo
  8. 0 {DepthExternalRGB → PointcloudWriter}/emptyExample_vs2010.vcxproj
  9. 0 {DepthExternalRGB → PointcloudWriter}/emptyExample_vs2010.vcxproj.user
  10. 0 {DepthExternalRGB → PointcloudWriter}/openFrameworks-Info.plist
  11. +7 −6 {DepthExternalRGB → PointcloudWriter}/src/CameraHead.cpp
  12. 0 {DepthExternalRGB → PointcloudWriter}/src/CameraHead.h
  13. +17 −3 DepthExternalRGB/src/testApp.cpp → PointcloudWriter/src/_testApp.cpp
  14. 0 DepthExternalRGB/src/testApp.h → PointcloudWriter/src/_testApp.h
  15. 0 {DepthExternalRGB → PointcloudWriter}/src/main.cpp
  16. +103 −0 PointcloudWriter/src/ofxKinectPointcloudRecorder.cpp
  17. +37 −0 PointcloudWriter/src/ofxKinectPointcloudRecorder.h
  18. +173 −0 PointcloudWriter/src/testApp.cpp
  19. +69 −0 PointcloudWriter/src/testApp.h
  20. +19 −0 RGBDPost/Project.xcconfig
  21. +1,373 −0 RGBDPost/RGBDPost.xcodeproj/project.pbxproj
  22. BIN RGBDPost/emptyExample_vs2010.sdf
  23. +25 −0 RGBDPost/emptyExample_vs2010.sln
  24. BIN RGBDPost/emptyExample_vs2010.suo
  25. +145 −0 RGBDPost/emptyExample_vs2010.vcxproj
  26. +11 −0 RGBDPost/emptyExample_vs2010.vcxproj.user
  27. +20 −0 RGBDPost/openFrameworks-Info.plist
  28. +309 −0 RGBDPost/src/CameraHead.cpp
  29. +82 −0 RGBDPost/src/CameraHead.h
  30. +235 −0 RGBDPost/src/_testApp.cpp
  31. +52 −0 RGBDPost/src/_testApp.h
  32. +16 −0 RGBDPost/src/main.cpp
  33. +234 −0 RGBDPost/src/testApp.cpp
  34. +60 −0 RGBDPost/src/testApp.h
  35. +19 −0 RGBDPreview/Project.xcconfig
  36. +1,869 −0 RGBDPreview/RGBDPreview.xcodeproj/project.pbxproj
  37. +510 −0 RGBDPreview/bin/data/colorCalib.yml
  38. +510 −0 RGBDPreview/bin/data/depthCalib.yml
  39. BIN RGBDPreview/emptyExample_vs2010.sdf
  40. +25 −0 RGBDPreview/emptyExample_vs2010.sln
  41. BIN RGBDPreview/emptyExample_vs2010.suo
  42. +145 −0 RGBDPreview/emptyExample_vs2010.vcxproj
  43. +11 −0 RGBDPreview/emptyExample_vs2010.vcxproj.user
  44. +20 −0 RGBDPreview/openFrameworks-Info.plist
  45. +309 −0 RGBDPreview/src/CameraHead.cpp
  46. +82 −0 RGBDPreview/src/CameraHead.h
  47. +235 −0 RGBDPreview/src/_testApp.cpp
  48. +52 −0 RGBDPreview/src/_testApp.h
  49. +16 −0 RGBDPreview/src/main.cpp
  50. +191 −0 RGBDPreview/src/testApp.cpp
  51. +59 −0 RGBDPreview/src/testApp.h
  52. +106 −0 common src/ofxCvCheckerboardPreview.cpp
  53. +42 −0 common src/ofxCvCheckerboardPreview.h
  54. +452 −0 common src/ofxRGBDAlignment.cpp
  55. +80 −0 common src/ofxRGBDAlignment.h
  56. +50 −0 common src/scrGameView3D.cpp
  57. +32 −0 common src/scrGameView3D.h
@@ -1,34 +0,0 @@
-/*
- * ofxDepthRGBAlignment.cpp
- * DepthExternalRGB
- *
- * Created by Jim on 10/18/11.
- * Copyright 2011 University of Washington. All rights reserved.
- *
- */
-
-#include "ofxDepthRGBAlignment.h"
-
-ofxDepthRGBAlignment::ofxDepthRGBAlignment() {
-
-}
-
-//-----------------------------------------------
-
-ofxDepthRGBAlignment::~ofxDepthRGBAlignment() {
-
-}
-
-//-----------------------------------------------
-
-void ofxDepthRGBAlignment::setup() {
-
-}
-
-//-----------------------------------------------
-
-void ofxDepthRGBAlignment::addCalibrationPair(ofPixels &depth, ofPixels &color) {
-
-}
-
-//-----------------------------------------------
@@ -1,45 +0,0 @@
-/*
- * ofxDepthRGBAlignment.h
- * DepthExternalRGB
- *
- * Created by Jim on 10/18/11.
- * Copyright 2011 University of Washington. All rights reserved.
- *
- */
-
-#include "ofMain.h"
-
-#include "ofxCv.h"
-
-using namespace ofxCv;
-using namespace ofxC
-
-class ofxDepthRGBAlignment {
- public:
- ofxDepthRGBAlignment();
- ~ofxDepthRGBAlignment();
- void setup();
-
- //calibratin of matrix
- //TODO: set calibration files or directories
- void addCalibrationPair(ofPixels &depth, ofPixels &color);
- void computeCalibration();
-
- //Display of dat
- void setColorImage(ofImage colorimage);
- void setDepthImage(ofImage depthImage);
- void update(); //updates current mesh
-
-
- void drawMesh();
- void drawPointCloud();
-
- protected:
- ofVboMesh mesh;
- Calibration depthCalibration, colorCalibration;
- Mat rotationKinectToColor, translationKinectToColor;
- Mat rotationColorToKinect, translationColorToKinect;
-
- Mat rotation, translation;
-
-};
Oops, something went wrong.
@@ -106,7 +106,7 @@ void CameraHead::update () {
++out;
}
//undistort
- if (calib.isReady && cameraScreen.iSelection==1)
+ if (calib.isReady() && cameraScreen.iSelection==1)
{
calib.undistort(toCv(video), toCv(videoUndistorted));
videoUndistorted.update();
@@ -133,13 +133,13 @@ void CameraHead::drawCorners(ofRectangle &viewport) {
}
ofPopStyle();
- drawHighlightString("isReady = " + string(calib.isReady ? "true" : "false"), viewport.x+5, viewport.y + viewport.height-60, ofColor(200,100,100), ofColor(255,255,255));
+ drawHighlightString("isReady = " + string(calib.isReady() ? "true" : "false"), viewport.x+5, viewport.y + viewport.height-60, ofColor(200,100,100), ofColor(255,255,255));
drawHighlightString("Calibration sets = " + ofToString(calib.imagePoints.size()), viewport.x+5, viewport.y + viewport.height-40, ofColor(200,100,100), ofColor(255,255,255));
drawHighlightString("Found corners = " + ofToString(imagePoints.size()), viewport.x+5, viewport.y + viewport.height-20, ofColor(200,100,100), ofColor(255,255,255));
}
void CameraHead::drawFrustum(ofNode& n) {
- if (!calib.isReady)
+ if (!calib.isReady())
return;
ofPushMatrix();
@@ -152,7 +152,7 @@ void CameraHead::drawFrustum(ofNode& n) {
void CameraHead::drawOnUndistorted(ofRectangle &r) {
- if (!calib.isReady)
+ if (!calib.isReady())
return;
ofPushView();
@@ -201,6 +201,7 @@ void CameraHead::threadedFunction() {
while (isThreadRunning())
{
+
lock();
memcpy(greyThreadedInternal.getPixels(), greyBetweenBuffer.getPixels(), width*height);
unlock();
@@ -229,7 +230,7 @@ void CameraHead::threadedAdd() {
if (calibCount() >= MIN_CALIBS)
calib.calibrate();
- if (calib.isReady) {
+ if (calib.isReady()) {
Mat matCv = calib.getUndistortedIntrinsics().getCameraMatrix();
ofMatrix4x4 matC;
@@ -290,7 +291,7 @@ void CameraHead::shrink(unsigned int s) {
void CameraHead::updateCursor(ofVec2f& p) {
if (lockCorners.tryLock())
{
- if (calib.isReady)
+ if (calib.isReady())
{
ofVec3f c;
ofRectangle scr = cameraUndistortedScreen.getLiveBounds();
@@ -16,8 +16,9 @@ void testApp::setup(){
gui.init(mainScreen);
mainScreen.setGridWidth(1);
- for (int i=0; i<2; ++i)
+ for (int i=0; i<2; ++i){
mainScreen.push(camera[i].screens);
+ }
ofAddListener(camera[0].calibrationScreen.evtDraw3D, this, &testApp::draw3DCam);
ofAddListener(camera[1].calibrationScreen.evtDraw3D, this, &testApp::draw3DCam);
@@ -30,6 +31,20 @@ void testApp::setup(){
timerOn = false;
lastCaptureTime = 0;
+
+ ofShortPixels p;
+ //fill out p;
+
+ ofstream writer;
+ writer.open(ofToDataPath("arsewsp").c_str(), ios::binary | ios::out);
+ writer.write((char*)p.getPixels(), 2 * 640 * 480);
+ writer.close();
+
+ ifstream reader;
+ reader.open(ofToDataPath("arsewsp").c_str(), ios::binary | ios::in);
+ p.allocate(640, 480, OF_PIXELS_MONO);
+ reader.read((char*)p.getPixels(), 2 * 640 * 480);
+ reader.close();
}
@@ -38,8 +53,7 @@ void testApp::update(){
for (int i=0; i<2; ++i)
camera[i].update();
- if (camera[0].bangAdded && camera[1].bangAdded)
- {
+ if (camera[0].bangAdded && camera[1].bangAdded) {
camera[0].bangAdded = false;
camera[1].bangAdded = false;
calcTransforms();
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,103 @@
+/*
+ * ofxKinectPointcloudRecorder.cpp
+ * PointcloudWriter
+ *
+ * Created by Jim on 10/20/11.
+ * Copyright 2011 University of Washington. All rights reserved.
+ *
+ */
+
+#include "ofxKinectPointcloudRecorder.h"
+
+ofxKinectPointcloudRecorder::ofxKinectPointcloudRecorder(){
+
+}
+
+void ofxKinectPointcloudRecorder::setup(){
+
+ startThread(true, false);
+ currentFrame = 0;
+}
+
+void ofxKinectPointcloudRecorder::setRecordLocation(string directory, string filePrefix){
+ targetDirectory = directory;
+ ofDirectory dir(directory);
+ if(!dir.exists()){
+ dir.create(true);
+ }
+
+ targetFilePrefix = filePrefix;
+}
+
+void ofxKinectPointcloudRecorder::addImage(unsigned short* image){
+ unsigned short* addToQueue = new unsigned short[640*480];
+ memcpy(addToQueue, image, 640*480);
+ lock();
+ saveQueue.push( addToQueue );
+ unlock();
+}
+
+//void ofxKinectPointcloudRecorder::collectIntrinsics(ofxKinect& kinect) {
+//
+//
+//}
+
+void ofxKinectPointcloudRecorder::threadedFunction(){
+
+ while(isThreadRunning()){
+ unsigned short* tosave = NULL;
+ lock();
+ if(saveQueue.size() != 0){
+ tosave = saveQueue.front();
+ saveQueue.pop();
+ cout << " currently " << saveQueue.size() << " waiting " << endl;
+ }
+ unlock();
+
+ if(tosave != NULL){
+// vector<ofVec3f> newpoints;
+// for(int i = 0; i < kinect->getHeight()*kinect->getWidth(); i++){
+// int distance = tosave[i];
+// if(distance > 0){
+// ofVec3f worldp = kinect->getWorldCoordinateAt(i%int(kinect->getWidth()), i/int(kinect->getWidth()), distance);
+// newpoints.push_back(worldp);
+// }
+// }
+//
+
+ string filename = targetDirectory + "/" + targetFilePrefix + "_" + ofToString(currentFrame) + ".tga";
+ ofFile file(filename, ofFile::WriteOnly, true);
+// int size = newpoints.size();
+// file.write( (char*)&size, sizeof(int) );
+ file.write( (char*)&tosave[0], sizeof(unsigned short)*640*480 );
+ file.close();
+
+ /*
+ int amnt;
+ ofFile openTest(filename, ofFile::ReadOnly, true);
+ openTest.read((char*)&amnt,sizeof(int));
+ cout << " amount " << amnt << endl;
+
+ vector<ofVec3f> testvec(amnt);
+ openTest.read((char*)&(testvec[0]), sizeof(ofVec3f)*amnt);
+ openTest.close();
+ */
+
+ currentFrame++;
+ delete tosave;
+ }
+ }
+}
+
+unsigned short* ofxKinectPointcloudRecorder::readDepthFrame(string filename) {
+ int amnt;
+ ofFile infile(filename, ofFile::ReadOnly, true);
+ return readDepthFrame(infile);
+}
+
+unsigned short* ofxKinectPointcloudRecorder::readDepthFrame(ofFile infile){
+ unsigned short* outbuf = new unsigned short[640*480];
+ infile.read((char*)(&outbuf[0]), sizeof(unsigned short)*640*480);
+ infile.close();
+ return outbuf;
+}
@@ -0,0 +1,37 @@
+/*
+ * ofxKinectPointcloudRecorder.h
+ * PointcloudWriter
+ *
+ * Created by Jim on 10/20/11.
+ * Copyright 2011 University of Washington. All rights reserved.
+ *
+ */
+
+#pragma once
+
+#include "ofMain.h"
+#include "ofxKinect.h";
+#include "ofxCv.h"
+
+using namespace ofxCv;
+using namespace cv;
+
+class ofxKinectPointcloudRecorder : ofThread {
+ public:
+ ofxKinectPointcloudRecorder();
+ void setup();
+ void setRecordLocation(string directory, string filePrefix);
+ void addImage(unsigned short* image);
+
+ unsigned short* readDepthFrame(string filename);
+ unsigned short* readDepthFrame(ofFile file);
+
+ protected:
+ void threadedFunction();
+
+ string targetDirectory;
+ string targetFilePrefix;
+ int currentFrame;
+ queue<unsigned short*> saveQueue;
+ bool isRecording;
+};
Oops, something went wrong.

0 comments on commit 115f90b

Please sign in to comment.