From be71de7e182f0ea488bed89d3b238906eb678e9f Mon Sep 17 00:00:00 2001 From: Camille Troillard Date: Wed, 6 Nov 2013 20:53:28 +0100 Subject: [PATCH 01/29] Add OpenCV include directories to CMakefile. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d66373..9597a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,8 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") INCLUDE_DIRECTORIES("src/") INCLUDE_DIRECTORIES("src/avatar/") INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/src/") +INCLUDE_DIRECTORIES(OpenCV_INCLUDE_DIRS) + # Subdirectories with CMakeLists.txt ADD_SUBDIRECTORY(src/utils) From 0614346f3cc30b7f5a169109c9691e2ddbde36f3 Mon Sep 17 00:00:00 2001 From: Camille Troillard Date: Wed, 6 Nov 2013 20:54:12 +0100 Subject: [PATCH 02/29] Include unistd.h in map-list utility. --- src/map-list/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/map-list/main.cpp b/src/map-list/main.cpp index 9703742..234b66f 100644 --- a/src/map-list/main.cpp +++ b/src/map-list/main.cpp @@ -24,6 +24,7 @@ #include #include #include +#include void print_usage() From d3cf9f752647c133aa32737d9523e929e7d0d706 Mon Sep 17 00:00:00 2001 From: Camille Troillard Date: Wed, 13 Nov 2013 22:38:50 +0100 Subject: [PATCH 03/29] Fix a compilation problem occuring with OpenCV 2.4.6 and Apple LLVM 5.0. --- src/tracker/Detector.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tracker/Detector.cpp b/src/tracker/Detector.cpp index c5cf1c2..8c1c336 100644 --- a/src/tracker/Detector.cpp +++ b/src/tracker/Detector.cpp @@ -197,8 +197,9 @@ Detector::getResponsesForRefShape(cv::Size wSize, cv::Mat r) cv::resize(prob_.at(i), m, sz); if(respRect.x>0 || respRect.y>0){ - resp.at(i) = cv::Mat::zeros(wSize, m.type()); - m(probRect).copyTo(resp.at(i)(respRect)); + resp.at(i) = cv::Mat::zeros(wSize, m.type()); + cv::Mat tmp = resp.at(i)(respRect); + m(probRect).copyTo(tmp); } else resp.at(i) = m(probRect); From dbc90c6bb091edc6bfb3cccc7e7ffa0b5792bde5 Mon Sep 17 00:00:00 2001 From: Ean Schuessler Date: Mon, 28 Apr 2014 22:35:38 -0500 Subject: [PATCH 04/29] Various includes to get face kit to build --- CMakeLists.txt | 3 +++ src/avatar/myAvatar.cpp | 1 + src/face-fit/main.cpp | 1 + src/map-list/main.cpp | 1 + src/test/speed_test.cpp | 1 + src/test/test_Avatar.cpp | 1 + src/tracker/ATM.hpp | 1 + src/tracker/FDet.hpp | 1 + src/tracker/Patch.hpp | 1 + src/tracker/Warp.hpp | 1 + src/utils/helpers.cpp | 3 +++ 11 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d66373..17059c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ # -*-cmake-*- +set(OpenCV_DIR /usr/local/share/OpenCV) + PROJECT(CSIRO-FaceAnalysis-SDK) cmake_minimum_required(VERSION 2.8) @@ -60,6 +62,7 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") # Include directories +include_directories("/usr/include/") INCLUDE_DIRECTORIES("src/") INCLUDE_DIRECTORIES("src/avatar/") INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/src/") diff --git a/src/avatar/myAvatar.cpp b/src/avatar/myAvatar.cpp index 194f763..9dc2c75 100644 --- a/src/avatar/myAvatar.cpp +++ b/src/avatar/myAvatar.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #define it at #define db at using namespace AVATAR; diff --git a/src/face-fit/main.cpp b/src/face-fit/main.cpp index b5b0deb..c575ea1 100644 --- a/src/face-fit/main.cpp +++ b/src/face-fit/main.cpp @@ -22,6 +22,7 @@ #include "utils/points.hpp" #include "tracker/FaceTracker.hpp" #include +#include using namespace FACETRACKER; diff --git a/src/map-list/main.cpp b/src/map-list/main.cpp index 234b66f..cd632c6 100644 --- a/src/map-list/main.cpp +++ b/src/map-list/main.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include "assert.h" #include "utils/helpers.hpp" #include "utils/command-line-arguments.hpp" #include diff --git a/src/test/speed_test.cpp b/src/test/speed_test.cpp index 8631926..11f4e2f 100644 --- a/src/test/speed_test.cpp +++ b/src/test/speed_test.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/src/test/test_Avatar.cpp b/src/test/test_Avatar.cpp index e228cfa..d3857ea 100644 --- a/src/test/test_Avatar.cpp +++ b/src/test/test_Avatar.cpp @@ -22,6 +22,7 @@ #include #endif #include +#include #include #include #include diff --git a/src/tracker/ATM.hpp b/src/tracker/ATM.hpp index c873081..948dfe3 100644 --- a/src/tracker/ATM.hpp +++ b/src/tracker/ATM.hpp @@ -21,6 +21,7 @@ #define _TRACKER_ATM_h_ #include #include +#include #include namespace FACETRACKER { diff --git a/src/tracker/FDet.hpp b/src/tracker/FDet.hpp index e59c8af..e64818b 100644 --- a/src/tracker/FDet.hpp +++ b/src/tracker/FDet.hpp @@ -20,6 +20,7 @@ #ifndef _TRACKER_FDet_h_ #define _TRACKER_FDet_h_ #include +#include namespace FACETRACKER { //=========================================================================== diff --git a/src/tracker/Patch.hpp b/src/tracker/Patch.hpp index eebad36..ae44f9c 100644 --- a/src/tracker/Patch.hpp +++ b/src/tracker/Patch.hpp @@ -20,6 +20,7 @@ #ifndef _TRACKER_Patch_h_ #define _TRACKER_Patch_h_ #include +#include namespace FACETRACKER { //=========================================================================== diff --git a/src/tracker/Warp.hpp b/src/tracker/Warp.hpp index acb9bb3..f2e894b 100644 --- a/src/tracker/Warp.hpp +++ b/src/tracker/Warp.hpp @@ -20,6 +20,7 @@ #ifndef _TRACKER_Warp_h_ #define _TRACKER_Warp_h_ #include +#include namespace FACETRACKER { //=========================================================================== diff --git a/src/utils/helpers.cpp b/src/utils/helpers.cpp index feb1f39..b005ab0 100644 --- a/src/utils/helpers.cpp +++ b/src/utils/helpers.cpp @@ -20,10 +20,13 @@ #include "helpers.hpp" #include #include +#include +#include #include #include #include #include +#include bool nan_p(double value) From 02883e156482e124216459ded9e8d50f6e8b7dcf Mon Sep 17 00:00:00 2001 From: Yantao Xie Date: Mon, 30 Mar 2015 18:01:54 +0800 Subject: [PATCH 05/29] Missing including a head file: Foundation/NSValue.h. --- src/qt-gui/osx-configuration.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt-gui/osx-configuration.mm b/src/qt-gui/osx-configuration.mm index 2e3e1f6..4d841f5 100644 --- a/src/qt-gui/osx-configuration.mm +++ b/src/qt-gui/osx-configuration.mm @@ -19,6 +19,7 @@ #include #include +#include #include #include #include From 4f878b4b7d8ed2f8b3eeadd79fcdcbf9dba1b83c Mon Sep 17 00:00:00 2001 From: Yantao Xie Date: Mon, 30 Mar 2015 18:03:11 +0800 Subject: [PATCH 06/29] Fix a character case error. --- src/qt-gui/gui/worker-thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt-gui/gui/worker-thread.cpp b/src/qt-gui/gui/worker-thread.cpp index 880565d..f420753 100644 --- a/src/qt-gui/gui/worker-thread.cpp +++ b/src/qt-gui/gui/worker-thread.cpp @@ -24,7 +24,7 @@ #include #include -#include "avatar/avatar.hpp" +#include "avatar/Avatar.hpp" #include "gui/avatar.hpp" #include "configuration.hpp" From 5b42c0a49a671d3782112a181241f0965f7dc96f Mon Sep 17 00:00:00 2001 From: Yantao Xie Date: Mon, 30 Mar 2015 18:09:48 +0800 Subject: [PATCH 07/29] Make qt-gui build successfully with GNUStep on linux. --- src/qt-gui/CMakeLists.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/qt-gui/CMakeLists.txt b/src/qt-gui/CMakeLists.txt index 8ddb0a4..dd84111 100644 --- a/src/qt-gui/CMakeLists.txt +++ b/src/qt-gui/CMakeLists.txt @@ -36,8 +36,20 @@ SET(MOC_HEADERS QT4_WRAP_CPP(MOC_SRCS ${MOC_HEADERS}) INCLUDE_DIRECTORIES(".") -set_source_files_properties(osx-configuration.mm PROPERTIES COMPILE_FLAGS -ObjC++) - +IF(UNIX AND NOT APPLE) + INCLUDE_DIRECTORIES(/usr/local/include/GNUstep /usr/include/GNUstep) + EXECUTE_PROCESS(COMMAND gnustep-config --objc-flags + OUTPUT_VARIABLE GnuStep_FLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + EXECUTE_PROCESS(COMMAND gnustep-config --base-libs + OUTPUT_VARIABLE GnuStep_LINK_FLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + STRING(REPLACE "\n" "" GnuStep_FLAGS ${GnuStep_FLAGS}) + STRING(REPLACE "\n" "" GnuStep_LINK_FLAGS ${GnuStep_LINK_FLAGS}) + set_source_files_properties(osx-configuration.mm PROPERTIES COMPILE_FLAGS "${GnuStep_FLAGS}") +ELSE() + set_source_files_properties(osx-configuration.mm PROPERTIES COMPILE_FLAGS -ObjC++) +ENDIF() add_executable(demo-application main.cpp @@ -65,6 +77,10 @@ ADD_EXECUTABLE(${BundleName} MACOSX_BUNDLE ${MOC_SRCS} ${EXTRA_SRC} ) +IF(UNIX AND NOT APPLE) + SET_TARGET_PROPERTIES(${BundleName} PROPERTIES + LINK_FLAGS "${GnuStep_LINK_FLAGS}") +ENDIF() TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} ${QT_LIBRARIES} clmTracker avatarAnim ${EXTRA_LIBS}) From d221892cf9c612819db99c404ae738d85dbead38 Mon Sep 17 00:00:00 2001 From: Yantao Xie Date: Wed, 26 Aug 2015 11:59:38 +0800 Subject: [PATCH 08/29] update .gitignore. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4686482..1c65011 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ build/* config.log config.status .DS_Store -*~ \ No newline at end of file +*~ +/_build* From cda7f3322db41cbe2fd5256f022f167131996c3c Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Tue, 22 Sep 2015 11:25:50 +0800 Subject: [PATCH 09/29] Fix file name --- src/qt-gui/gui/worker-thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt-gui/gui/worker-thread.cpp b/src/qt-gui/gui/worker-thread.cpp index 880565d..f420753 100644 --- a/src/qt-gui/gui/worker-thread.cpp +++ b/src/qt-gui/gui/worker-thread.cpp @@ -24,7 +24,7 @@ #include #include -#include "avatar/avatar.hpp" +#include "avatar/Avatar.hpp" #include "gui/avatar.hpp" #include "configuration.hpp" From 818bad3e8a1cbc872e675b5c0fed185f38a5af83 Mon Sep 17 00:00:00 2001 From: GeorgeChan Date: Fri, 18 Dec 2015 00:25:25 +0800 Subject: [PATCH 10/29] Support OpenCV 3.0.0 --- src/tracker/ATM.cpp | 1 + src/tracker/Detector.cpp | 10 +++++----- src/tracker/FDet.cpp | 1 + src/tracker/FaceTracker.cpp | 2 +- src/tracker/IO.cpp | 12 ++++++------ src/tracker/Patch.cpp | 1 + src/tracker/RegistrationCheck.cpp | 1 + src/tracker/ShapePredictor.cpp | 22 +++++++++++----------- src/tracker/ShapePredictor.hpp | 2 +- src/tracker/Warp.cpp | 1 + src/tracker/myFaceTracker.cpp | 3 ++- 11 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/tracker/ATM.cpp b/src/tracker/ATM.cpp index 4cd88e5..d9bb7cd 100644 --- a/src/tracker/ATM.cpp +++ b/src/tracker/ATM.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #define it at #define db at diff --git a/src/tracker/Detector.cpp b/src/tracker/Detector.cpp index c5cf1c2..1c0a083 100644 --- a/src/tracker/Detector.cpp +++ b/src/tracker/Detector.cpp @@ -18,7 +18,7 @@ // Copyright CSIRO 2013 #include - +#include #include "Detector.hpp" #include "IO.hpp" @@ -136,7 +136,7 @@ Detector::getResponsesForRefShape(cv::Mat r, double *sc_) double theta, scale; Align2DShapes(sh, _refs_zm, scale, theta); if(fabs(theta) > .1){ - std::cerr << "Reference shapes can only differ in scale" << std::endl; + // std::cerr << "Reference shapes can only differ in scale" << std::endl; exit(-1); } if(sc_) *sc_ = scale; @@ -162,7 +162,7 @@ Detector::getResponsesForRefShape(cv::Size wSize, cv::Mat r) double theta, scale; Align2DShapes(sh, _refs_zm, scale, theta); if(fabs(theta) > .1){ - std::cerr << "Reference shapes can only differ in scale" << std::endl; + // std::cerr << "Reference shapes can only differ in scale" << std::endl; exit(-1); } if(fabs(scale-1.)<1e-2) @@ -296,8 +296,8 @@ DetectorNCC::Write(std::ofstream &s, bool binary) void DetectorNCC::Read(std::ifstream &, bool) { - std::cerr << "Reading DetectorNCC objects from text files is not supported" - << std::endl; + // std::cerr << "Reading DetectorNCC objects from text files is not supported" + // << std::endl; exit(-1); } diff --git a/src/tracker/FDet.cpp b/src/tracker/FDet.cpp index 7940430..5c86d2b 100644 --- a/src/tracker/FDet.cpp +++ b/src/tracker/FDet.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include using namespace FACETRACKER; using namespace std; diff --git a/src/tracker/FaceTracker.cpp b/src/tracker/FaceTracker.cpp index 88cdec4..a8888d6 100644 --- a/src/tracker/FaceTracker.cpp +++ b/src/tracker/FaceTracker.cpp @@ -16,7 +16,7 @@ // most directory of the source code. // Copyright CSIRO 2013 - +#include #include #include #include diff --git a/src/tracker/IO.cpp b/src/tracker/IO.cpp index d6d3519..fff30a9 100644 --- a/src/tracker/IO.cpp +++ b/src/tracker/IO.cpp @@ -237,10 +237,10 @@ void IOBinary::ReadMat(std::ifstream &s, cv::Mat &M) s.read((char*)&c, sizeof(int)); s.read((char*)&t, sizeof(int)); M = cv::Mat(r,c,t); - s.read(reinterpret_cast(M.datastart), M.total()*M.elemSize()); + s.read((char*)(M.datastart), M.total() * M.elemSize()); if(!s.good()){ - std::cout << "Error reading matrix" << std::endl; + // std::cout << "Error reading matrix" << std::endl; } // std::cout << "Mat read: "<< r << "x"<(&M.rows), sizeof(int)); - s.write(reinterpret_cast(&M.cols), sizeof(int)); - s.write(reinterpret_cast(&t), sizeof(int)); + s.write(reinterpret_cast(&M.rows), sizeof(int)); + s.write(reinterpret_cast(&M.cols), sizeof(int)); + s.write(reinterpret_cast(&t), sizeof(int)); // s << M.rows << " " << M.cols << " " << M.type(); - s.write(reinterpret_cast(M.datastart), M.total()*M.elemSize()); + s.write(reinterpret_cast(M.datastart), M.total() * M.elemSize()); // std::cout << "Mat written: "<< M.rows << "x"<< M.cols << ", type " << M.type() << std::endl; diff --git a/src/tracker/Patch.cpp b/src/tracker/Patch.cpp index f1cb068..9a58c22 100644 --- a/src/tracker/Patch.cpp +++ b/src/tracker/Patch.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include #define SGN(x) ((x<0) ? 0:1) using namespace FACETRACKER; diff --git a/src/tracker/RegistrationCheck.cpp b/src/tracker/RegistrationCheck.cpp index ef057c5..5e6b8ba 100644 --- a/src/tracker/RegistrationCheck.cpp +++ b/src/tracker/RegistrationCheck.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include using namespace FACETRACKER; using namespace std; diff --git a/src/tracker/ShapePredictor.cpp b/src/tracker/ShapePredictor.cpp index e65655d..b793515 100644 --- a/src/tracker/ShapePredictor.cpp +++ b/src/tracker/ShapePredictor.cpp @@ -16,7 +16,7 @@ // most directory of the source code. // Copyright CSIRO 2013 - +#include #include #include #define db at @@ -31,9 +31,9 @@ ShapePredictor& ShapePredictor::operator= (ShapePredictor const&rhs) _rect = rhs._rect; _pdm = rhs._pdm; _warp = rhs._warp; - _C.resize(_K); _R.resize(_K); + _CC.resize(_K); _R.resize(_K); for(int i = 0; i < _K; i++){ - _C[i] = rhs._C[i].clone(); + _CC[i] = rhs._CC[i].clone(); _R[i] = rhs._R[i].clone(); } x_.create(_warp._nPix+1,1,CV_64F); @@ -66,9 +66,9 @@ void ShapePredictor::Save(const char* fname, bool binary) //============================================================================== void ShapePredictor::Read(ifstream &s) { - s >> _K; _C.resize(_K); _R.resize(_K); + s >> _K; _CC.resize(_K); _R.resize(_K); for(int i = 0; i < _K; i++){ - FACETRACKER::IO::ReadMat(s,_C[i]); + FACETRACKER::IO::ReadMat(s,_CC[i]); FACETRACKER::IO::ReadMat(s,_R[i]); } FACETRACKER::IO::ReadMat(s,_idx); @@ -91,9 +91,9 @@ void ShapePredictor::ReadBinary(ifstream &s, bool readType) } s.read(reinterpret_cast(&_K), sizeof(_K)); - _C.resize(_K); _R.resize(_K); + _CC.resize(_K); _R.resize(_K); for(int i = 0; i < _K; i++){ - FACETRACKER::IOBinary::ReadMat(s,_C[i]); + FACETRACKER::IOBinary::ReadMat(s,_CC[i]); FACETRACKER::IOBinary::ReadMat(s,_R[i]); } FACETRACKER::IOBinary::ReadMat(s,_idx); @@ -112,7 +112,7 @@ void ShapePredictor::Write(ofstream &s, bool binary) if(!binary){ s << _K << " "; for(int i = 0; i < _K; i++){ - FACETRACKER::IO::WriteMat(s,_C[i]); + FACETRACKER::IO::WriteMat(s,_CC[i]); FACETRACKER::IO::WriteMat(s,_R[i]); } FACETRACKER::IO::WriteMat(s,_idx); @@ -125,7 +125,7 @@ void ShapePredictor::Write(ofstream &s, bool binary) s.write(reinterpret_cast(&t), sizeof(t)); s.write(reinterpret_cast(&_K), sizeof(_K)); for(int i = 0; i < _K; i++){ - FACETRACKER::IOBinary::WriteMat(s,_C[i]); + FACETRACKER::IOBinary::WriteMat(s,_CC[i]); FACETRACKER::IOBinary::WriteMat(s,_R[i]); } FACETRACKER::IOBinary::WriteMat(s,_idx); @@ -162,11 +162,11 @@ int ShapePredictor::FindCluster(cv::Mat &shape) } double a1,b1,tx1,ty1,a2,b2,tx2,ty2,v,vmin = 0; int l = -1; cv::Mat S; for(int k = 0; k < _K; k++){ - FACETRACKER::CalcSimT(_C[k],z_,a1,b1,tx1,ty1); + FACETRACKER::CalcSimT(_CC[k],z_,a1,b1,tx1,ty1); FACETRACKER::invSimT(a1,b1,tx1,ty1,a2,b2,tx2,ty2); z_.copyTo(y_); FACETRACKER::SimT(y_,a2,b2,tx2,ty2); - v = cv::norm(y_,_C[k]); + v = cv::norm(y_,_CC[k]); if((v < vmin) || (l < 0)){vmin = v; l = k;} }return l; } diff --git a/src/tracker/ShapePredictor.hpp b/src/tracker/ShapePredictor.hpp index 0456ddd..7987a89 100644 --- a/src/tracker/ShapePredictor.hpp +++ b/src/tracker/ShapePredictor.hpp @@ -31,7 +31,7 @@ namespace FACETRACKER cv::Rect _rect; FACETRACKER::PDM2D _pdm; FACETRACKER::PAW _warp; - std::vector _C,_R; + std::vector _CC,_R; ShapePredictor(){;} ShapePredictor(const char* fname, bool binary = false){this->Load(fname, binary);} diff --git a/src/tracker/Warp.cpp b/src/tracker/Warp.cpp index 308a0c1..5dc8e0f 100644 --- a/src/tracker/Warp.cpp +++ b/src/tracker/Warp.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include #define it at #define db at diff --git a/src/tracker/myFaceTracker.cpp b/src/tracker/myFaceTracker.cpp index 091581e..c4ce579 100644 --- a/src/tracker/myFaceTracker.cpp +++ b/src/tracker/myFaceTracker.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include #define it at #define db at @@ -444,7 +445,7 @@ myFaceTracker::NewFrame(cv::Mat &im, if(p->init_type == 0) _clm.Fit(gray_,p->init_wSize,p->itol,p->clamp,p->ftol); else{ - std::cerr << "Bad init_type "<init_type << ". init_type should be 0" << std::endl; + // std::cerr << "Bad init_type "<init_type << ". init_type should be 0" << std::endl; abort(); } // myInitData data; data.calculate = true; From 7308c292ad06b2f40c7cf110a5d5ee480d2f8dd0 Mon Sep 17 00:00:00 2001 From: Luiz Carlos Vieira Date: Sat, 5 Mar 2016 01:15:28 -0300 Subject: [PATCH 11/29] First part of the Windows port: fixed compilation errors and warnings --- CMakeLists.txt | 11 ++++-- README | 12 +++++- src/avatar/myAvatar.cpp | 61 ++++++++++++++++--------------- src/create-avatar-model/main.cpp | 1 + src/display-3d-points/main.cpp | 1 + src/display-tracking/main.cpp | 3 +- src/face-fit/main.cpp | 11 +++--- src/map-list/main.cpp | 50 +++++++++++++++++++++++++ src/scripts/CMakeLists.txt | 2 +- src/test/command-line-options.cpp | 2 + src/test/speed_test.cpp | 23 ++++++------ src/test/test_Avatar.cpp | 41 +++++++++++++++++---- src/tracker/ATM.cpp | 1 + src/tracker/CLM.cpp | 4 +- src/tracker/Detector.cpp | 7 +++- src/tracker/FDet.cpp | 30 +++++++-------- src/tracker/FaceTracker.hpp | 10 +++++ src/tracker/IO.cpp | 7 +++- src/tracker/Patch.cpp | 3 +- src/tracker/RegistrationCheck.cpp | 1 + src/tracker/ShapePredictor.cpp | 1 + src/tracker/Warp.cpp | 1 + src/tracker/myFaceTracker.cpp | 7 ++-- src/utils/helpers.cpp | 37 +++++++++++++++++-- src/utils/helpers.hpp | 1 + 25 files changed, 238 insertions(+), 90 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d66373..02ff718 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,13 +46,16 @@ endif() SET(CMAKE_BUILD_TYPE Release CACHE STRING "") # - flags -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -Wall -Wextra -DDEBUG") -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -Wall -Wextra -DDEBUG") +if(UNIX) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -Wall -Wextra -DDEBUG") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -Wall -Wextra -DDEBUG") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3 -Wall -Wextra") -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall -O3 -Wextra") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3 -Wall -Wextra") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall -O3 -Wextra") +endif() SET(LIBS ${OpenCV_LIBS} ${EXTRA_LIBS}) +INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) # Build paths SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") diff --git a/README b/README index 44c1004..593685b 100644 --- a/README +++ b/README @@ -17,4 +17,14 @@ Single Image", AFGR Workshop 2011. If you use the SDK, we ask that you reference the following paper: M. Cox, J. Nuevo, J. Saragih and S. Lucey, "CSIRO Face Analysis SDK", -AFGR 2013. \ No newline at end of file +AFGR 2013. + +--- + +Here are my updates in the original code, included in this fork of the project: + +- added OpenCV missing includes (perhaps due to changes in version used?) +- type casts were made explicit to remove the warning messages +- array allocations were replaced with the operator `new[]` +- Windows/POSIX-specific function calls were enclosed in `#ifdefs` based on the operating system defined at compilation time, and the the best corresponding functions were used for Windows (for instance: `PathRemoveFileSpec` and `PathStripPath` respectively replaced `dirname` and `basename` in Windows). +- the class `ForkRunner` was completely replaced in Windows by the implementation proposed by Ben Howell [here](http://www.benhowell.net/guide/2015/03/16/porting-face-analysis-sdk-to-windows/); although [there is no direct equivalent of `fork` (used by the original class) on Windows](http://stackoverflow.com/a/9148072/2896619) and [`CreateProcess` does not have the same behaviour](http://stackoverflow.com/q/985281/2896619). \ No newline at end of file diff --git a/src/avatar/myAvatar.cpp b/src/avatar/myAvatar.cpp index 194f763..f45a9f4 100644 --- a/src/avatar/myAvatar.cpp +++ b/src/avatar/myAvatar.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #define it at #define db at using namespace AVATAR; @@ -342,8 +343,8 @@ myAvatar::Animate(cv::Mat &draw, dx0_ = dx; dy0_ = dy; this->GetWidthHeight(_shapes[_idx],_lpupil[_idx].idx,wl,hl); this->GetWidthHeight(_shapes[_idx],_rpupil[_idx].idx,wr,hr); - lp.x = _lpupil[_idx].px + dx*wl; lp.y = _lpupil[_idx].py + dy*hl; - rp.x = _rpupil[_idx].px + dx*wr; rp.y = _rpupil[_idx].py + dy*hr; + lp.x = (int) (_lpupil[_idx].px + dx*wl); lp.y = (int) (_lpupil[_idx].py + dy*hl); + rp.x = (int) (_rpupil[_idx].px + dx*wr); rp.y = (int) (_rpupil[_idx].py + dy*hr); this->WarpBackPupils(lp,rp,_shapes[_idx],_shape); _gpdm.CalcParams(shape,gplocal_,gpglobl_); lrad = _lpupil[_idx].rad*gpglobl_.db(0,0); @@ -468,8 +469,8 @@ void myAvatar::WarpTexture(cv::Mat &src_pts,cv::Mat &dst_pts, if(ymin > src_pts.db(n+i,0))ymin = src_pts.db(n+i,0); if(ymax < src_pts.db(n+i,0))ymax = src_pts.db(n+i,0); } - cv::Rect R(floor(xmin),floor(ymin), - ceil(xmax-xmin),ceil(ymax-ymin)); + cv::Rect R((int)floor(xmin), (int)floor(ymin), + (int)ceil(xmax-xmin), (int)ceil(ymax-ymin)); if(R.width*R.height > 1){ cv::Mat M(R.height,3*R.width,CV_8U); for(int i = 0; i < 3; i++){ @@ -669,7 +670,7 @@ myAvatar::GetPupil(cv::Mat &im, if((rect.width <= 0) || (rect.height <= 0)){ cv::Point p(0,0); for(int i = 0; i < idx.rows; i++){ - p.x += pt.db(i,0); p.y += pt.db(i+idx.rows,0); + p.x += (int) (pt.db(i,0)); p.y += (int) (pt.db(i+idx.rows,0)); } p.x /= idx.rows; p.y /= idx.rows; return p; } @@ -677,7 +678,7 @@ myAvatar::GetPupil(cv::Mat &im, (rect.y < 0) || (rect.y + rect.height >= im.rows)){ cv::Point p; p.x = 0; p.y = 0; for(int i = 0; i < idx.rows; i++){ - p.x += pt.db(i,0); p.y += pt.db(i+idx.rows,0); + p.x += (int) (pt.db(i,0)); p.y += (int) (pt.db(i+idx.rows,0)); } p.x /= idx.rows; p.y /= idx.rows; return p; } @@ -694,10 +695,10 @@ myAvatar::GetPupil(cv::Mat &im, if(sum == 0){ p.x = 0; p.y = 0; for(int i = 0; i < idx.rows; i++){ - p.x += pt.db(i,0); p.y += pt.db(i+idx.rows,0); + p.x += (int) (pt.db(i,0)); p.y += (int) (pt.db(i+idx.rows,0)); } p.x /= idx.rows; p.y /= idx.rows; - }else{p.x = vx/sum; p.y = vy/sum;} + }else{p.x = (int) (vx/sum); p.y = (int) (vy/sum);} return p; } //============================================================================== @@ -714,7 +715,7 @@ myAvatar::GetBoundingBox(cv::Mat &pt) if(ymin > pt.db(i+n,0))ymin = pt.db(i+n,0); if(ymax < pt.db(i+n,0))ymax = pt.db(i+n,0); } - cv::Rect r(xmin,ymin,xmax-xmin,ymax-ymin); return r; + cv::Rect r((int)xmin, (int)ymin, (int)(xmax-xmin), (int)(ymax-ymin)); return r; } //============================================================================== void @@ -743,9 +744,9 @@ myAvatar::DrawPupil(double px, double vx = (pupil[0].cols-1)/2 + (x-px)*((pupil[0].cols-1)/2)/rad; double vy = (pupil[0].rows-1)/2 + (y-py)*((pupil[0].rows-1)/2)/rad; for(int i = 0; i < 3; i++){ - img[i].at(y,x) = FACETRACKER::bilinInterp(pupil[i],vx,vy); + img[i].at(y,x) = (uchar) FACETRACKER::bilinInterp(pupil[i],vx,vy); } - }else{for(int i = 0; i < 3; i++)img[i].at(y,x) = b.val[i];} + }else{for(int i = 0; i < 3; i++)img[i].at(y,x) = (uchar) b.val[i];} } } } @@ -768,7 +769,7 @@ myAvatar::WarpBackLeftPupil(cv::Point &p, cv::solve(X,Y,Z,cv::DECOMP_SVD); double a = Z.db(0,0),b = Z.db(1,0),x = Z.db(2,0),y = Z.db(3,0); double vx = a*p.x + b*p.y + x,vy = a*p.y - b*p.x + y; - cv::Point P(vx,vy); return P; + cv::Point P((int)vx, (int)vy); return P; } //============================================================================= cv::Point @@ -787,7 +788,7 @@ myAvatar::WarpBackRightPupil(cv::Point &p, cv::solve(X,Y,Z,cv::DECOMP_SVD); double a = Z.db(0,0),b = Z.db(1,0),x = Z.db(2,0),y = Z.db(3,0); double vx = a*p.x + b*p.y + x,vy = a*p.y - b*p.x + y; - cv::Point P(vx,vy); return P; + cv::Point P((int)vx, (int)vy); return P; } //============================================================================= void @@ -1054,8 +1055,8 @@ void myAvatar::AddAvatar(cv::Mat &image, cv::Mat &points, cv::Mat &eyes) rrpupil.scelera = cv::Scalar(150,150,150); cv::Mat limg = cv::Mat::zeros(101,101,CV_8UC3); cv::Mat rimg = cv::Mat::zeros(101,101,CV_8UC3); - cv::circle(limg,cv::Point((limg.rows-1)/2,(limg.rows-1)/2), - (limg.rows-1)*0.3,CV_RGB(50,50,50),(limg.rows-1)/4); + cv::circle(limg,cv::Point((int)((limg.rows-1)/2), (int)((limg.rows-1)/2)), + (int)((limg.rows-1)*0.3),CV_RGB(50,50,50), (int)((limg.rows-1)/4)); cv::circle(rimg,cv::Point((rimg.rows-1)/2,(rimg.rows-1)/2), (rimg.rows-1)/4,CV_RGB(50,50,50),(limg.rows-1)/4); llpupil.image.resize(3); cv::split(limg,llpupil.image); @@ -1172,7 +1173,7 @@ void myAvatar::GetEyes(cv::Mat &pt,cv::Mat &im, for(int x = 0; x < size; x++){ double v = sqrt((y-(size-1)/2)*(y-(size-1)/2) + (x-(size-1)/2)*(x-(size-1)/2)); - int vi = floor((double(d)-1.0)*v/((size-1)/2)); + int vi = (int) floor((double(d)-1.0)*v/((size-1)/2)); if(v < (size-1)/2){ double xl = cxl + (x - (size-1)/2)*lrad/((size-1)/2); double yl = cyl + (y - (size-1)/2)*lrad/((size-1)/2); @@ -1183,14 +1184,14 @@ void myAvatar::GetEyes(cv::Mat &pt,cv::Mat &im, lrgb[i].at(y,x) = (uchar)FACETRACKER::bilinInterp(rgb[i],xl,yl); }else{ - for(int i = 0; i < 3; i++)lrgb[i].at(y,x) = Tl.db(vi+d*i,0); + for(int i = 0; i < 3; i++)lrgb[i].at(y,x) = (uchar) Tl.db(vi+d*i,0); } if(FACETRACKER::isWithinTri(xr,yr,tri,rpt)>=0){ for(int i = 0; i < 3; i++) rrgb[i].at(y,x) = (uchar)FACETRACKER::bilinInterp(rgb[i],xr,yr); }else{ - for(int i = 0; i < 3; i++)rrgb[i].at(y,x) = Tr.db(vi+d*i,0); + for(int i = 0; i < 3; i++)rrgb[i].at(y,x) = (uchar) Tr.db(vi+d*i,0); } } } @@ -1256,12 +1257,12 @@ myAvatarParams::Load(const char* fname, bool binary) ifstream file(fname); assert(file.is_open()); int t; file >> t; assert(t == AVATAR::IO::MYAVATARPARAMS); - file >> t; animate_rigid = bool(t); - file >> t; animate_exprs = bool(t); - file >> t; animate_textr = bool(t); - file >> t; animate_eyes = bool(t); - file >> t; avatar_shape = bool(t); - file >> t; oral_cavity = bool(t); + file >> t; animate_rigid = (t != 0); + file >> t; animate_exprs = (t != 0); + file >> t; animate_textr = (t != 0); + file >> t; animate_eyes = (t != 0); + file >> t; avatar_shape = (t != 0); + file >> t; oral_cavity = (t != 0); file >> alpha; file.close(); type = AVATAR::IO::MYAVATARPARAMS; } @@ -1271,12 +1272,12 @@ myAvatarParams::Load(const char* fname, bool binary) s.read(reinterpret_cast(&t), sizeof(t)); assert(t == AVATAR::IOBinary::MYAVATARPARAMS); - s.read(reinterpret_cast(&t), sizeof(t)); animate_rigid = (bool)t; - s.read(reinterpret_cast(&t), sizeof(t)); animate_exprs = (bool)t; - s.read(reinterpret_cast(&t), sizeof(t)); animate_textr = (bool)t; - s.read(reinterpret_cast(&t), sizeof(t)); animate_eyes = (bool)t; - s.read(reinterpret_cast(&t), sizeof(t)); avatar_shape = (bool)t; - s.read(reinterpret_cast(&t), sizeof(t)); oral_cavity = (bool)t; + s.read(reinterpret_cast(&t), sizeof(t)); animate_rigid = (t != 0); + s.read(reinterpret_cast(&t), sizeof(t)); animate_exprs = (t != 0); + s.read(reinterpret_cast(&t), sizeof(t)); animate_textr = (t != 0); + s.read(reinterpret_cast(&t), sizeof(t)); animate_eyes = (t != 0); + s.read(reinterpret_cast(&t), sizeof(t)); avatar_shape = (t != 0); + s.read(reinterpret_cast(&t), sizeof(t)); oral_cavity = (t != 0); s.read(reinterpret_cast(&alpha), sizeof(alpha)); type = AVATAR::IO::MYAVATARPARAMS; s.close(); diff --git a/src/create-avatar-model/main.cpp b/src/create-avatar-model/main.cpp index 423caec..25c043d 100644 --- a/src/create-avatar-model/main.cpp +++ b/src/create-avatar-model/main.cpp @@ -4,6 +4,7 @@ #include "avatar/myAvatar.hpp" #include +#include void print_usage() diff --git a/src/display-3d-points/main.cpp b/src/display-3d-points/main.cpp index 792068f..d822960 100644 --- a/src/display-3d-points/main.cpp +++ b/src/display-3d-points/main.cpp @@ -4,6 +4,7 @@ #include "tracker/FaceTracker.hpp" #include +#include void print_usage() diff --git a/src/display-tracking/main.cpp b/src/display-tracking/main.cpp index 9eed15d..64c35ce 100644 --- a/src/display-tracking/main.cpp +++ b/src/display-tracking/main.cpp @@ -22,6 +22,7 @@ #include "utils/points.hpp" #include #include +#include void print_usage() @@ -98,7 +99,7 @@ run_program(int argc, char **argv) cv::imwrite(output_pathname->c_str(), img); } else { cv::imshow("Image", img); - cv::waitKey(1000*wait_time); + cv::waitKey((int) (1000*wait_time)); } return 0; diff --git a/src/face-fit/main.cpp b/src/face-fit/main.cpp index b5b0deb..a29a4f0 100644 --- a/src/face-fit/main.cpp +++ b/src/face-fit/main.cpp @@ -22,6 +22,7 @@ #include "utils/points.hpp" #include "tracker/FaceTracker.hpp" #include +#include using namespace FACETRACKER; @@ -188,7 +189,7 @@ main(int argc, char **argv) { try { return run_program(argc, argv); - } catch (user_pressed_escape &e) { + } catch (user_pressed_escape) { std::cout << "Stopping prematurely." << std::endl; return 1; } catch (std::exception &e) { @@ -395,11 +396,11 @@ compute_pose_image(const Pose &pose, int height, int width) cv::Point centre(width/2, height/2); // pitch - cv::line(rv, centre, cv::Point(axes(0,0), axes(1,0)), cv::Scalar(255,0,0)); + cv::line(rv, centre, cv::Point((int)axes(0,0), (int)axes(1,0)), cv::Scalar(255,0,0)); // yaw - cv::line(rv, centre, cv::Point(axes(0,1), axes(1,1)), cv::Scalar(0,255,0)); + cv::line(rv, centre, cv::Point((int)axes(0,1), (int)axes(1,1)), cv::Scalar(0,255,0)); // roll - cv::line(rv, centre, cv::Point(axes(0,2), axes(1,2)), cv::Scalar(0,0,255)); + cv::line(rv, centre, cv::Point((int)axes(0,2), (int)axes(1,2)), cv::Scalar(0,0,255)); return rv; } @@ -448,7 +449,7 @@ display_data(const Configuration &cfg, if (cfg.wait_time == 0) std::cout << "Press any key to continue." << std::endl; - char ch = cv::waitKey(cfg.wait_time * 1000); + char ch = cv::waitKey((int) (cfg.wait_time * 1000)); if (ch == 27) // escape throw user_pressed_escape(); diff --git a/src/map-list/main.cpp b/src/map-list/main.cpp index 234b66f..d5a09b8 100644 --- a/src/map-list/main.cpp +++ b/src/map-list/main.cpp @@ -23,8 +23,14 @@ #include #include #include + +#ifdef _WIN32 +#include +#include +#else #include #include +#endif void print_usage() @@ -65,6 +71,49 @@ class EchoRunner : public Runner std::ostream &stream; }; +#ifdef _WIN32 +class ForkRunner : public Runner +{ +public: + void perform(const std::string &command, const std::list &arguments) { + + STARTUPINFO si; + PROCESS_INFORMATION pi; + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + if(!CreateProcess(NULL, "", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)){ //child process + char **argv = new char*[arguments.size() + 2]; + argv[0] = (char *)command.c_str(); + argv[arguments.size() + 1] = 0; + + std::list::const_iterator it = arguments.begin(); + for (size_t i = 0; i < arguments.size(); i++) { + argv[i + 1] = (char *)it->c_str(); + it++; + } + + int rv = _execvp(command.c_str(), argv); + delete[] argv; + if (rv == -1) + throw make_runtime_error("Unable to create new process: %s.", strerror(errno)); + } + else { // parent process + throw make_runtime_error("CreateProcess failed (%d).\n", GetLastError() ); + return; + } + + // Wait until child process exits. + WaitForSingleObject( pi.hProcess, INFINITE ); + + // Close process and thread handles. + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + } +}; +#else class ForkRunner : public Runner { public: @@ -103,6 +152,7 @@ class ForkRunner : public Runner } } }; +#endif int run_program(int argc, char **argv) diff --git a/src/scripts/CMakeLists.txt b/src/scripts/CMakeLists.txt index 24cac0c..398e3a5 100644 --- a/src/scripts/CMakeLists.txt +++ b/src/scripts/CMakeLists.txt @@ -13,7 +13,7 @@ foreach(_script ${generated_scripts}) configure_file(${_script}.in ${_script}) add_custom_command( OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_script} - COMMAND /usr/bin/install -m 755 ${_script} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_script} + COMMAND install -m 755 ${_script} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_script} DEPENDS ${_script}.in) list(APPEND executable_scripts ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_script}) endforeach() diff --git a/src/test/command-line-options.cpp b/src/test/command-line-options.cpp index 7dca9f0..11675a7 100644 --- a/src/test/command-line-options.cpp +++ b/src/test/command-line-options.cpp @@ -20,6 +20,8 @@ #include "command-line-options.hpp" #include #include +#include +#include //Utilities template diff --git a/src/test/speed_test.cpp b/src/test/speed_test.cpp index 8631926..0cf66b9 100644 --- a/src/test/speed_test.cpp +++ b/src/test/speed_test.cpp @@ -25,6 +25,7 @@ #include #include +#include "opencv2/opencv.hpp" #define db at #define it at @@ -54,14 +55,14 @@ void draw_shape(cv::Mat &image,cv::Mat &shape,cv::Mat &con) { int i,n = shape.rows/2; cv::Point p1,p2; for(i = 0; i < con.cols; i++){ - p1 = cv::Point(shape.at(con.at(0,i),0), - shape.at(con.at(0,i)+n,0)); - p2 = cv::Point(shape.at(con.at(1,i),0), - shape.at(con.at(1,i)+n,0)); + p1 = cv::Point((int)shape.at(con.at(0,i),0), + (int)shape.at(con.at(0,i)+n,0)); + p2 = cv::Point((int)shape.at(con.at(1,i),0), + (int)shape.at(con.at(1,i)+n,0)); cv::line(image,p1,p2,CV_RGB(0,255,0),1); } for(i = 0; i < n; i++){ - p1 = cv::Point(shape.at(i,0),shape.at(i+n,0)); + p1 = cv::Point((int)shape.at(i,0), (int)shape.at(i+n,0)); cv::circle(image,p1,2,CV_RGB(255,0,0)); }return; } @@ -69,9 +70,9 @@ void draw_shape(cv::Mat &image,cv::Mat &shape,cv::Mat &con) void draw_health(cv::Mat &I,int health) { double v = double(health)/10.0; - int w = 0.1*double(I.cols),h = 0.05*double(I.rows); + int w = (int)(0.1*double(I.cols)),h = (int) (0.05*double(I.rows)); cv::rectangle(I,cv::Point(h/2,h/2),cv::Point(w+h/2,h+h/2),CV_RGB(0,0,0),3); - cv::Mat im = I(cv::Rect(h/2+3,h/2+3,v*(w-5),h-5)); im = CV_RGB(0,0,255); + cv::Mat im = I(cv::Rect((int)(h/2+3), (int)(h/2+3), (int)(v*(w-5)), (int)(h-5))); im = CV_RGB(0,0,255); char str[256]; sprintf(str,"%d%%",(int)(100*v+0.5)); cv::putText(I,str,cv::Point(w+h/2+w/20,h+h/2), CV_FONT_HERSHEY_SIMPLEX,h*0.045,CV_RGB(0,0,255),2); return; @@ -140,7 +141,7 @@ int main(int argc, char** argv) try { camera_index = options.argument("camera", 0); - } catch (std::exception &e) { + } catch (std::exception) { camera_index = -1; } @@ -168,7 +169,7 @@ int main(int argc, char** argv) FACETRACKER::FaceTrackerParams * p = FACETRACKER::LoadFaceTrackerParams(face_tracker_parameters_file.c_str()); FACETRACKER::myFaceTrackerParams* pp = dynamic_cast(p); - pp->shape_predict = eye_mouth_refine; + pp->shape_predict = (eye_mouth_refine != 0); char* fname = NULL; cv::Mat con = FACETRACKER::IO::LoadCon(face_connections_file.c_str()); @@ -348,8 +349,8 @@ int main(int argc, char** argv) else if(c == int('i')){ avatar->Initialise(im,tracker->_shape); init = true; } - input_frame_last_captured += 1.0/(1000.0*cv::getTickFrequency()); - output_frame_last_output += 1.0/(1000.0*cv::getTickFrequency()); + input_frame_last_captured += (int) (1.0/(1000.0*cv::getTickFrequency())); + output_frame_last_output += (int) (1.0/(1000.0*cv::getTickFrequency())); int64 total2 = cv::getTickCount(); total_time += total2-total1; diff --git a/src/test/test_Avatar.cpp b/src/test/test_Avatar.cpp index e228cfa..a456b12 100644 --- a/src/test/test_Avatar.cpp +++ b/src/test/test_Avatar.cpp @@ -26,6 +26,11 @@ #include #include #include + +#ifdef _WIN32 +#include +#endif + #define db at #define it at //============================================================================= @@ -33,14 +38,14 @@ void draw_shape(cv::Mat &image,cv::Mat &shape,cv::Mat &con) { int i,n = shape.rows/2; cv::Point p1,p2; for(i = 0; i < con.cols; i++){ - p1 = cv::Point(shape.at(con.at(0,i),0), - shape.at(con.at(0,i)+n,0)); - p2 = cv::Point(shape.at(con.at(1,i),0), - shape.at(con.at(1,i)+n,0)); + p1 = cv::Point((int)shape.at(con.at(0,i),0), + (int)shape.at(con.at(0,i)+n,0)); + p2 = cv::Point((int)shape.at(con.at(1,i),0), + (int)shape.at(con.at(1,i)+n,0)); cv::line(image,p1,p2,CV_RGB(0,255,0),1); } for(i = 0; i < n; i++){ - p1 = cv::Point(shape.at(i,0),shape.at(i+n,0)); + p1 = cv::Point((int)shape.at(i,0), (int)shape.at(i+n,0)); cv::circle(image,p1,2,CV_RGB(255,0,0)); }return; } @@ -48,10 +53,17 @@ void draw_shape(cv::Mat &image,cv::Mat &shape,cv::Mat &con) void draw_health(cv::Mat &I,int health) { double v = MAX(0,double(health)/10.0); - int w = 0.1*double(I.cols),h = 0.05*double(I.rows); + int w = (int) (0.1*double(I.cols)), h = (int) (0.05*double(I.rows)); cv::rectangle(I,cv::Point(h/2,h/2),cv::Point(w+h/2,h+h/2),CV_RGB(0,0,0),3); - cv::Mat im = I(cv::Rect(h/2+3,h/2+3,v*(w-5),h-5)); im = CV_RGB(0,0,255); - char str[256]; sprintf(str,"%d%%",(int)(100*v+0.5)); + cv::Mat im = I(cv::Rect((int)(h/2+3), (int)(h/2+3), (int)(v*(w-5)), (int)(h-5))); im = CV_RGB(0,0,255); + char str[256]; + +#ifdef _WIN32 + sprintf_s(str, 256, "%d%%", (int)(100 * v + 0.5)); +#else + sprintf(str,"%d%%",(int)(100*v+0.5)); +#endif + cv::putText(I,str,cv::Point(w+h/2+w/20,h+h/2), CV_FONT_HERSHEY_SIMPLEX,h*0.045,CV_RGB(0,0,255),2); return; } @@ -106,9 +118,18 @@ int main(int argc, char *argv[]) if(!strcmp(argv[1], "-o")){ saveData = true; char fname[128]; + +#ifdef _WIN32 + time_t rawtime; + struct tm timeinfo; + localtime_s(&timeinfo, &rawtime); + strftime(fname, 128, "output_%Y_%m_%d_%H_%M_%S.xml", &timeinfo); +#else time_t rawtime; time(&rawtime); struct tm * timeinfo = localtime(&rawtime); strftime(fname, 128, "output_%Y_%m_%d_%H_%M_%S.xml", timeinfo); +#endif + outputFile = fname; camera.open(0); @@ -187,7 +208,11 @@ int main(int argc, char *argv[]) if(saveData){ char fnum[26]; +#ifdef _WIN32 + sprintf_s(fnum, 256, "frame_%05d", frameCount); +#else sprintf(fnum, "frame_%05d", frameCount); +#endif fs << std::string(fnum) << "{"; if(health>=0){ //save the 2D points to file diff --git a/src/tracker/ATM.cpp b/src/tracker/ATM.cpp index 4cd88e5..8d809b2 100644 --- a/src/tracker/ATM.cpp +++ b/src/tracker/ATM.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #define it at #define db at diff --git a/src/tracker/CLM.cpp b/src/tracker/CLM.cpp index 33c2189..7c67336 100644 --- a/src/tracker/CLM.cpp +++ b/src/tracker/CLM.cpp @@ -208,7 +208,7 @@ void CLM::Read(ifstream &s,bool readType) int n; s >> n; - _kWidth = 36.; + _kWidth = 36; _pdm.Read(s); _cent.resize(n); _visi.resize(n); @@ -255,7 +255,7 @@ void CLM::ReadBinary(ifstream &s,bool readType) } int n; - _kWidth = 36.; + _kWidth = 36; s.read(reinterpret_cast(&n), sizeof(n)); _pdm.ReadBinary(s); _cent.resize(n); diff --git a/src/tracker/Detector.cpp b/src/tracker/Detector.cpp index c5cf1c2..1d2c4a5 100644 --- a/src/tracker/Detector.cpp +++ b/src/tracker/Detector.cpp @@ -17,7 +17,10 @@ // Copyright CSIRO 2013 +#include + #include +#include #include "Detector.hpp" #include "IO.hpp" @@ -105,7 +108,7 @@ Detector::getResponsesForRefShape(double scale) if(scale == 1.) return prob_; else{ - cv::Size sz (prob_.at(0).cols / scale, prob_.at(0).rows/scale); + cv::Size sz ((int) (prob_.at(0).cols / scale), (int) (prob_.at(0).rows/scale)); bool t = false; if(sz.width%2==0){ sz.width++; t = true;} @@ -171,7 +174,7 @@ Detector::getResponsesForRefShape(cv::Size wSize, cv::Mat r) cv::Size sz; for (size_t i=0; i #include using namespace FACETRACKER; using namespace std; @@ -76,8 +76,8 @@ cv::Rect FDet::Detect(cv::Mat im) for(i = 0,maxv = 0; i < obj->total; i++){ CvRect* r = (CvRect*)cvGetSeqElem(obj,i); if(i == 0 || maxv < r->width*r->height){ - maxv = r->width*r->height; R.x = r->x*_img_scale; R.y = r->y*_img_scale; - R.width = r->width*_img_scale; R.height = r->height*_img_scale; + maxv = r->width*r->height; R.x = (int) (r->x*_img_scale); R.y = (int) (r->y*_img_scale); + R.width = (int) (r->width*_img_scale); R.height = (int) (r->height*_img_scale); } } cvRelease((void**)(&obj)); return R; @@ -384,10 +384,10 @@ cv::Rect SInit::ReDetect(cv::Mat &im) if(temp_.rows == 0)return cv::Rect(); int x,y; float v,vb=-2; int ww = im.cols,hh = im.rows; - int w = TSCALE*ww-temp_.cols+1,h = TSCALE*hh-temp_.rows+1; + int w = (int) (TSCALE*ww-temp_.cols+1),h = (int) (TSCALE*hh-temp_.rows+1); if((small_.rows != TSCALE*hh) || (small_.cols != TSCALE*ww)) - small_.create(TSCALE*hh,TSCALE*ww,CV_8U); - cv::resize(im,small_,cv::Size(TSCALE*ww,TSCALE*hh),0,0,CV_INTER_LINEAR); + small_.create((int)(TSCALE*hh),(int)(TSCALE*ww),CV_8U); + cv::resize(im,small_,cv::Size((int)(TSCALE*ww),(int)(TSCALE*hh)),0,0,CV_INTER_LINEAR); if((ncc_.rows != h) || (ncc_.cols != w))ncc_.create(h,w,CV_32F); IplImage im_o = small_,temp_o = temp_,ncc_o = ncc_; cvMatchTemplate(&im_o,&temp_o,&ncc_o,CV_TM_CCOEFF_NORMED); @@ -398,8 +398,8 @@ cv::Rect SInit::ReDetect(cv::Mat &im) v = *p++; if(v > vb){vb = v; R.x = x; R.y = y;} } } - R.x *= 1.0/TSCALE; R.y *= 1.0/TSCALE; - R.width *= 1.0/TSCALE; R.height *= 1.0/TSCALE; return R; + R.x = (int) (R.x * 1.0/TSCALE); R.y = (int) (R.y * 1.0/TSCALE); + R.width = (int) (R.width * 1.0/TSCALE); R.height = (int) (R.height * 1.0/TSCALE); return R; } //=========================================================================== cv::Rect SInit::Update(cv::Mat &im,cv::Mat &s,bool rsize) @@ -418,18 +418,18 @@ cv::Rect SInit::Update(cv::Mat &im,cv::Mat &s,bool rsize) return cv::Rect(0,0,0,0); else{ xmin *= TSCALE; ymin *= TSCALE; xmax *= TSCALE; ymax *= TSCALE; - cv::Rect R = cv::Rect(std::floor(xmin),std::floor(ymin), - std::ceil(xmax-xmin),std::ceil(ymax-ymin)); + cv::Rect R = cv::Rect((int)std::floor(xmin), (int)std::floor(ymin), + (int)std::ceil(xmax-xmin), (int)std::ceil(ymax-ymin)); int ww = im.cols,hh = im.rows; if(rsize){ if((small_.rows != TSCALE*hh) || (small_.cols != TSCALE*ww)) - small_.create(TSCALE*hh,TSCALE*ww,CV_8U); - cv::resize(im,small_,cv::Size(TSCALE*ww,TSCALE*hh),0,0,CV_INTER_LINEAR); + small_.create((int)(TSCALE*hh), (int)(TSCALE*ww),CV_8U); + cv::resize(im,small_,cv::Size((int)(TSCALE*ww), (int)(TSCALE*hh)),0,0,CV_INTER_LINEAR); } - cv::resize(im,small_,cv::Size(TSCALE*ww,TSCALE*hh),0,0,CV_INTER_LINEAR); + cv::resize(im,small_,cv::Size((int)(TSCALE*ww), (int)(TSCALE*hh)),0,0,CV_INTER_LINEAR); temp_ = small_(R).clone(); - R.x *= 1.0/TSCALE; R.y *= 1.0/TSCALE; - R.width *= 1.0/TSCALE; R.height *= 1.0/TSCALE; return R; + R.x = (int) (R.x * 1.0/TSCALE); R.y = (int) (R.y * 1.0/TSCALE); + R.width = (int) (R.width * 1.0/TSCALE); R.height = (int) (R.height * 1.0/TSCALE); return R; } } //=========================================================================== diff --git a/src/tracker/FaceTracker.hpp b/src/tracker/FaceTracker.hpp index 7b50459..f38be9f 100644 --- a/src/tracker/FaceTracker.hpp +++ b/src/tracker/FaceTracker.hpp @@ -19,6 +19,12 @@ #ifndef _TRACKER_FaceTracker_h_ #define _TRACKER_FaceTracker_h_ + +#ifdef _WIN32 + #include +#endif + +#include #include namespace FACETRACKER { @@ -54,7 +60,11 @@ namespace FACETRACKER void write_fps(cv::Mat &im){ //image to draw FPS on top left corner char str[256]; +#ifdef _WIN32 + sprintf_s(str, 256, "Tracker: %d fps", (int) round(_fps)); std::string text = str; +#else sprintf(str,"Tracker: %d fps",(int)round(_fps)); std::string text = str; +#endif cv::putText(im,text,cv::Point(10,im.rows-20), CV_FONT_HERSHEY_SIMPLEX,0.5,CV_RGB(255,255,255)); return; } diff --git a/src/tracker/IO.cpp b/src/tracker/IO.cpp index d6d3519..86475e1 100644 --- a/src/tracker/IO.cpp +++ b/src/tracker/IO.cpp @@ -19,6 +19,7 @@ #include #include +#include using namespace FACETRACKER; using namespace std; //=========================================================================== @@ -237,7 +238,8 @@ void IOBinary::ReadMat(std::ifstream &s, cv::Mat &M) s.read((char*)&c, sizeof(int)); s.read((char*)&t, sizeof(int)); M = cv::Mat(r,c,t); - s.read(reinterpret_cast(M.datastart), M.total()*M.elemSize()); + //s.read(reinterpret_cast(M.datastart), M.total()*M.elemSize()); + s.read((char*)(M.datastart), M.total()*M.elemSize()); if(!s.good()){ std::cout << "Error reading matrix" << std::endl; @@ -254,7 +256,8 @@ void IOBinary::WriteMat(std::ofstream &s, cv::Mat &M) s.write(reinterpret_cast(&M.cols), sizeof(int)); s.write(reinterpret_cast(&t), sizeof(int)); // s << M.rows << " " << M.cols << " " << M.type(); - s.write(reinterpret_cast(M.datastart), M.total()*M.elemSize()); + //s.write(reinterpret_cast(M.datastart), M.total()*M.elemSize()); + s.write((char*)(M.datastart), M.total()*M.elemSize()); // std::cout << "Mat written: "<< M.rows << "x"<< M.cols << ", type " << M.type() << std::endl; diff --git a/src/tracker/Patch.cpp b/src/tracker/Patch.cpp index f1cb068..0d4ff01 100644 --- a/src/tracker/Patch.cpp +++ b/src/tracker/Patch.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include #define SGN(x) ((x<0) ? 0:1) using namespace FACETRACKER; @@ -78,7 +79,7 @@ void LBP(cv::Mat &im,cv::Mat &lbp) v[4] = *p2++; v[0] = *p2++; v[5] = *p2; v[1] = *p1++; v[2] = *p1++; v[3] = *p1; v[6] = *p3++; v[7] = *p3++; v[8] = *p3; - *lp++ = + *lp++ = (float) SGN(v[0]-v[1])*2 + SGN(v[0]-v[2])*4 + SGN(v[0]-v[3])*8 + SGN(v[0]-v[4])*16 + SGN(v[0]-v[5])*32 + SGN(v[0]-v[6])*64 + diff --git a/src/tracker/RegistrationCheck.cpp b/src/tracker/RegistrationCheck.cpp index ef057c5..5bd433f 100644 --- a/src/tracker/RegistrationCheck.cpp +++ b/src/tracker/RegistrationCheck.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include using namespace FACETRACKER; using namespace std; diff --git a/src/tracker/ShapePredictor.cpp b/src/tracker/ShapePredictor.cpp index e65655d..e55256c 100644 --- a/src/tracker/ShapePredictor.cpp +++ b/src/tracker/ShapePredictor.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include #include #define db at diff --git a/src/tracker/Warp.cpp b/src/tracker/Warp.cpp index 308a0c1..9ea39e2 100644 --- a/src/tracker/Warp.cpp +++ b/src/tracker/Warp.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include #define it at #define db at diff --git a/src/tracker/myFaceTracker.cpp b/src/tracker/myFaceTracker.cpp index 091581e..11e5fcb 100644 --- a/src/tracker/myFaceTracker.cpp +++ b/src/tracker/myFaceTracker.cpp @@ -17,6 +17,7 @@ // Copyright CSIRO 2013 +#include #include #define it at #define db at @@ -243,7 +244,7 @@ void myFaceTrackerParams::Load(const char* fname, bool binary) >> gamma >> init_type >> track_type - >> t; shape_predict = t; + >> t; shape_predict = (t != 0); file >> t; init_wSize.resize(t); for(int i = 0; i < int(init_wSize.size()); i++)file >> init_wSize[i]; file >> t; track_wSize.resize(t); @@ -463,7 +464,7 @@ myFaceTracker::NewFrame(cv::Mat &im, else{ if(_atm._scale == 1)smooth_ = gray_; else{ - cv::Size ksize((1.0/_atm._scale)*3+1,(1.0/_atm._scale)*3+1); + cv::Size ksize((int) ((1.0/_atm._scale)*3+1), (int) ((1.0/_atm._scale)*3+1)); cv::GaussianBlur(gray_,smooth_,ksize,0,0); } vector visi; @@ -543,7 +544,7 @@ myFaceTracker::NewFrame(cv::Mat &im, if (_atm._scale == 1) { smooth_ = gray_; } else { - cv::Size ksize((1.0/p->atm_scale)*3+1,(1.0/p->atm_scale)*3+1); + cv::Size ksize((int) ((1.0/p->atm_scale)*3+1), (int) ((1.0/p->atm_scale)*3+1)); cv::GaussianBlur(gray_,smooth_,ksize,0,0); } _atm.Init(p->center,pose,_shape,smooth_,p->atm_tri,p->atm_scale); diff --git a/src/utils/helpers.cpp b/src/utils/helpers.cpp index feb1f39..d02d70e 100644 --- a/src/utils/helpers.cpp +++ b/src/utils/helpers.cpp @@ -19,11 +19,22 @@ #include "helpers.hpp" #include + +#ifdef _WIN32 +#define NOMINMAX +#include +#include "Shlwapi.h" +#else #include +#endif + #include #include #include #include +#include +#include +#include bool nan_p(double value) @@ -276,19 +287,37 @@ pathname_name(const std::string &pathname) std::string pathname_directory(const std::string &pathname) { - char buffer[pathname.size() + 1]; - memset(buffer, 0, sizeof(buffer)); - std::copy(pathname.begin(), pathname.end(), buffer); - return std::string(dirname(buffer)); +#ifdef _WIN32 + char *buffer = new char[pathname.size() + 1]; + memset(buffer, 0, pathname.size() + 1); + PathRemoveFileSpec(buffer); + std::string ret = std::string(buffer); + delete[] buffer; + return ret; +#else + char buffer[pathname.size() + 1]; + memset(buffer, 0, sizeof(buffer)); + std::copy(pathname.begin(), pathname.end(), buffer); + return std::string(dirname(buffer)); +#endif } std::string pathname_sans_directory(const std::string &pathname) { +#ifdef _WIN32 + char *buffer = new char[pathname.size() + 1]; + memset(buffer, 0, pathname.size() + 1); + PathStripPath(buffer); + std::string ret = std::string(buffer); + delete[] buffer; + return ret; +#else char buffer[pathname.size() + 1]; memset(buffer, 0, sizeof(buffer)); std::copy(pathname.begin(), pathname.end(), buffer); return std::string(basename(buffer)); +#endif } std::string diff --git a/src/utils/helpers.hpp b/src/utils/helpers.hpp index 08f71f5..56b7f1a 100644 --- a/src/utils/helpers.hpp +++ b/src/utils/helpers.hpp @@ -24,6 +24,7 @@ #include #include #include +#include //fixes issue with va_args /** Evaluates predicate on all items within the range (begin,end) until predicate is false, otherwise returns true. */ From 4de4bdb795d82b48ba73f84f79737a0cd73c603e Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Mon, 7 Mar 2016 01:13:57 +1100 Subject: [PATCH 12/29] Create INSTALL.md --- INSTALL.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 INSTALL.md diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..f22d61c --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,38 @@ +Make sure you have Bash, Cmake, Git, FFmpeg and OpenCV installed. + +If you're on Ubuntu, this should be enough: + +``` + # this installs a prebuilt opencv with python bindings along with some other tools + sudo apt-get install -y \ + git \ + pkg-config \ + build-essential \ + cmake \ + libopencv-dev \ + python-opencv \ + ffmpeg +``` + +Otherwise check: + +* http://milq.github.io/install-opencv-ubuntu-debian/ +* http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html +* http://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04 + +After you have all the dependencies, the build is simple: + +``` +# assuming you installed from libopencv-dev in ubuntu/debian +# if not, look for the directory that contains OpenCVConfig.cmake +path_to_opencv=$(dpkg --listfiles libopencv-dev | grep --max-count=1 'OpenCVConfig.cmake$') + +git clone https://github.com/MatrixAI/face-analysis-sdk +pushd face-analysis-sdk + mkdir -p build + pushd build + cmake -DOpenCV_DIR="$path_to_opencv" -DFFMPEG=$(which ffmpeg) -DBASH=$(which bash) .. + make + popd +popd +``` From ea86b383ff9435eb37d02e3d4788cff503a5f965 Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Mon, 7 Mar 2016 01:14:43 +1100 Subject: [PATCH 13/29] Update INSTALL.md --- INSTALL.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f22d61c..93e2ea3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,7 +2,7 @@ Make sure you have Bash, Cmake, Git, FFmpeg and OpenCV installed. If you're on Ubuntu, this should be enough: -``` +```sh # this installs a prebuilt opencv with python bindings along with some other tools sudo apt-get install -y \ git \ @@ -19,10 +19,11 @@ Otherwise check: * http://milq.github.io/install-opencv-ubuntu-debian/ * http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html * http://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04 +* https://help.ubuntu.com/community/OpenCV After you have all the dependencies, the build is simple: -``` +```sh # assuming you installed from libopencv-dev in ubuntu/debian # if not, look for the directory that contains OpenCVConfig.cmake path_to_opencv=$(dpkg --listfiles libopencv-dev | grep --max-count=1 'OpenCVConfig.cmake$') From eabf39ca17cbdde86461de45bb9a0aba90e2df2c Mon Sep 17 00:00:00 2001 From: Luiz Carlos Vieira Date: Sun, 6 Mar 2016 19:23:15 -0300 Subject: [PATCH 14/29] Second part of the Windows port: fixed link errors; upgraded to Qt5 --- CMakeLists.txt | 10 ++++-- README | 16 +++++----- src/avatar/CMakeLists.txt | 8 ++++- src/qt-gui/CMakeLists.txt | 36 ++++++++++++++-------- src/qt-gui/application-states.hpp | 2 +- src/qt-gui/configuration.hpp | 2 +- src/qt-gui/controllers.hpp | 4 +-- src/qt-gui/gui/avatar-selection.cpp | 4 +-- src/qt-gui/gui/avatar-selection.hpp | 8 ++--- src/qt-gui/gui/graphics-scrollbar.cpp | 6 ++-- src/qt-gui/gui/graphics-scrollbar.hpp | 10 +++--- src/qt-gui/gui/item-controllers.hpp | 6 ++-- src/qt-gui/gui/main-window.cpp | 12 ++++---- src/qt-gui/gui/main-window.hpp | 14 ++++----- src/qt-gui/gui/mesh-drawer.cpp | 4 +-- src/qt-gui/gui/mesh-drawer.hpp | 8 ++--- src/qt-gui/gui/windowed-gui-controller.hpp | 10 +++--- src/qt-gui/gui/worker-thread.hpp | 8 +++-- src/qt-gui/main.cpp | 8 ++--- src/tracker/CMakeLists.txt | 7 ++++- src/utils/CMakeLists.txt | 16 ++++++++-- 21 files changed, 122 insertions(+), 77 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02ff718..334a83f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,13 @@ endif() SET(CMAKE_BUILD_TYPE Release CACHE STRING "") # - flags -if(UNIX) +if(WIN32) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} /DEBUG /Od -DDEBUG") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /DEBUG /Od -DDEBUG") + + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} /O2") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /O2") +else() SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -Wall -Wextra -DDEBUG") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -Wall -Wextra -DDEBUG") @@ -59,7 +65,7 @@ INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) # Build paths SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") -#SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") +SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") # Include directories diff --git a/README b/README index 593685b..e2d098f 100644 --- a/README +++ b/README @@ -21,10 +21,12 @@ AFGR 2013. --- -Here are my updates in the original code, included in this fork of the project: - -- added OpenCV missing includes (perhaps due to changes in version used?) -- type casts were made explicit to remove the warning messages -- array allocations were replaced with the operator `new[]` -- Windows/POSIX-specific function calls were enclosed in `#ifdefs` based on the operating system defined at compilation time, and the the best corresponding functions were used for Windows (for instance: `PathRemoveFileSpec` and `PathStripPath` respectively replaced `dirname` and `basename` in Windows). -- the class `ForkRunner` was completely replaced in Windows by the implementation proposed by Ben Howell [here](http://www.benhowell.net/guide/2015/03/16/porting-face-analysis-sdk-to-windows/); although [there is no direct equivalent of `fork` (used by the original class) on Windows](http://stackoverflow.com/a/9148072/2896619) and [`CreateProcess` does not have the same behaviour](http://stackoverflow.com/q/985281/2896619). \ No newline at end of file +Here are the updates in the original code included in this fork of the project: + +- The dependency of Qt in the qt-gui project was upgraded from Qt4 to Qt5. +- Some OpenCV missing includes were added (perhaps they are due to changes in version used). +- The type casts were made explicit to remove related warning messages. +- Some static array allocations were replaced with the operator `new[]`. +- The Windows/POSIX-specific function calls were enclosed in `#ifdefs` based on the operating system defined at compilation time, and the the best corresponding functions were used for Windows (for instance: `PathRemoveFileSpec` and `PathStripPath` respectively replaced `dirname` and `basename` in Windows). +- The class `ForkRunner` was completely replaced in Windows by the implementation proposed by Ben Howell [here](http://www.benhowell.net/guide/2015/03/16/porting-face-analysis-sdk-to-windows/). Although, [there is no direct equivalent of `fork` (used by the original class) on Windows](http://stackoverflow.com/a/9148072/2896619) and [`CreateProcess` does not have the same behaviour](http://stackoverflow.com/q/985281/2896619) (further tests required). +- The libraries `utilities`, `clmTracker` and `avatarAnim`, that were originally created as shared libraries, were transformed into static libraries only for the Windows configuration. This was just simpler to do at this time, because the use of the `__declspec(dllexport)` directive (to export the functions/classes to be usable through a DLL) was causing problems related to third part objects not being equally exported (for instance, in some classes/functions, the compiler was producing messages like: "warning C4251: class 'cv::Mat' needs to have dll-interface to be used by clients of class "). \ No newline at end of file diff --git a/src/avatar/CMakeLists.txt b/src/avatar/CMakeLists.txt index 6bccad1..ab4de2b 100644 --- a/src/avatar/CMakeLists.txt +++ b/src/avatar/CMakeLists.txt @@ -8,5 +8,11 @@ CONFIGURE_FILE("Config.h.in" "Config.h") SET(AVATAR_FILES "Avatar.cpp" "myAvatar.cpp") -ADD_LIBRARY(avatarAnim SHARED ${AVATAR_FILES}) +if(WIN32) + set(LIBTYPE STATIC) +else() + set(LIBTYPE SHARED) +endif() + +ADD_LIBRARY(avatarAnim ${LIBTYPE} ${AVATAR_FILES}) TARGET_LINK_LIBRARIES(avatarAnim ${LIBS} utilities clmTracker) \ No newline at end of file diff --git a/src/qt-gui/CMakeLists.txt b/src/qt-gui/CMakeLists.txt index 8ddb0a4..c453456 100644 --- a/src/qt-gui/CMakeLists.txt +++ b/src/qt-gui/CMakeLists.txt @@ -1,7 +1,13 @@ # -*-cmake-*- -find_package(Qt4 REQUIRED) +set(CMAKE_INCLUDE_CURRENT_DIR ON) # Find includes in corresponding build directories +set(CMAKE_AUTOMOC ON) # Instruct CMake to run moc automatically when needed +set(CMAKE_AUTORCC ON) # Instruct CMake to run rcc automatically when needed +set(CMAKE_AUTOUIC ON) # Instruct CMake to run uic automatically when needed +find_package(Qt5Widgets) -INCLUDE( ${QT_USE_FILE} ) +cmake_policy (SET CMP0020 NEW) + +#INCLUDE( ${QT_USE_FILE} ) #set(CMAKE_VERBOSE_MAKEFILE true) @@ -33,19 +39,25 @@ SET(MOC_HEADERS "gui/worker-thread.hpp") # "gui/item-positions-calculator.hpp") -QT4_WRAP_CPP(MOC_SRCS ${MOC_HEADERS}) +#QT5_WRAP_CPP(MOC_SRCS ${MOC_HEADERS}) INCLUDE_DIRECTORIES(".") set_source_files_properties(osx-configuration.mm PROPERTIES COMPILE_FLAGS -ObjC++) +if(WIN32) + set(TARGET_TYPE WIN32) +elseif(APPLE) + set(TARGET_TYPE MACOSX_BUNDLE) +endif() -add_executable(demo-application +add_executable(demo-application ${TARGET_TYPE} main.cpp command-line-configuration.cpp ${guiFILES} - ${MOC_SRCS} +# ${MOC_SRCS} ${EXTRA_SRC}) -target_link_libraries(demo-application ${LIBS} ${QT_LIBRARIES} clmTracker avatarAnim utilities ${EXTRA_LIBS}) + +target_link_libraries(demo-application ${LIBS} Qt5::Widgets clmTracker avatarAnim utilities ${EXTRA_LIBS}) # Apple Specific Targets @@ -54,18 +66,18 @@ IF(APPLE) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/Configuration.plist PROPERTIES MACOSX_PACKAGE_LOCATION Resources) SET(EXTRA_SRC "Configuration.plist") + SET(CONFIG_SRC "osx-configuration.mm") ENDIF() - -ADD_EXECUTABLE(${BundleName} MACOSX_BUNDLE +ADD_EXECUTABLE(${BundleName} ${TARGET_TYPE} main.cpp - osx-configuration.mm + ${CONFIG_SRC} ${guiFILES} - ${MOC_SRCS} + #${MOC_SRCS} ${EXTRA_SRC} ) -TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} ${QT_LIBRARIES} clmTracker avatarAnim ${EXTRA_LIBS}) +TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} Qt5::Widgets clmTracker avatarAnim ${EXTRA_LIBS}) # IF(APPLE) @@ -106,4 +118,4 @@ IF(APPLE) include(CPack) -ENDIF() +ENDIF() \ No newline at end of file diff --git a/src/qt-gui/application-states.hpp b/src/qt-gui/application-states.hpp index 2323ba1..a2b13ee 100644 --- a/src/qt-gui/application-states.hpp +++ b/src/qt-gui/application-states.hpp @@ -20,7 +20,7 @@ #ifndef _QT_GUI_APPLICATION_STATES_HPP_ #define _QT_GUI_APPLICATION_STATES_HPP_ -#include +#include namespace CI2CVGui { diff --git a/src/qt-gui/configuration.hpp b/src/qt-gui/configuration.hpp index e7cd566..23183da 100644 --- a/src/qt-gui/configuration.hpp +++ b/src/qt-gui/configuration.hpp @@ -20,7 +20,7 @@ #ifndef _CI2CV_GUI_CONFIGURATION_HPP_ #define _CI2CV_GUI_CONFIGURATION_HPP_ -#include +#include namespace CI2CVGui { diff --git a/src/qt-gui/controllers.hpp b/src/qt-gui/controllers.hpp index cb9c4ee..5c0a0b1 100644 --- a/src/qt-gui/controllers.hpp +++ b/src/qt-gui/controllers.hpp @@ -20,8 +20,8 @@ #ifndef _CI2CV_GUI_GUI_CONTROLLER_HPP_ #define _CI2CV_GUI_GUI_CONTROLLER_HPP_ -#include -#include +#include +#include #include namespace CI2CVGui diff --git a/src/qt-gui/gui/avatar-selection.cpp b/src/qt-gui/gui/avatar-selection.cpp index b4ddf54..67bc4bd 100644 --- a/src/qt-gui/gui/avatar-selection.cpp +++ b/src/qt-gui/gui/avatar-selection.cpp @@ -20,8 +20,8 @@ #include "gui/avatar-selection.hpp" #include "controllers.hpp" -#include -#include +#include +#include using namespace CI2CVGui; diff --git a/src/qt-gui/gui/avatar-selection.hpp b/src/qt-gui/gui/avatar-selection.hpp index 836c78a..27ee942 100644 --- a/src/qt-gui/gui/avatar-selection.hpp +++ b/src/qt-gui/gui/avatar-selection.hpp @@ -20,10 +20,10 @@ #ifndef _CI2CV_GUI_GUI_AVATAR_SELECTION_HPP_ #define _CI2CV_GUI_GUI_AVATAR_SELECTION_HPP_ -#include -#include -#include -#include +#include +#include +#include +#include #include "gui/graphics-scrollbar.hpp" diff --git a/src/qt-gui/gui/graphics-scrollbar.cpp b/src/qt-gui/gui/graphics-scrollbar.cpp index 36bb9d6..e3a4e2b 100644 --- a/src/qt-gui/gui/graphics-scrollbar.cpp +++ b/src/qt-gui/gui/graphics-scrollbar.cpp @@ -18,9 +18,9 @@ // Copyright CSIRO 2013 #include "gui/graphics-scrollbar.hpp" -#include -#include -#include +#include +#include +#include using namespace CI2CVGui; diff --git a/src/qt-gui/gui/graphics-scrollbar.hpp b/src/qt-gui/gui/graphics-scrollbar.hpp index 601f302..db19f99 100644 --- a/src/qt-gui/gui/graphics-scrollbar.hpp +++ b/src/qt-gui/gui/graphics-scrollbar.hpp @@ -20,11 +20,11 @@ #ifndef _CI2CV_GUI_GUI_GRAPHICS_SCROLLBAR_HPP_ #define _CI2CV_GUI_GUI_GRAPHICS_SCROLLBAR_HPP_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace CI2CVGui { class GraphicsScrollbar; diff --git a/src/qt-gui/gui/item-controllers.hpp b/src/qt-gui/gui/item-controllers.hpp index d103aee..f01c579 100644 --- a/src/qt-gui/gui/item-controllers.hpp +++ b/src/qt-gui/gui/item-controllers.hpp @@ -20,9 +20,9 @@ #ifndef _CI2CV_GUI_GUI_ITEM_POSITIONERS_HPP_ #define _CI2CV_GUI_GUI_ITEM_POSITIONERS_HPP_ -#include -#include -#include +#include +#include +#include #include diff --git a/src/qt-gui/gui/main-window.cpp b/src/qt-gui/gui/main-window.cpp index a1e4d64..c24687a 100644 --- a/src/qt-gui/gui/main-window.cpp +++ b/src/qt-gui/gui/main-window.cpp @@ -24,12 +24,12 @@ #include "gui/mesh-drawer.hpp" #include "configuration.hpp" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include using namespace CI2CVGui; diff --git a/src/qt-gui/gui/main-window.hpp b/src/qt-gui/gui/main-window.hpp index 99eea1f..5534191 100644 --- a/src/qt-gui/gui/main-window.hpp +++ b/src/qt-gui/gui/main-window.hpp @@ -20,13 +20,13 @@ #ifndef _CI2CV_GUI_GUI_MAIN_WINDOW_HPP_ #define _CI2CV_GUI_GUI_MAIN_WINDOW_HPP_ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "gui/item-controllers.hpp" diff --git a/src/qt-gui/gui/mesh-drawer.cpp b/src/qt-gui/gui/mesh-drawer.cpp index 23b01a7..c215354 100644 --- a/src/qt-gui/gui/mesh-drawer.cpp +++ b/src/qt-gui/gui/mesh-drawer.cpp @@ -20,8 +20,8 @@ #include "gui/mesh-drawer.hpp" #include "controllers.hpp" -#include -#include +#include +#include using namespace CI2CVGui; diff --git a/src/qt-gui/gui/mesh-drawer.hpp b/src/qt-gui/gui/mesh-drawer.hpp index 2ca14af..e1ed089 100644 --- a/src/qt-gui/gui/mesh-drawer.hpp +++ b/src/qt-gui/gui/mesh-drawer.hpp @@ -20,10 +20,10 @@ #ifndef _CI2CV_GUI_GUI_MESH_DRAWER_HPP_ #define _CI2CV_GUI_GUI_MESH_DRAWER_HPP_ -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/src/qt-gui/gui/windowed-gui-controller.hpp b/src/qt-gui/gui/windowed-gui-controller.hpp index 0f2b250..52f83b7 100644 --- a/src/qt-gui/gui/windowed-gui-controller.hpp +++ b/src/qt-gui/gui/windowed-gui-controller.hpp @@ -20,11 +20,11 @@ #ifndef _CI2CV_GUI_GUI_WINDOWED_GUI_CONTROLLER_HPP_ #define _CI2CV_GUI_GUI_WINDOWED_GUI_CONTROLLER_HPP_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "controllers.hpp" #include "gui/item-controllers.hpp" diff --git a/src/qt-gui/gui/worker-thread.hpp b/src/qt-gui/gui/worker-thread.hpp index 289991d..9a966ff 100644 --- a/src/qt-gui/gui/worker-thread.hpp +++ b/src/qt-gui/gui/worker-thread.hpp @@ -25,9 +25,11 @@ #include #include -#include -#include -#include +#include "opencv2/opencv.hpp" + +#include +#include +#include namespace CI2CVGui { class WorkerThreadCameraController : public CameraController diff --git a/src/qt-gui/main.cpp b/src/qt-gui/main.cpp index ab2c6eb..b42ed09 100644 --- a/src/qt-gui/main.cpp +++ b/src/qt-gui/main.cpp @@ -17,10 +17,10 @@ // Copyright CSIRO 2013 -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/tracker/CMakeLists.txt b/src/tracker/CMakeLists.txt index b1e0c47..7b9c680 100644 --- a/src/tracker/CMakeLists.txt +++ b/src/tracker/CMakeLists.txt @@ -23,6 +23,11 @@ SET(TRACKER_FILES "ShapePredictor.cpp" "myFaceTracker.cpp") +if(WIN32) + set(LIBTYPE STATIC) +else() + set(LIBTYPE SHARED) +endif() -ADD_LIBRARY(clmTracker SHARED ${TRACKER_FILES}) +ADD_LIBRARY(clmTracker ${LIBTYPE} ${TRACKER_FILES}) TARGET_LINK_LIBRARIES(clmTracker ${LIBS}) \ No newline at end of file diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 3031a1f..b89eeca 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,6 +1,18 @@ +if(WIN32) + set(LIBTYPE STATIC) + + # Shlwapi.lib is the lib required by PathRemoveFileSpec and PathStripPath + # used in helpers.cpp to replace dirname and basename in Windows + set(EXTRALIBS "Shlwapi.lib") +else() + set(LIBTYPE SHARED) + set(EXTRALIBS "") +endif() + add_library(utilities - SHARED + ${LIBTYPE} command-line-arguments.cpp helpers.cpp points.cpp) -target_link_libraries(utilities ${LIBS}) + +target_link_libraries(utilities ${LIBS} ${EXTRALIBS}) \ No newline at end of file From e8feb8b156dd34a449053775abe602563fb149b2 Mon Sep 17 00:00:00 2001 From: Luiz Carlos Vieira Date: Sun, 6 Mar 2016 23:01:42 -0300 Subject: [PATCH 15/29] Fixes for the compilation in Linux --- src/display-3d-points/main.cpp | 1 + src/qt-gui/gui/worker-thread.cpp | 2 +- src/test/speed_test.cpp | 1 + src/utils/helpers.cpp | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/display-3d-points/main.cpp b/src/display-3d-points/main.cpp index d822960..40f2d43 100644 --- a/src/display-3d-points/main.cpp +++ b/src/display-3d-points/main.cpp @@ -5,6 +5,7 @@ #include #include +#include void print_usage() diff --git a/src/qt-gui/gui/worker-thread.cpp b/src/qt-gui/gui/worker-thread.cpp index 880565d..f420753 100644 --- a/src/qt-gui/gui/worker-thread.cpp +++ b/src/qt-gui/gui/worker-thread.cpp @@ -24,7 +24,7 @@ #include #include -#include "avatar/avatar.hpp" +#include "avatar/Avatar.hpp" #include "gui/avatar.hpp" #include "configuration.hpp" diff --git a/src/test/speed_test.cpp b/src/test/speed_test.cpp index 0cf66b9..a045d5b 100644 --- a/src/test/speed_test.cpp +++ b/src/test/speed_test.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "opencv2/opencv.hpp" diff --git a/src/utils/helpers.cpp b/src/utils/helpers.cpp index d02d70e..2e16b14 100644 --- a/src/utils/helpers.cpp +++ b/src/utils/helpers.cpp @@ -35,6 +35,7 @@ #include #include #include +#include bool nan_p(double value) From 1496fc42395dcc9e8b0003dc9124d104af2226f8 Mon Sep 17 00:00:00 2001 From: Luiz Carlos Vieira Date: Tue, 8 Mar 2016 14:37:57 -0300 Subject: [PATCH 16/29] Renamed README to make it a markdown file --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From 3f8a24bc66ddc071bbf28428b368b7242e1ebd30 Mon Sep 17 00:00:00 2001 From: Luiz Carlos Vieira Date: Tue, 8 Mar 2016 15:11:01 -0300 Subject: [PATCH 17/29] Added missing cpp file to qt-guit project --- src/qt-gui/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qt-gui/CMakeLists.txt b/src/qt-gui/CMakeLists.txt index c453456..635707b 100644 --- a/src/qt-gui/CMakeLists.txt +++ b/src/qt-gui/CMakeLists.txt @@ -15,6 +15,7 @@ SET(BundleName "qt-gui") SET(guiFILES "application-states.cpp" "controllers.cpp" + "command-line-configuration.cpp" "configuration.cpp" "gui/avatar-selection.cpp" "gui/main-window.cpp" @@ -54,7 +55,7 @@ add_executable(demo-application ${TARGET_TYPE} main.cpp command-line-configuration.cpp ${guiFILES} -# ${MOC_SRCS} + ${MOC_SRCS} ${EXTRA_SRC}) target_link_libraries(demo-application ${LIBS} Qt5::Widgets clmTracker avatarAnim utilities ${EXTRA_LIBS}) @@ -74,7 +75,7 @@ ADD_EXECUTABLE(${BundleName} ${TARGET_TYPE} main.cpp ${CONFIG_SRC} ${guiFILES} - #${MOC_SRCS} + ${MOC_SRCS} ${EXTRA_SRC} ) TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} Qt5::Widgets clmTracker avatarAnim ${EXTRA_LIBS}) From d3f8d94d18edf138a64a029d2ee5b287d88e3c1b Mon Sep 17 00:00:00 2001 From: Luiz Carlos Vieira Date: Tue, 8 Mar 2016 16:12:59 -0300 Subject: [PATCH 18/29] Removed compiler flags in Windows - to let VS do its default in debug/release --- CMakeLists.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 334a83f..392afb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,13 +46,7 @@ endif() SET(CMAKE_BUILD_TYPE Release CACHE STRING "") # - flags -if(WIN32) - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} /DEBUG /Od -DDEBUG") - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /DEBUG /Od -DDEBUG") - - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} /O2") - SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /O2") -else() +if(NOT WIN32) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -Wall -Wextra -DDEBUG") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -Wall -Wextra -DDEBUG") From 981463e1d5fbd9a238b96420a9db2c788a422edf Mon Sep 17 00:00:00 2001 From: Luiz Carlos Vieira Date: Tue, 15 Mar 2016 08:41:25 -0300 Subject: [PATCH 19/29] Fixed potential crash/assert in Warp method used for expression transfer --- src/tracker/Warp.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tracker/Warp.cpp b/src/tracker/Warp.cpp index 9ea39e2..5b63199 100644 --- a/src/tracker/Warp.cpp +++ b/src/tracker/Warp.cpp @@ -59,6 +59,14 @@ double FACETRACKER::bilinInterp(cv::Mat& I,const double x,const double y) if(x < 0 || x >= I.cols || y < 0 || y >= I.rows)return 0; int x1 = (int)std::floor(x),y1 = (int)std::floor(y); int x2 = (int)std::ceil(x) ,y2 = (int)std::ceil(y); + + // This check avoids an assertion (in DEBUG) or crash (in RELEASE) if the ceiling + // in x2/y2 exceeds the size of the image + if (x2 >= I.cols) + x2 = I.cols - 1; + if (y2 >= I.rows) + y2 = I.rows - 1; + if(x1 == x2){ if(y1 == y2)return (double)I.at(y1,x1); else return (double(y2)-y)*I.at(y1,x1) + From e09fea32d065aa2dcde08665b8e16c0f1b49be99 Mon Sep 17 00:00:00 2001 From: luigivieira Date: Thu, 29 Sep 2016 15:51:43 -0300 Subject: [PATCH 20/29] Implemented installation in CMake scripts --- CMakeLists.txt | 3 +-- src/avatar/CMakeLists.txt | 5 ++++- src/change-pathnames/CMakeLists.txt | 4 +++- src/create-avatar-model/CMakeLists.txt | 2 ++ src/display-3d-points/CMakeLists.txt | 2 ++ src/display-avatar/CMakeLists.txt | 2 ++ src/display-tracking/CMakeLists.txt | 2 ++ src/expression-transfer/CMakeLists.txt | 2 ++ src/face-fit/CMakeLists.txt | 2 ++ src/map-list/CMakeLists.txt | 2 ++ src/qt-gui/CMakeLists.txt | 5 ++++- src/test/CMakeLists.txt | 4 ++++ src/tracker/CMakeLists.txt | 5 ++++- src/utils/CMakeLists.txt | 5 ++++- 14 files changed, 38 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 392afb9..201e2c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,5 +96,4 @@ IF(WITH_GUI) ADD_SUBDIRECTORY(src/qt-gui) endif() -#cpack stuff goes here - +#cpack stuff goes here \ No newline at end of file diff --git a/src/avatar/CMakeLists.txt b/src/avatar/CMakeLists.txt index ab4de2b..8cdb840 100644 --- a/src/avatar/CMakeLists.txt +++ b/src/avatar/CMakeLists.txt @@ -15,4 +15,7 @@ else() endif() ADD_LIBRARY(avatarAnim ${LIBTYPE} ${AVATAR_FILES}) -TARGET_LINK_LIBRARIES(avatarAnim ${LIBS} utilities clmTracker) \ No newline at end of file +TARGET_LINK_LIBRARIES(avatarAnim ${LIBS} utilities clmTracker) + +install(TARGETS avatarAnim DESTINATION lib) +install(FILES Avatar.hpp DESTINATION include) \ No newline at end of file diff --git a/src/change-pathnames/CMakeLists.txt b/src/change-pathnames/CMakeLists.txt index 75472c8..2be97c7 100644 --- a/src/change-pathnames/CMakeLists.txt +++ b/src/change-pathnames/CMakeLists.txt @@ -5,4 +5,6 @@ add_executable(change-pathnames target_link_libraries(change-pathnames utilities - ${LIBS}) \ No newline at end of file + ${LIBS}) + +install(TARGETS change-pathnames DESTINATION bin) \ No newline at end of file diff --git a/src/create-avatar-model/CMakeLists.txt b/src/create-avatar-model/CMakeLists.txt index 15dda62..ddb78cc 100644 --- a/src/create-avatar-model/CMakeLists.txt +++ b/src/create-avatar-model/CMakeLists.txt @@ -7,3 +7,5 @@ target_link_libraries(create-avatar-model utilities avatarAnim ${LIBS}) + +install(TARGETS create-avatar-model DESTINATION bin) \ No newline at end of file diff --git a/src/display-3d-points/CMakeLists.txt b/src/display-3d-points/CMakeLists.txt index 6533e44..23d6993 100644 --- a/src/display-3d-points/CMakeLists.txt +++ b/src/display-3d-points/CMakeLists.txt @@ -5,3 +5,5 @@ target_link_libraries(display-3d-points utilities clmTracker ${LIBS}) + +install(TARGETS display-3d-points DESTINATION bin) \ No newline at end of file diff --git a/src/display-avatar/CMakeLists.txt b/src/display-avatar/CMakeLists.txt index 30dfae5..ec30b67 100644 --- a/src/display-avatar/CMakeLists.txt +++ b/src/display-avatar/CMakeLists.txt @@ -7,3 +7,5 @@ target_link_libraries(display-avatar utilities avatarAnim ${LIBS}) + +install(TARGETS display-avatar DESTINATION bin) \ No newline at end of file diff --git a/src/display-tracking/CMakeLists.txt b/src/display-tracking/CMakeLists.txt index e92f5a8..a8566ca 100644 --- a/src/display-tracking/CMakeLists.txt +++ b/src/display-tracking/CMakeLists.txt @@ -6,3 +6,5 @@ add_executable(display-tracking target_link_libraries(display-tracking utilities ${LIBS}) + +install(TARGETS display-tracking DESTINATION bin) \ No newline at end of file diff --git a/src/expression-transfer/CMakeLists.txt b/src/expression-transfer/CMakeLists.txt index b968058..ed5c526 100644 --- a/src/expression-transfer/CMakeLists.txt +++ b/src/expression-transfer/CMakeLists.txt @@ -6,3 +6,5 @@ target_link_libraries(expression-transfer utilities avatarAnim ${LIBS}) + +install(TARGETS expression-transfer DESTINATION bin) \ No newline at end of file diff --git a/src/face-fit/CMakeLists.txt b/src/face-fit/CMakeLists.txt index f5d19e3..f3683df 100644 --- a/src/face-fit/CMakeLists.txt +++ b/src/face-fit/CMakeLists.txt @@ -5,3 +5,5 @@ target_link_libraries(face-fit utilities clmTracker ${LIBS}) + +install(TARGETS face-fit DESTINATION bin) \ No newline at end of file diff --git a/src/map-list/CMakeLists.txt b/src/map-list/CMakeLists.txt index 9f97f21..61b735e 100644 --- a/src/map-list/CMakeLists.txt +++ b/src/map-list/CMakeLists.txt @@ -6,3 +6,5 @@ add_executable(map-list target_link_libraries(map-list utilities ${LIBS}) + +install(TARGETS map-list DESTINATION bin) diff --git a/src/qt-gui/CMakeLists.txt b/src/qt-gui/CMakeLists.txt index 635707b..348c270 100644 --- a/src/qt-gui/CMakeLists.txt +++ b/src/qt-gui/CMakeLists.txt @@ -60,6 +60,8 @@ add_executable(demo-application ${TARGET_TYPE} target_link_libraries(demo-application ${LIBS} Qt5::Widgets clmTracker avatarAnim utilities ${EXTRA_LIBS}) +install(TARGETS demo-application DESTINATION bin) + # Apple Specific Targets IF(APPLE) @@ -80,6 +82,7 @@ ADD_EXECUTABLE(${BundleName} ${TARGET_TYPE} ) TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} Qt5::Widgets clmTracker avatarAnim ${EXTRA_LIBS}) +install(TARGETS ${BundleName} DESTINATION bin) # IF(APPLE) @@ -101,7 +104,7 @@ IF(APPLE) BUNDLE DESTINATION . COMPONENT Runtime RUNTIME DESTINATION bin COMPONENT Runtime ) - + FILE(GLOB trackerFiles "${CMAKE_CURRENT_SOURCE_DIR}/../tracker/resources/*") FILE(GLOB avatarFiles "${CMAKE_CURRENT_SOURCE_DIR}/../avatar/resources/*") diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 885708b..06ed96e 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -10,3 +10,7 @@ TARGET_LINK_LIBRARIES(speed_test ${LIBS} clmTracker avatarAnim) ADD_EXECUTABLE(add_avatar add_avatar.cpp) TARGET_LINK_LIBRARIES(add_avatar ${LIBS} avatarAnim) + +install(TARGETS test_avatar DESTINATION bin) +install(TARGETS speed_test DESTINATION bin) +install(TARGETS add_avatar DESTINATION bin) \ No newline at end of file diff --git a/src/tracker/CMakeLists.txt b/src/tracker/CMakeLists.txt index 7b9c680..9b580b1 100644 --- a/src/tracker/CMakeLists.txt +++ b/src/tracker/CMakeLists.txt @@ -30,4 +30,7 @@ else() endif() ADD_LIBRARY(clmTracker ${LIBTYPE} ${TRACKER_FILES}) -TARGET_LINK_LIBRARIES(clmTracker ${LIBS}) \ No newline at end of file +TARGET_LINK_LIBRARIES(clmTracker ${LIBS}) + +install(TARGETS clmTracker DESTINATION lib) +install(FILES FaceTracker.hpp DESTINATION include) \ No newline at end of file diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index b89eeca..bb406d5 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -15,4 +15,7 @@ add_library(utilities helpers.cpp points.cpp) -target_link_libraries(utilities ${LIBS} ${EXTRALIBS}) \ No newline at end of file +target_link_libraries(utilities ${LIBS} ${EXTRALIBS}) + +install(TARGETS utilities DESTINATION lib) +install(FILES points.hpp DESTINATION include) \ No newline at end of file From 5a99117076069c8349981c156bcafbdd169d92f0 Mon Sep 17 00:00:00 2001 From: luigivieira Date: Fri, 30 Sep 2016 11:01:03 -0300 Subject: [PATCH 21/29] Implemented find script (to allow using find_package(CSIRO) in other CMake projects) --- CMakeLists.txt | 3 +++ src/CSIROConfig.cmake | 2 ++ src/avatar/CMakeLists.txt | 2 +- src/tracker/CMakeLists.txt | 2 +- src/utils/CMakeLists.txt | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/CSIROConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 201e2c1..c87fce3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,9 @@ ADD_SUBDIRECTORY(src/display-tracking) ADD_SUBDIRECTORY(src/create-avatar-model) ADD_SUBDIRECTORY(src/display-3d-points) +install(EXPORT CSIRO DESTINATION ${CMAKE_INSTALL_PREFIX}) +install(FILES src/CSIROConfig.cmake DESTINATION "${CMAKE_INSTALL_PREFIX}") + IF(WITH_GUI) SET(CPACK_PACKAGE_NAME "clm") SET(CPACK_PACKAGE_VENDOR "CI2CV-CSIRO ci2cv.net") diff --git a/src/CSIROConfig.cmake b/src/CSIROConfig.cmake new file mode 100644 index 0000000..35ca7e0 --- /dev/null +++ b/src/CSIROConfig.cmake @@ -0,0 +1,2 @@ +set(CSIRO_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include") +include("${CMAKE_CURRENT_LIST_DIR}/CSIRO.cmake") \ No newline at end of file diff --git a/src/avatar/CMakeLists.txt b/src/avatar/CMakeLists.txt index 8cdb840..211e963 100644 --- a/src/avatar/CMakeLists.txt +++ b/src/avatar/CMakeLists.txt @@ -17,5 +17,5 @@ endif() ADD_LIBRARY(avatarAnim ${LIBTYPE} ${AVATAR_FILES}) TARGET_LINK_LIBRARIES(avatarAnim ${LIBS} utilities clmTracker) -install(TARGETS avatarAnim DESTINATION lib) +install(TARGETS avatarAnim EXPORT CSIRO DESTINATION lib) install(FILES Avatar.hpp DESTINATION include) \ No newline at end of file diff --git a/src/tracker/CMakeLists.txt b/src/tracker/CMakeLists.txt index 9b580b1..265a50c 100644 --- a/src/tracker/CMakeLists.txt +++ b/src/tracker/CMakeLists.txt @@ -32,5 +32,5 @@ endif() ADD_LIBRARY(clmTracker ${LIBTYPE} ${TRACKER_FILES}) TARGET_LINK_LIBRARIES(clmTracker ${LIBS}) -install(TARGETS clmTracker DESTINATION lib) +install(TARGETS clmTracker EXPORT CSIRO DESTINATION lib) install(FILES FaceTracker.hpp DESTINATION include) \ No newline at end of file diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index bb406d5..aade4f7 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -17,5 +17,5 @@ add_library(utilities target_link_libraries(utilities ${LIBS} ${EXTRALIBS}) -install(TARGETS utilities DESTINATION lib) +install(TARGETS utilities EXPORT CSIRO DESTINATION lib) install(FILES points.hpp DESTINATION include) \ No newline at end of file From 8d633e09c7c5789d22a98132966c982c7b242bfb Mon Sep 17 00:00:00 2001 From: luigivieira Date: Fri, 30 Sep 2016 22:52:46 -0300 Subject: [PATCH 22/29] Exporting includes to correct structure; exporting binaries in both debug (with postfix 'd') and release versions --- src/avatar/CMakeLists.txt | 3 ++- src/change-pathnames/CMakeLists.txt | 2 +- src/create-avatar-model/CMakeLists.txt | 2 +- src/display-3d-points/CMakeLists.txt | 1 + src/display-avatar/CMakeLists.txt | 2 +- src/display-tracking/CMakeLists.txt | 2 +- src/expression-transfer/CMakeLists.txt | 2 +- src/face-fit/CMakeLists.txt | 1 + src/map-list/CMakeLists.txt | 2 +- src/qt-gui/CMakeLists.txt | 4 +++- src/test/CMakeLists.txt | 3 +++ src/tracker/CMakeLists.txt | 3 ++- src/utils/CMakeLists.txt | 4 +++- 13 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/avatar/CMakeLists.txt b/src/avatar/CMakeLists.txt index 211e963..2960314 100644 --- a/src/avatar/CMakeLists.txt +++ b/src/avatar/CMakeLists.txt @@ -15,7 +15,8 @@ else() endif() ADD_LIBRARY(avatarAnim ${LIBTYPE} ${AVATAR_FILES}) +set_target_properties(avatarAnim PROPERTIES DEBUG_POSTFIX "d") TARGET_LINK_LIBRARIES(avatarAnim ${LIBS} utilities clmTracker) install(TARGETS avatarAnim EXPORT CSIRO DESTINATION lib) -install(FILES Avatar.hpp DESTINATION include) \ No newline at end of file +install(FILES Avatar.hpp IO.hpp DESTINATION include/avatar) \ No newline at end of file diff --git a/src/change-pathnames/CMakeLists.txt b/src/change-pathnames/CMakeLists.txt index 2be97c7..3e24c69 100644 --- a/src/change-pathnames/CMakeLists.txt +++ b/src/change-pathnames/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(change-pathnames main.cpp) - +set_target_properties(change-pathnames PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(change-pathnames utilities ${LIBS}) diff --git a/src/create-avatar-model/CMakeLists.txt b/src/create-avatar-model/CMakeLists.txt index ddb78cc..7161962 100644 --- a/src/create-avatar-model/CMakeLists.txt +++ b/src/create-avatar-model/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(create-avatar-model main.cpp) - +set_target_properties(create-avatar-model PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(create-avatar-model utilities avatarAnim diff --git a/src/display-3d-points/CMakeLists.txt b/src/display-3d-points/CMakeLists.txt index 23d6993..8b4efc4 100644 --- a/src/display-3d-points/CMakeLists.txt +++ b/src/display-3d-points/CMakeLists.txt @@ -1,6 +1,7 @@ # -*-cmake-*- add_executable(display-3d-points main.cpp) +set_target_properties(display-3d-points PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(display-3d-points utilities clmTracker diff --git a/src/display-avatar/CMakeLists.txt b/src/display-avatar/CMakeLists.txt index ec30b67..617dcf6 100644 --- a/src/display-avatar/CMakeLists.txt +++ b/src/display-avatar/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(display-avatar main.cpp) - +set_target_properties(display-avatar PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(display-avatar utilities avatarAnim diff --git a/src/display-tracking/CMakeLists.txt b/src/display-tracking/CMakeLists.txt index a8566ca..afab597 100644 --- a/src/display-tracking/CMakeLists.txt +++ b/src/display-tracking/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(display-tracking main.cpp) - +set_target_properties(display-tracking PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(display-tracking utilities ${LIBS}) diff --git a/src/expression-transfer/CMakeLists.txt b/src/expression-transfer/CMakeLists.txt index ed5c526..79ada2a 100644 --- a/src/expression-transfer/CMakeLists.txt +++ b/src/expression-transfer/CMakeLists.txt @@ -1,7 +1,7 @@ # -*-cmake-*- add_executable(expression-transfer main.cpp) - +set_target_properties(expression-transfer PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(expression-transfer utilities avatarAnim diff --git a/src/face-fit/CMakeLists.txt b/src/face-fit/CMakeLists.txt index f3683df..d452098 100644 --- a/src/face-fit/CMakeLists.txt +++ b/src/face-fit/CMakeLists.txt @@ -1,6 +1,7 @@ # -*-cmake-*- add_executable(face-fit main.cpp) +set_target_properties(face-fit PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(face-fit utilities clmTracker diff --git a/src/map-list/CMakeLists.txt b/src/map-list/CMakeLists.txt index 61b735e..9cd8332 100644 --- a/src/map-list/CMakeLists.txt +++ b/src/map-list/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(map-list main.cpp) - +set_target_properties(map-list PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(map-list utilities ${LIBS}) diff --git a/src/qt-gui/CMakeLists.txt b/src/qt-gui/CMakeLists.txt index 348c270..d09d466 100644 --- a/src/qt-gui/CMakeLists.txt +++ b/src/qt-gui/CMakeLists.txt @@ -57,7 +57,8 @@ add_executable(demo-application ${TARGET_TYPE} ${guiFILES} ${MOC_SRCS} ${EXTRA_SRC}) - + +set_target_properties(demo-application PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(demo-application ${LIBS} Qt5::Widgets clmTracker avatarAnim utilities ${EXTRA_LIBS}) install(TARGETS demo-application DESTINATION bin) @@ -80,6 +81,7 @@ ADD_EXECUTABLE(${BundleName} ${TARGET_TYPE} ${MOC_SRCS} ${EXTRA_SRC} ) +set_target_properties(${BundleName} PROPERTIES DEBUG_POSTFIX "d") TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} Qt5::Widgets clmTracker avatarAnim ${EXTRA_LIBS}) install(TARGETS ${BundleName} DESTINATION bin) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 06ed96e..a07fc2d 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,14 +1,17 @@ # -*-cmake-*- ADD_EXECUTABLE(test_avatar test_Avatar.cpp) +set_target_properties(test_avatar PROPERTIES DEBUG_POSTFIX "d") TARGET_LINK_LIBRARIES(test_avatar ${LIBS} clmTracker) TARGET_LINK_LIBRARIES(test_avatar avatarAnim) ADD_EXECUTABLE(speed_test speed_test.cpp command-line-options.cpp) +set_target_properties(speed_test PROPERTIES DEBUG_POSTFIX "d") TARGET_LINK_LIBRARIES(speed_test ${LIBS} clmTracker avatarAnim) ADD_EXECUTABLE(add_avatar add_avatar.cpp) +set_target_properties(add_avatar PROPERTIES DEBUG_POSTFIX "d") TARGET_LINK_LIBRARIES(add_avatar ${LIBS} avatarAnim) install(TARGETS test_avatar DESTINATION bin) diff --git a/src/tracker/CMakeLists.txt b/src/tracker/CMakeLists.txt index 265a50c..03391dc 100644 --- a/src/tracker/CMakeLists.txt +++ b/src/tracker/CMakeLists.txt @@ -30,7 +30,8 @@ else() endif() ADD_LIBRARY(clmTracker ${LIBTYPE} ${TRACKER_FILES}) +set_target_properties(clmTracker PROPERTIES DEBUG_POSTFIX "d") TARGET_LINK_LIBRARIES(clmTracker ${LIBS}) install(TARGETS clmTracker EXPORT CSIRO DESTINATION lib) -install(FILES FaceTracker.hpp DESTINATION include) \ No newline at end of file +install(FILES FaceTracker.hpp IO.hpp DESTINATION include/tracker) \ No newline at end of file diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index aade4f7..722c4db 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -14,8 +14,10 @@ add_library(utilities command-line-arguments.cpp helpers.cpp points.cpp) + +set_target_properties(utilities PROPERTIES DEBUG_POSTFIX "d") target_link_libraries(utilities ${LIBS} ${EXTRALIBS}) install(TARGETS utilities EXPORT CSIRO DESTINATION lib) -install(FILES points.hpp DESTINATION include) \ No newline at end of file +install(FILES points.hpp DESTINATION include/utils) \ No newline at end of file From c87844addd3153729a0780b102408acf7210d672 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 1 Oct 2016 13:50:45 -0500 Subject: [PATCH 23/29] Set a default search path for most Linux systems --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d66373..a4108e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,11 @@ if(NOT DEFINED OpenCV_PREFIX) set(OpenCV_PREFIX ${CMAKE_INSTALL_PREFIX}) endif() +if(NOT DEFINED OpenCV_DIR) + # Use the default install path for most Linux systems. + set(OpenCV_DIR /usr/share/OpenCV/) +endif() + # Configurable options OPTION(WITH_GUI "Build the GUI" OFF) From c78e916f0518e3c8a9f6478605d9c1cb1128d2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Sat, 1 Oct 2016 14:46:00 -0500 Subject: [PATCH 24/29] Revert "Various includes to get face kit to build" --- CMakeLists.txt | 3 --- src/avatar/myAvatar.cpp | 1 - src/face-fit/main.cpp | 1 - src/map-list/main.cpp | 1 - src/test/speed_test.cpp | 1 - src/test/test_Avatar.cpp | 1 - src/tracker/ATM.hpp | 1 - src/tracker/FDet.hpp | 1 - src/tracker/Patch.hpp | 1 - src/tracker/Warp.hpp | 1 - src/utils/helpers.cpp | 3 --- 11 files changed, 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad089e6..a4108e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,4 @@ # -*-cmake-*- -set(OpenCV_DIR /usr/local/share/OpenCV) - PROJECT(CSIRO-FaceAnalysis-SDK) cmake_minimum_required(VERSION 2.8) @@ -67,7 +65,6 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") # Include directories -include_directories("/usr/include/") INCLUDE_DIRECTORIES("src/") INCLUDE_DIRECTORIES("src/avatar/") INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/src/") diff --git a/src/avatar/myAvatar.cpp b/src/avatar/myAvatar.cpp index 9dc2c75..194f763 100644 --- a/src/avatar/myAvatar.cpp +++ b/src/avatar/myAvatar.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #define it at #define db at using namespace AVATAR; diff --git a/src/face-fit/main.cpp b/src/face-fit/main.cpp index c575ea1..b5b0deb 100644 --- a/src/face-fit/main.cpp +++ b/src/face-fit/main.cpp @@ -22,7 +22,6 @@ #include "utils/points.hpp" #include "tracker/FaceTracker.hpp" #include -#include using namespace FACETRACKER; diff --git a/src/map-list/main.cpp b/src/map-list/main.cpp index cd632c6..234b66f 100644 --- a/src/map-list/main.cpp +++ b/src/map-list/main.cpp @@ -17,7 +17,6 @@ // Copyright CSIRO 2013 -#include "assert.h" #include "utils/helpers.hpp" #include "utils/command-line-arguments.hpp" #include diff --git a/src/test/speed_test.cpp b/src/test/speed_test.cpp index 11f4e2f..8631926 100644 --- a/src/test/speed_test.cpp +++ b/src/test/speed_test.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/src/test/test_Avatar.cpp b/src/test/test_Avatar.cpp index d3857ea..e228cfa 100644 --- a/src/test/test_Avatar.cpp +++ b/src/test/test_Avatar.cpp @@ -22,7 +22,6 @@ #include #endif #include -#include #include #include #include diff --git a/src/tracker/ATM.hpp b/src/tracker/ATM.hpp index 948dfe3..c873081 100644 --- a/src/tracker/ATM.hpp +++ b/src/tracker/ATM.hpp @@ -21,7 +21,6 @@ #define _TRACKER_ATM_h_ #include #include -#include #include namespace FACETRACKER { diff --git a/src/tracker/FDet.hpp b/src/tracker/FDet.hpp index e64818b..e59c8af 100644 --- a/src/tracker/FDet.hpp +++ b/src/tracker/FDet.hpp @@ -20,7 +20,6 @@ #ifndef _TRACKER_FDet_h_ #define _TRACKER_FDet_h_ #include -#include namespace FACETRACKER { //=========================================================================== diff --git a/src/tracker/Patch.hpp b/src/tracker/Patch.hpp index ae44f9c..eebad36 100644 --- a/src/tracker/Patch.hpp +++ b/src/tracker/Patch.hpp @@ -20,7 +20,6 @@ #ifndef _TRACKER_Patch_h_ #define _TRACKER_Patch_h_ #include -#include namespace FACETRACKER { //=========================================================================== diff --git a/src/tracker/Warp.hpp b/src/tracker/Warp.hpp index f2e894b..acb9bb3 100644 --- a/src/tracker/Warp.hpp +++ b/src/tracker/Warp.hpp @@ -20,7 +20,6 @@ #ifndef _TRACKER_Warp_h_ #define _TRACKER_Warp_h_ #include -#include namespace FACETRACKER { //=========================================================================== diff --git a/src/utils/helpers.cpp b/src/utils/helpers.cpp index b005ab0..feb1f39 100644 --- a/src/utils/helpers.cpp +++ b/src/utils/helpers.cpp @@ -20,13 +20,10 @@ #include "helpers.hpp" #include #include -#include -#include #include #include #include #include -#include bool nan_p(double value) From d0c6e88a907edb969195db5328ff36696e6bbebf Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 1 Oct 2016 15:38:30 -0500 Subject: [PATCH 25/29] Check for the GUI components in tthe cmakefile --- CMakeLists.txt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6b39dc..d213eaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ endif() # Configurable options OPTION(WITH_GUI "Build the GUI" OFF) + # Third party libraries find_package(OpenCV REQUIRED core highgui imgproc objdetect PATHS ${OpenCV_PREFIX}/lib/cmake/ @@ -25,10 +26,21 @@ find_package(OpenCV REQUIRED core highgui imgproc objdetect NO_DEFAULT_PATH) # For some reason CMake uses its defaults before the above paths. IF(APPLE) -find_library(FOUNDATION Foundation) -SET(EXTRA_LIBS ${FOUNDATION}) + find_library(FOUNDATION Foundation) + SET(EXTRA_LIBS ${FOUNDATION}) ENDIF() +IF(UNIX AND NOT APPLE) + FIND_PROGRAM(HAVE_GNUSTEP NAMES gnustep-config) + IF(HAVE_GNUSTEP) + SET(WITH_GUI "Build the GUI" ON) + MESSAGE(STATUS "Found GnuStep") + ELSE(HAVE_GNUSTEP) + MESSAGE(STATUS "Cannot find GnuStep") + ENDIF(HAVE_GNUSTEP) +ENDIF(UNIX AND NOT APPLE) + + # Third party programs if(NOT DEFINED FFMPEG) find_program(FFMPEG ffmpeg) @@ -98,6 +110,9 @@ IF(WITH_GUI) SET(CPACK_BINARY_PACKAGEMAKER OFF) SET(CPACK_SOURCE_TGZ OFF) ADD_SUBDIRECTORY(src/qt-gui) + MESSAGE(STATUS "Will build the GUI") +else() + MESSAGE(STATUS "Missing GUI components - will NOT build the GUI") endif() #cpack stuff goes here From 7e54478a897ab2c1a90ebec1cde7d30d981198dc Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 1 Oct 2016 15:53:15 -0500 Subject: [PATCH 26/29] Add the needed linker flags to avoid bomb --- src/qt-gui/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qt-gui/CMakeLists.txt b/src/qt-gui/CMakeLists.txt index dd84111..84fd2b4 100644 --- a/src/qt-gui/CMakeLists.txt +++ b/src/qt-gui/CMakeLists.txt @@ -46,7 +46,11 @@ IF(UNIX AND NOT APPLE) OUTPUT_STRIP_TRAILING_WHITESPACE) STRING(REPLACE "\n" "" GnuStep_FLAGS ${GnuStep_FLAGS}) STRING(REPLACE "\n" "" GnuStep_LINK_FLAGS ${GnuStep_LINK_FLAGS}) - set_source_files_properties(osx-configuration.mm PROPERTIES COMPILE_FLAGS "${GnuStep_FLAGS}") + + SET(GnuStep_LINK_FLAGS "-Wl,--no-as-needed ${GnuStep_LINK_FLAGS}") + set_source_files_properties(osx-configuration.mm PROPERTIES + COMPILE_FLAGS "${GnuStep_FLAGS}" + LINKER_FLAGS "${GnuStep_LINK_FLAGS}") ELSE() set_source_files_properties(osx-configuration.mm PROPERTIES COMPILE_FLAGS -ObjC++) ENDIF() From 826d1be95bc7a01e5fb2fe03b2f889e1149640a8 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 1 Oct 2016 16:10:46 -0500 Subject: [PATCH 27/29] Revert some of GeorgeChan's changes --- src/tracker/Detector.cpp | 8 ++++---- src/tracker/IO.cpp | 4 ++-- src/tracker/myFaceTracker.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tracker/Detector.cpp b/src/tracker/Detector.cpp index d739aed..6adebf7 100644 --- a/src/tracker/Detector.cpp +++ b/src/tracker/Detector.cpp @@ -136,7 +136,7 @@ Detector::getResponsesForRefShape(cv::Mat r, double *sc_) double theta, scale; Align2DShapes(sh, _refs_zm, scale, theta); if(fabs(theta) > .1){ - // std::cerr << "Reference shapes can only differ in scale" << std::endl; + std::cerr << "Reference shapes can only differ in scale" << std::endl; exit(-1); } if(sc_) *sc_ = scale; @@ -162,7 +162,7 @@ Detector::getResponsesForRefShape(cv::Size wSize, cv::Mat r) double theta, scale; Align2DShapes(sh, _refs_zm, scale, theta); if(fabs(theta) > .1){ - // std::cerr << "Reference shapes can only differ in scale" << std::endl; + std::cerr << "Reference shapes can only differ in scale" << std::endl; exit(-1); } if(fabs(scale-1.)<1e-2) @@ -297,8 +297,8 @@ DetectorNCC::Write(std::ofstream &s, bool binary) void DetectorNCC::Read(std::ifstream &, bool) { - // std::cerr << "Reading DetectorNCC objects from text files is not supported" - // << std::endl; + std::cerr << "Reading DetectorNCC objects from text files is not supported" + << std::endl; exit(-1); } diff --git a/src/tracker/IO.cpp b/src/tracker/IO.cpp index fff30a9..0c69121 100644 --- a/src/tracker/IO.cpp +++ b/src/tracker/IO.cpp @@ -237,10 +237,10 @@ void IOBinary::ReadMat(std::ifstream &s, cv::Mat &M) s.read((char*)&c, sizeof(int)); s.read((char*)&t, sizeof(int)); M = cv::Mat(r,c,t); - s.read((char*)(M.datastart), M.total() * M.elemSize()); + s.read(reinterpret_cast(M.datastart), M.total() * M.elemSize()); if(!s.good()){ - // std::cout << "Error reading matrix" << std::endl; + std::cout << "Error reading matrix" << std::endl; } // std::cout << "Mat read: "<< r << "x"<init_type == 0) _clm.Fit(gray_,p->init_wSize,p->itol,p->clamp,p->ftol); else{ - // std::cerr << "Bad init_type "<init_type << ". init_type should be 0" << std::endl; + std::cerr << "Bad init_type "<init_type << ". init_type should be 0" << std::endl; abort(); } // myInitData data; data.calculate = true; From 3acffdee7c829a72cff8cc93c8e869a51190fb6f Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 1 Oct 2016 17:23:40 -0500 Subject: [PATCH 28/29] Simplify the screw cmakefile --- CMakeLists.txt | 15 +-------------- README | 2 +- src/test/speed_test.cpp | 2 +- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d213eaf..01f8426 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,25 +5,12 @@ cmake_minimum_required(VERSION 2.8) #set(CMAKE_VERBOSE_MAKEFILE true) -# Default values for options -if(NOT DEFINED OpenCV_PREFIX) - set(OpenCV_PREFIX ${CMAKE_INSTALL_PREFIX}) -endif() - -if(NOT DEFINED OpenCV_DIR) - # Use the default install path for most Linux systems. - set(OpenCV_DIR /usr/share/OpenCV/) -endif() - # Configurable options OPTION(WITH_GUI "Build the GUI" OFF) # Third party libraries -find_package(OpenCV REQUIRED core highgui imgproc objdetect - PATHS ${OpenCV_PREFIX}/lib/cmake/ - ${OpenCV_PREFIX}/share/OpenCV/ - NO_DEFAULT_PATH) # For some reason CMake uses its defaults before the above paths. +find_package(OpenCV REQUIRED core highgui imgproc objdetect) IF(APPLE) find_library(FOUNDATION Foundation) diff --git a/README b/README index 44c1004..3129cb8 100644 --- a/README +++ b/README @@ -17,4 +17,4 @@ Single Image", AFGR Workshop 2011. If you use the SDK, we ask that you reference the following paper: M. Cox, J. Nuevo, J. Saragih and S. Lucey, "CSIRO Face Analysis SDK", -AFGR 2013. \ No newline at end of file +AFGR 2013. diff --git a/src/test/speed_test.cpp b/src/test/speed_test.cpp index 8631926..54b6d7b 100644 --- a/src/test/speed_test.cpp +++ b/src/test/speed_test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include From 6e50ff80351f13558117fb94fb7d563b7aaa6e8a Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 1 Oct 2016 18:26:56 -0500 Subject: [PATCH 29/29] Misc fixes to get things to compile --- src/qt-gui/CMakeLists.txt | 20 +++++++++++--------- src/qt-gui/qt-gui.pro | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/qt-gui/CMakeLists.txt b/src/qt-gui/CMakeLists.txt index f799cfd..2986905 100644 --- a/src/qt-gui/CMakeLists.txt +++ b/src/qt-gui/CMakeLists.txt @@ -1,11 +1,15 @@ # -*-cmake-*- +cmake_policy (SET CMP0020 NEW) + set(CMAKE_INCLUDE_CURRENT_DIR ON) # Find includes in corresponding build directories set(CMAKE_AUTOMOC ON) # Instruct CMake to run moc automatically when needed set(CMAKE_AUTORCC ON) # Instruct CMake to run rcc automatically when needed set(CMAKE_AUTOUIC ON) # Instruct CMake to run uic automatically when needed -find_package(Qt5Widgets) -cmake_policy (SET CMP0020 NEW) +find_package(Qt5Widgets) +include_directories(${Qt5Widgets_INCLUDE_DIRS}) +# add_definitions(${Qt5Widgets_DEFINITIONS}) +set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") #INCLUDE( ${QT_USE_FILE} ) @@ -43,6 +47,8 @@ SET(MOC_HEADERS #QT5_WRAP_CPP(MOC_SRCS ${MOC_HEADERS}) INCLUDE_DIRECTORIES(".") + +# Non-Apple users get the Foundation librariries from GnuStep IF(UNIX AND NOT APPLE) INCLUDE_DIRECTORIES(/usr/local/include/GNUstep /usr/include/GNUstep) EXECUTE_PROCESS(COMMAND gnustep-config --objc-flags @@ -76,7 +82,7 @@ add_executable(demo-application ${TARGET_TYPE} ${EXTRA_SRC}) set_target_properties(demo-application PROPERTIES DEBUG_POSTFIX "d") -target_link_libraries(demo-application ${LIBS} Qt5::Widgets clmTracker avatarAnim utilities ${EXTRA_LIBS}) +target_link_libraries(demo-application ${Qt5Widgets_LIBRARIES} ${LIBS} clmTracker avatarAnim utilities ${EXTRA_LIBS}) install(TARGETS demo-application DESTINATION bin) @@ -103,12 +109,8 @@ IF(UNIX AND NOT APPLE) LINK_FLAGS "${GnuStep_LINK_FLAGS}") ENDIF() -IF(WIN32) - set_target_properties(${BundleName} PROPERTIES DEBUG_POSTFIX "d") - TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} Qt5::Widgets clmTracker avatarAnim ${EXTRA_LIBS}) -ELSE() - TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} ${QT_LIBRARIES} clmTracker avatarAnim ${EXTRA_LIBS}) -ENDIF() +set_target_properties(${BundleName} PROPERTIES DEBUG_POSTFIX "d") +TARGET_LINK_LIBRARIES(${BundleName} ${LIBS} ${Qt5Widgets_LIBRARIES} clmTracker avatarAnim ${EXTRA_LIBS}) install(TARGETS ${BundleName} DESTINATION bin) diff --git a/src/qt-gui/qt-gui.pro b/src/qt-gui/qt-gui.pro index ef1e38f..d135bb8 100644 --- a/src/qt-gui/qt-gui.pro +++ b/src/qt-gui/qt-gui.pro @@ -9,6 +9,8 @@ LIBS += \ -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_objdetect -lopencv_video -lobjc \ -framework Foundation +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + include(qt-gui.pro.local) { message("Loading in data from qt-gui.pro.local") } else {