From 173c5f7a2af9d9daa02cf9416ea6c435ed2d50a0 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sat, 23 Jan 2016 22:44:17 +0100 Subject: [PATCH] Integrare `HomographyHelper` into ofxPiMapper more deeply --- example/example.xcodeproj/project.pbxproj | 12 ++++++------ src/Surfaces/QuadSurface.cpp | 3 +-- src/Surfaces/QuadSurface.h | 2 +- ...fxHomographyHelper.cpp => HomographyHelper.cpp} | 14 ++++++++++---- .../{ofxHomographyHelper.h => HomographyHelper.h} | 9 +++++++-- 5 files changed, 25 insertions(+), 15 deletions(-) rename src/Utils/{ofxHomographyHelper.cpp => HomographyHelper.cpp} (92%) rename src/Utils/{ofxHomographyHelper.h => HomographyHelper.h} (84%) diff --git a/example/example.xcodeproj/project.pbxproj b/example/example.xcodeproj/project.pbxproj index 3397f7c..4a258bf 100644 --- a/example/example.xcodeproj/project.pbxproj +++ b/example/example.xcodeproj/project.pbxproj @@ -14,7 +14,7 @@ 39264841192224F90008A7F5 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483D192224F90008A7F5 /* tinyxml.cpp */; }; 39264842192224F90008A7F5 /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483F192224F90008A7F5 /* tinyxmlerror.cpp */; }; 39264843192224F90008A7F5 /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39264840192224F90008A7F5 /* tinyxmlparser.cpp */; }; - 3926516E1C54292E00C54844 /* ofxHomographyHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926516D1C54292E00C54844 /* ofxHomographyHelper.cpp */; }; + 392651711C5429C600C54844 /* HomographyHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 392651701C5429C600C54844 /* HomographyHelper.cpp */; }; 3933D5D319BB87BD000ACA55 /* ofxBaseGui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3933D5C219BB87BD000ACA55 /* ofxBaseGui.cpp */; }; 3933D5D419BB87BD000ACA55 /* ofxButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3933D5C419BB87BD000ACA55 /* ofxButton.cpp */; }; 3933D5D519BB87BD000ACA55 /* ofxGuiGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3933D5C719BB87BD000ACA55 /* ofxGuiGroup.cpp */; }; @@ -148,8 +148,8 @@ 3926483E192224F90008A7F5 /* tinyxml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tinyxml.h; sourceTree = ""; }; 3926483F192224F90008A7F5 /* tinyxmlerror.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxmlerror.cpp; sourceTree = ""; }; 39264840192224F90008A7F5 /* tinyxmlparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxmlparser.cpp; sourceTree = ""; }; - 3926516C1C54292E00C54844 /* ofxHomographyHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxHomographyHelper.h; sourceTree = ""; }; - 3926516D1C54292E00C54844 /* ofxHomographyHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxHomographyHelper.cpp; sourceTree = ""; }; + 3926516F1C5429C600C54844 /* HomographyHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomographyHelper.h; sourceTree = ""; }; + 392651701C5429C600C54844 /* HomographyHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HomographyHelper.cpp; sourceTree = ""; }; 3933D5C219BB87BD000ACA55 /* ofxBaseGui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxBaseGui.cpp; sourceTree = ""; }; 3933D5C319BB87BD000ACA55 /* ofxBaseGui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxBaseGui.h; sourceTree = ""; }; 3933D5C419BB87BD000ACA55 /* ofxButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxButton.cpp; sourceTree = ""; }; @@ -488,8 +488,8 @@ 39836CC71C502108006DB042 /* Utils */ = { isa = PBXGroup; children = ( - 3926516C1C54292E00C54844 /* ofxHomographyHelper.h */, - 3926516D1C54292E00C54844 /* ofxHomographyHelper.cpp */, + 3926516F1C5429C600C54844 /* HomographyHelper.h */, + 392651701C5429C600C54844 /* HomographyHelper.cpp */, ); path = Utils; sourceTree = ""; @@ -968,7 +968,6 @@ 39C1246A19F0AB96005DF557 /* QuadSurface.cpp in Sources */, 39C1247F19F187D5005DF557 /* RadioList.cpp in Sources */, 39C1243419EE9589005DF557 /* Base64Encoding.cpp in Sources */, - 3926516E1C54292E00C54844 /* ofxHomographyHelper.cpp in Sources */, 397EFC7F1A08FE720009286E /* FboSource.cpp in Sources */, 397C46C21C3AE2A7002689E2 /* SurfaceFactory.cpp in Sources */, E4B69E200A3A1BDC003C02F2 /* main.cpp in Sources */, @@ -1027,6 +1026,7 @@ E4B69E210A3A1BDC003C02F2 /* ofApp.cpp in Sources */, 39C1244B19EE9589005DF557 /* snappy.cc in Sources */, 3933D5D719BB87BD000ACA55 /* ofxPanel.cpp in Sources */, + 392651711C5429C600C54844 /* HomographyHelper.cpp in Sources */, 39C1247D19F187D5005DF557 /* CircleJoint.cpp in Sources */, 39264842192224F90008A7F5 /* tinyxmlerror.cpp in Sources */, 3926483B192224DA0008A7F5 /* ofxXmlSettings.cpp in Sources */, diff --git a/src/Surfaces/QuadSurface.cpp b/src/Surfaces/QuadSurface.cpp index 78183bb..61c4ba0 100644 --- a/src/Surfaces/QuadSurface.cpp +++ b/src/Surfaces/QuadSurface.cpp @@ -226,10 +226,9 @@ void QuadSurface::calculateHomography(){ dst[3][0] = p3.x; dst[3][1] = p3.y; - ofxHomographyHelper::findHomography(src, dst, _matrix); + HomographyHelper::findHomography(src, dst, _matrix); } - void QuadSurface::setPerspectiveWarping(bool b){ _perspectiveWarping = b; } diff --git a/src/Surfaces/QuadSurface.h b/src/Surfaces/QuadSurface.h index 5d6f580..1ca101d 100644 --- a/src/Surfaces/QuadSurface.h +++ b/src/Surfaces/QuadSurface.h @@ -3,7 +3,7 @@ #include "ofMain.h" #include "BaseSurface.h" #include "SurfaceType.h" -#include "ofxHomographyHelper.h" +#include "HomographyHelper.h" namespace ofx { namespace piMapper { diff --git a/src/Utils/ofxHomographyHelper.cpp b/src/Utils/HomographyHelper.cpp similarity index 92% rename from src/Utils/ofxHomographyHelper.cpp rename to src/Utils/HomographyHelper.cpp index 4b19eb1..43f6181 100644 --- a/src/Utils/ofxHomographyHelper.cpp +++ b/src/Utils/HomographyHelper.cpp @@ -1,5 +1,5 @@ /* - * ofxHomographyHelper.cpp + * HomographyHelper * Created by Elliot Woods on 26/11/2010. * Edited by Krisjanis Rijnieks on 23/01/2016 * @@ -9,9 +9,12 @@ * http://www.openframeworks.cc/forum/viewtopic.php?f=9&t=3121 */ -#include "ofxHomographyHelper.h" +#include "HomographyHelper.h" -void ofxHomographyHelper::gaussian_elimination(float *input, int n){ +namespace ofx { +namespace piMapper { + +void HomographyHelper::gaussian_elimination(float *input, int n){ // ported to c from pseudocode in // http://en.wikipedia.org/wiki/Gaussian_elimination @@ -66,7 +69,7 @@ void ofxHomographyHelper::gaussian_elimination(float *input, int n){ } -void ofxHomographyHelper::findHomography(float src[4][2], float dst[4][2], float homography[16]){ +void HomographyHelper::findHomography(float src[4][2], float dst[4][2], float homography[16]){ // create the equation system to be solved // @@ -112,3 +115,6 @@ void ofxHomographyHelper::findHomography(float src[4][2], float dst[4][2], float for(int i=0;i<16;i++) homography[i] = aux_H[i]; } + +} // namespace piMapper +} // namespace ofx diff --git a/src/Utils/ofxHomographyHelper.h b/src/Utils/HomographyHelper.h similarity index 84% rename from src/Utils/ofxHomographyHelper.h rename to src/Utils/HomographyHelper.h index fb3361e..5ce8920 100644 --- a/src/Utils/ofxHomographyHelper.h +++ b/src/Utils/HomographyHelper.h @@ -1,5 +1,5 @@ /* - * ofxHomographyHelper.cpp + * HomographyHelper * Created by Elliot Woods on 26/11/2010. * Edited by Krisjanis Rijnieks on 23/01/2016 * @@ -13,9 +13,14 @@ #include "ofMatrix4x4.h" -class ofxHomographyHelper { +namespace ofx { +namespace piMapper { + +class HomographyHelper { public: static void gaussian_elimination(float *input, int n); static void findHomography(float src[4][2], float dst[4][2], float homography[16]); }; +} +}