Skip to content
Snippets Groups Projects
Commit 886b533d authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Merge with windows fixes

parents 77a3bce7 47633685
No related branches found
No related tags found
No related merge requests found
*/build */build
*/node_modules */node_modules
*/include/ftl/config.h
cmake_minimum_required (VERSION 3.1.0) cmake_minimum_required (VERSION 3.1.0)
include (CheckIncludeFile) include (CheckIncludeFile)
include (CheckIncludeFileCXX)
include (CheckFunctionExists) include (CheckFunctionExists)
include(CheckLanguage) include(CheckLanguage)
...@@ -11,23 +12,19 @@ enable_testing() ...@@ -11,23 +12,19 @@ enable_testing()
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
#find_package( glog REQUIRED ) find_package( glog REQUIRED )
if (WIN32) #if (WIN32)
include_directories(${glog_DIR}) #include_directories(${glog_DIR})
endif (WIN32) #endif (WIN32)
find_package( CUDA )
find_package( OpenCV REQUIRED ) find_package( OpenCV REQUIRED )
find_package( Threads REQUIRED ) find_package( Threads REQUIRED )
find_package( LibSGM ) find_package( LibSGM )
#find_package(PkgConfig) #find_package( CUDA )
#pkg_check_modules(GTKMM gtkmm-3.0)
message("Cuda at ${CMAKE_CUDA_COMPILER}") check_language(CUDA)
#check_language(CUDA)
if (CUDA_FOUND) if (CUDA_FOUND)
enable_language(CUDA) enable_language(CUDA)
set(CMAKE_CUDA_FLAGS "-Xcompiler -Wall") set(CMAKE_CUDA_FLAGS "")
set(CMAKE_CUDA_FLAGS_DEBUG "-g -DDEBUG -D_DEBUG -Wall") set(CMAKE_CUDA_FLAGS_DEBUG "-g -DDEBUG -D_DEBUG -Wall")
set(CMAKE_CUDA_FLAGS_RELEASE "") set(CMAKE_CUDA_FLAGS_RELEASE "")
add_definitions(-DHAVE_CUDA) add_definitions(-DHAVE_CUDA)
...@@ -38,6 +35,11 @@ endif (CUDA_FOUND) ...@@ -38,6 +35,11 @@ endif (CUDA_FOUND)
include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}) include_directories(${PROJECT_BINARY_DIR})
# Check for optional opencv components
set(CMAKE_REQUIRED_INCLUDES "${OpenCV_DIR}/include")
check_include_file_cxx("opencv2/viz.hpp" HAVE_VIZ)
check_include_file_cxx("opencv2/cudastereo.hpp" HAVE_OPENCVCUDA)
set(ftl_VERSION_MAJOR "1") set(ftl_VERSION_MAJOR "1")
set(ftl_VERSION_MINOR "0") set(ftl_VERSION_MINOR "0")
set(ftl_VERSION_PATCH "0") set(ftl_VERSION_PATCH "0")
...@@ -51,6 +53,10 @@ if (WIN32) ...@@ -51,6 +53,10 @@ if (WIN32)
set(FTL_CACHE_ROOT "$ENV{USERPROFILE}/AppData/ftl") set(FTL_CACHE_ROOT "$ENV{USERPROFILE}/AppData/ftl")
set(FTL_DATA_ROOT "$ENV{USERPROFILE}/AppData/ftl") set(FTL_DATA_ROOT "$ENV{USERPROFILE}/AppData/ftl")
add_definitions(-DWIN32) add_definitions(-DWIN32)
set(CMAKE_CXX_FLAGS "/std:c++17")
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
endif (WIN32) endif (WIN32)
if (UNIX) if (UNIX)
...@@ -59,15 +65,19 @@ if (UNIX) ...@@ -59,15 +65,19 @@ if (UNIX)
message(STATUS "Config root is ${FTL_CONFIG_ROOT}") message(STATUS "Config root is ${FTL_CONFIG_ROOT}")
set(FTL_CACHE_ROOT "$ENV{HOME}/.cache/ftl") set(FTL_CACHE_ROOT "$ENV{HOME}/.cache/ftl")
set(FTL_DATA_ROOT "$ENV{HOME}/.local/share/ftl") set(FTL_DATA_ROOT "$ENV{HOME}/.local/share/ftl")
set(CMAKE_CXX_FLAGS "-std=c++17")
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -pg -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse3 -mfpmath=sse")
endif (UNIX) endif (UNIX)
add_definitions("-DFTL_CONFIG_ROOT=${FTL_CONFIG_ROOT}") #add_definitions("-DFTL_CONFIG_ROOT=${FTL_CONFIG_ROOT}")
add_definitions("-DFTL_CACHE_ROOT=${FTL_CACHE_ROOT}") #add_definitions("-DFTL_CACHE_ROOT=${FTL_CACHE_ROOT}")
add_definitions("-DFTL_DATA_ROOT=${FTL_DATA_ROOT}") #add_definitions("-DFTL_DATA_ROOT=${FTL_DATA_ROOT}")
set(CMAKE_CXX_FLAGS "-std=c++17 -Wall") configure_file(${CMAKE_SOURCE_DIR}/include/ftl/config.h.in
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -pg -Wall") ${CMAKE_SOURCE_DIR}/include/ftl/config.h
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse3 -mfpmath=sse") )
SET(CMAKE_USE_RELATIVE_PATHS ON) SET(CMAKE_USE_RELATIVE_PATHS ON)
...@@ -113,6 +123,6 @@ set_property(TARGET cv-node PROPERTY CUDA_SEPARABLE_COMPILATION ON) ...@@ -113,6 +123,6 @@ set_property(TARGET cv-node PROPERTY CUDA_SEPARABLE_COMPILATION ON)
endif (CUDA_FOUND) endif (CUDA_FOUND)
target_include_directories(cv-node PUBLIC ${PROJECT_SOURCE_DIR}/include) target_include_directories(cv-node PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(cv-node Threads::Threads ${OpenCV_LIBS} ${LIBSGM_LIBRARIES} ${CUDA_LIBRARIES} glog) target_link_libraries(cv-node Threads::Threads ${OpenCV_LIBS} ${LIBSGM_LIBRARIES} ${CUDA_LIBRARIES} ${GLOG_LIBRARIES})
###############################################################################
# Find glog
#
if(WIN32)
find_path(glog_DIR glog PATHS "C:/Program Files" "C:/Program Files (x86)")
set(glog_DIR ${glog_DIR}/glog)
else()
set(glog_DIR "")
endif()
# Find lib
set(GLOG_FOUND FALSE CACHE BOOL "" FORCE)
find_library(GLOG_LIBRARY
NAMES glog libglog
PATHS ${glog_DIR}
PATH_SUFFIXES lib/
)
# Find include
find_path(GLOG_INCLUDE_DIRS
NAMES glog/logging.h
PATHS ${glog_DIR}
PATH_SUFFIXES include
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(glog DEFAULT_MSG GLOG_LIBRARY GLOG_INCLUDE_DIRS)
message(STATUS "(GLOG_FOUND : ${GLOG_FOUND} include: ${GLOG_INCLUDE_DIRS}, lib: ${GLOG_LIBRARY})")
mark_as_advanced(GLOG_FOUND)
if(GLOG_FOUND)
include_directories(${GLOG_INCLUDE_DIRS})
set(GLOG_FOUND TRUE CACHE BOOL "" FORCE)
set(GLOG_LIBRARIES ${GLOG_LIBRARY})
message(STATUS "glog found ( include: ${GLOG_INCLUDE_DIRS}, lib: ${GLOG_LIBRARY})")
endif()
...@@ -6,16 +6,25 @@ ...@@ -6,16 +6,25 @@
# LIBSGM_INCLUDE_DIRS - Directories containing the LIBSGM include files. # LIBSGM_INCLUDE_DIRS - Directories containing the LIBSGM include files.
# LIBSGM_LIBRARY - Libraries needed to use LIBSGM. # LIBSGM_LIBRARY - Libraries needed to use LIBSGM.
if(WIN32)
find_path(libSGM_DIR libSGM PATHS "C:/Program Files" "C:/Program Files (x86)")
set(libSGM_DIR ${libSGM_DIR}/libSGM)
else()
set(glog_DIR "")
endif()
# Find lib # Find lib
set(LIBSGM_FOUND FALSE CACHE BOOL "" FORCE) set(LIBSGM_FOUND FALSE CACHE BOOL "" FORCE)
find_library(LIBSGM_LIBRARY find_library(LIBSGM_LIBRARY
NAMES sgm libsgm NAMES sgm libsgm
PATHS ${libSGM_DIR}
PATH_SUFFIXES lib/ PATH_SUFFIXES lib/
) )
# Find include # Find include
find_path(LIBSGM_INCLUDE_DIRS find_path(LIBSGM_INCLUDE_DIRS
NAMES libsgm.h NAMES libsgm.h
PATHS ${libSGM_DIR}
PATH_SUFFIXES include/ PATH_SUFFIXES include/
) )
...@@ -27,6 +36,7 @@ message(STATUS "(LIBSGM_FOUND : ${LIBSGM_FOUND} include: ${LIBSGM_INCLUDE_DIRS}, ...@@ -27,6 +36,7 @@ message(STATUS "(LIBSGM_FOUND : ${LIBSGM_FOUND} include: ${LIBSGM_INCLUDE_DIRS},
mark_as_advanced(LIBSGM_FOUND) mark_as_advanced(LIBSGM_FOUND)
if(LIBSGM_FOUND) if(LIBSGM_FOUND)
include_directories(${LIBSGM_INCLUDE_DIRS})
set(LIBSGM_FOUND TRUE CACHE BOOL "" FORCE) set(LIBSGM_FOUND TRUE CACHE BOOL "" FORCE)
set(LIBSGM_LIBRARIES ${LIBSGM_LIBRARY}) set(LIBSGM_LIBRARIES ${LIBSGM_LIBRARY})
message(STATUS "LibSGM found ( include: ${LIBSGM_INCLUDE_DIRS}, lib: ${LIBSGM_LIBRARY})") message(STATUS "LibSGM found ( include: ${LIBSGM_INCLUDE_DIRS}, lib: ${LIBSGM_LIBRARY})")
......
#ifndef __FTL_CONFIG_H__
#define __FTL_CONFIG_H__
#cmakedefine HAVE_VIZ
#cmakedefine HAVE_OPENCVCUDA
#define FTL_VERSION @FTL_VERSION@
#define FTL_VERSION_MAJOR @ftl_VERSION_MAJOR@
#define FTL_VERSION_MINOR @ftl_VERSION_MINOR@
#define FTL_VERSION_PATCH @ftl_VERSION_PATCH@
#define FTL_CONFIG_ROOT @FTL_CONFIG_ROOT@
#define FTL_CACHE_ROOT @FTL_CACHE_ROOT@
#define FTL_DATA_ROOT @FTL_DATA_ROOT@
#endif // __FTL_CONFIG_H__
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
#include <ftl/calibrate.hpp> #include <ftl/calibrate.hpp>
#include <ftl/config.h>
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
namespace ftl { namespace ftl {
...@@ -19,7 +20,11 @@ namespace ftl { ...@@ -19,7 +20,11 @@ namespace ftl {
private: private:
const ftl::Calibrate &calibrate_; const ftl::Calibrate &calibrate_;
nlohmann::json config_; nlohmann::json config_;
#if defined HAVE_VIZ
cv::viz::Viz3d *window_; cv::viz::Viz3d *window_;
#endif // HAVE_VIZ
bool active_; bool active_;
}; };
}; };
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <cstdio> #include <cstdio>
#include <ftl/calibrate.hpp> #include <ftl/calibrate.hpp>
#include <ftl/config.h>
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/core/utility.hpp> #include <opencv2/core/utility.hpp>
......
#include <ftl/display.hpp> #include <ftl/display.hpp>
#include <glog/logging.h>
using ftl::Display; using ftl::Display;
using ftl::Calibrate;
using namespace cv; using namespace cv;
Display::Display(const Calibrate &cal, nlohmann::json &config) : calibrate_(cal), config_(config) { Display::Display(const Calibrate &cal, nlohmann::json &config) : calibrate_(cal), config_(config) {
#if defined HAVE_VIZ
window_ = new cv::viz::Viz3d("FTL"); window_ = new cv::viz::Viz3d("FTL");
window_->setBackgroundColor(cv::viz::Color::white()); window_->setBackgroundColor(cv::viz::Color::white());
#endif // HAVE_VIZ
active_ = true; active_ = true;
} }
Display::~Display() { Display::~Display() {
#if defined HAVE_VIZ
delete window_; delete window_;
#endif // HAVE_VIZ
} }
bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) { bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) {
Mat idepth; Mat idepth;
if (config_["points"]) { if (config_["points"]) {
#if defined HAVE_VIZ
cv::Mat Q_32F; cv::Mat Q_32F;
calibrate_.getQ().convertTo(Q_32F,CV_32F); calibrate_.getQ().convertTo(Q_32F,CV_32F);
cv::Mat_<cv::Vec3f> XYZ(depth.rows,depth.cols); // Output point cloud cv::Mat_<cv::Vec3f> XYZ(depth.rows,depth.cols); // Output point cloud
...@@ -32,6 +39,12 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) { ...@@ -32,6 +39,12 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) {
window_->showWidget( "Depth", cloud_widget ); window_->showWidget( "Depth", cloud_widget );
window_->spinOnce( 1, true ); window_->spinOnce( 1, true );
#else // HAVE_VIZ
LOG(ERROR) << "Need OpenCV Viz module to display points";
#endif // HAVE_VIZ
} }
if (config_["depth"]) { if (config_["depth"]) {
...@@ -60,6 +73,10 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) { ...@@ -60,6 +73,10 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) {
} }
bool Display::active() const { bool Display::active() const {
#if defined HAVE_VIZ
return active_ && !window_->wasStopped(); return active_ && !window_->wasStopped();
#else
return active_;
#endif
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <ftl/disparity.hpp> #include <ftl/disparity.hpp>
#include <ftl/middlebury.hpp> #include <ftl/middlebury.hpp>
#include <ftl/display.hpp> #include <ftl/display.hpp>
#include <ftl/config.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
...@@ -75,6 +76,7 @@ static void process_options(const map<string,string> &opts) { ...@@ -75,6 +76,7 @@ static void process_options(const map<string,string> &opts) {
try { try {
auto ptr = json::json_pointer("/"+opt.first); auto ptr = json::json_pointer("/"+opt.first);
// TODO Allow strings without quotes
auto v = json::parse(opt.second); auto v = json::parse(opt.second);
if (v.type() != config.at(ptr).type()) { if (v.type() != config.at(ptr).type()) {
LOG(ERROR) << "Incorrect type for argument " << opt.first; LOG(ERROR) << "Incorrect type for argument " << opt.first;
...@@ -87,29 +89,6 @@ static void process_options(const map<string,string> &opts) { ...@@ -87,29 +89,6 @@ static void process_options(const map<string,string> &opts) {
} }
} }
static string type2str(int type) {
string r;
uchar depth = type & CV_MAT_DEPTH_MASK;
uchar chans = 1 + (type >> CV_CN_SHIFT);
switch ( depth ) {
case CV_8U: r = "8U"; break;
case CV_8S: r = "8S"; break;
case CV_16U: r = "16U"; break;
case CV_16S: r = "16S"; break;
case CV_32S: r = "32S"; break;
case CV_32F: r = "32F"; break;
case CV_64F: r = "64F"; break;
default: r = "User"; break;
}
r += "C";
r += (chans+'0');
return r;
}
static void run(const string &file) { static void run(const string &file) {
// TODO Initiate the network // TODO Initiate the network
...@@ -142,7 +121,7 @@ static void run(const string &file) { ...@@ -142,7 +121,7 @@ static void run(const string &file) {
while (display.active()) { while (display.active()) {
// Read calibrated images. // Read calibrated images.
calibrate.undistort(l,r); calibrate.rectified(l,r);
// Feed into sync buffer and network forward // Feed into sync buffer and network forward
sync->feed(LEFT, l,lsrc->getTimestamp()); sync->feed(LEFT, l,lsrc->getTimestamp());
...@@ -175,6 +154,7 @@ int main(int argc, char **argv) { ...@@ -175,6 +154,7 @@ int main(int argc, char **argv) {
} }
process_options(options); process_options(options);
// Choose normal or middlebury modes
if (config["middlebury"]["dataset"] == "") { if (config["middlebury"]["dataset"] == "") {
run((argc > 0) ? argv[0] : ""); run((argc > 0) ? argv[0] : "");
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment