From 557f4904d8a7eefb2736a00a0c8c2aa5b3afec9f Mon Sep 17 00:00:00 2001 From: Leng Zhen Date: Fri, 12 Jul 2019 19:34:12 +0800 Subject: [PATCH] Remove GUI&Qt&OpenGL Component --- CMakeLists.txt | 30 ++++------- src/CMakeLists.txt | 2 +- src/exe/colmap.cc | 100 ++++++++++++++++++++++--------------- src/feature/extraction.h | 4 +- src/feature/matching.h | 6 +-- src/feature/sift.cc | 5 +- src/util/CMakeLists.txt | 2 +- src/util/opengl_utils.cc | 5 +- src/util/option_manager.cc | 16 +++--- src/util/option_manager.h | 4 +- 10 files changed, 92 insertions(+), 82 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 219385ff8..3c86aa73c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ if(CUDA_ENABLED) find_package(CUDA ${CUDA_MIN_VERSION} QUIET) endif() -find_package(Qt5 5.4 REQUIRED COMPONENTS Core OpenGL Widgets) +# find_package(Qt5 5.4 REQUIRED COMPONENTS Core OpenGL Widgets) if(Qt5_FOUND) message(STATUS "Found Qt") @@ -237,16 +237,6 @@ else() set(CGAL_ENABLED OFF) endif() -# Qt5 was built with -reduce-relocations. -if(Qt5_POSITION_INDEPENDENT_CODE) - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - if(CUDA_ENABLED AND NOT IS_MSVC) - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --compiler-options -fPIC") - endif() -endif() - -# Enable automatic compilation of Qt resource files. -set(CMAKE_AUTORCC ON) ################################################################################ @@ -263,9 +253,9 @@ set(COLMAP_INCLUDE_DIRS ${FREEIMAGE_INCLUDE_DIRS} ${CERES_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS} - ${Qt5Core_INCLUDE_DIRS} - ${Qt5OpenGL_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} +# ${Qt5Core_INCLUDE_DIRS} +# ${Qt5OpenGL_INCLUDE_DIRS} +# ${Qt5Widgets_INCLUDE_DIRS} ) set(COLMAP_LINK_DIRS @@ -280,12 +270,12 @@ set(COLMAP_EXTERNAL_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${GLOG_LIBRARIES} ${FREEIMAGE_LIBRARIES} - ${CERES_LIBRARIES} + ${CERES_LIBRARIES}` ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} - ${Qt5Core_LIBRARIES} - ${Qt5OpenGL_LIBRARIES} - ${Qt5Widgets_LIBRARIES} +# ${Qt5Core_LIBRARIES} +# ${Qt5OpenGL_LIBRARIES} +# ${Qt5Widgets_LIBRARIES} ) if(CGAL_ENABLED) @@ -354,7 +344,7 @@ COLMAP_ADD_SOURCE_DIR(src/optim OPTIM_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/retrieval RETRIEVAL_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/sfm SFM_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/tools TOOLS_SRCS *.h *.cc) -COLMAP_ADD_SOURCE_DIR(src/ui UI_SRCS *.h *.cc) +#COLMAP_ADD_SOURCE_DIR(src/ui UI_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/util UTIL_SRCS *.h *.cc) # Add all of the source files to a regular library target, as using a custom @@ -380,7 +370,7 @@ add_library( ${RETRIEVAL_SRCS} ${SFM_SRCS} ${TOOLS_SRCS} - ${UI_SRCS} +# ${UI_SRCS} ${UTIL_SRCS} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d7fccc6a..5a5e172e2 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,7 +47,7 @@ add_subdirectory(optim) add_subdirectory(retrieval) add_subdirectory(sfm) add_subdirectory(tools) -add_subdirectory(ui) +#add_subdirectory(ui) add_subdirectory(util) COLMAP_ADD_LIBRARY(colmap ${COLMAP_SOURCES}) diff --git a/src/exe/colmap.cc b/src/exe/colmap.cc index cae30336f..b9ae55e9b 100644 --- a/src/exe/colmap.cc +++ b/src/exe/colmap.cc @@ -36,6 +36,8 @@ #include #include +#include "mvs/fusion.h" +#include "base/undistortion.h" #include "base/similarity_transform.h" #include "controllers/automatic_reconstruction.h" #include "controllers/bundle_adjustment.h" @@ -47,8 +49,9 @@ #include "mvs/meshing.h" #include "mvs/patch_match.h" #include "retrieval/visual_index.h" -#include "ui/main_window.h" -#include "util/opengl_utils.h" +//#include "ui/main_window.h" + +//#include "util/opengl_utils.h" #include "util/version.h" using namespace colmap; @@ -58,7 +61,8 @@ const bool kUseOpenGL = false; #else const bool kUseOpenGL = true; #endif - +// No GUI! +/* int RunGraphicalUserInterface(int argc, char** argv) { OptionManager options; @@ -89,6 +93,8 @@ int RunGraphicalUserInterface(int argc, char** argv) { return app.exec(); } + */ + int RunAutomaticReconstructor(int argc, char** argv) { AutomaticReconstructionController::Options reconstruction_options; std::string data_type = "individual"; @@ -161,10 +167,10 @@ int RunAutomaticReconstructor(int argc, char** argv) { ReconstructionManager reconstruction_manager; if (reconstruction_options.use_gpu && kUseOpenGL) { - QApplication app(argc, argv); +// QApplication app(argc, argv); AutomaticReconstructionController controller(reconstruction_options, &reconstruction_manager); - RunThreadWithOpenGLContext(&controller); +// RunThreadWithOpenGLContext(&controller); } else { AutomaticReconstructionController controller(reconstruction_options, &reconstruction_manager); @@ -426,17 +432,17 @@ int RunExhaustiveMatcher(int argc, char** argv) { options.AddExhaustiveMatchingOptions(); options.Parse(argc, argv); - std::unique_ptr app; - if (options.sift_matching->use_gpu && kUseOpenGL) { - app.reset(new QApplication(argc, argv)); - } + //std::unique_ptr app; + //if (options.sift_matching->use_gpu && kUseOpenGL) { + // app.reset(new QApplication(argc, argv)); + //} ExhaustiveFeatureMatcher feature_matcher(*options.exhaustive_matching, *options.sift_matching, *options.database_path); if (options.sift_matching->use_gpu && kUseOpenGL) { - RunThreadWithOpenGLContext(&feature_matcher); +// RunThreadWithOpenGLContext(&feature_matcher); } else { feature_matcher.Start(); feature_matcher.Wait(); @@ -493,16 +499,18 @@ int RunFeatureExtractor(int argc, char** argv) { return EXIT_FAILURE; } - std::unique_ptr app; - if (options.sift_extraction->use_gpu && kUseOpenGL) { - app.reset(new QApplication(argc, argv)); - } + //std::unique_ptr app; + //if (options.sift_extraction->use_gpu && kUseOpenGL) { + // app.reset(new QApplication(argc, argv)); + //} SiftFeatureExtractor feature_extractor(reader_options, *options.sift_extraction); if (options.sift_extraction->use_gpu && kUseOpenGL) { - RunThreadWithOpenGLContext(&feature_extractor); + //RunThreadWithOpenGLContext(&feature_extractor); + std::cerr << "ERROR: OpenGL Disabled."; + return EXIT_FAILURE; } else { feature_extractor.Start(); feature_extractor.Wait(); @@ -985,10 +993,10 @@ int RunMatchesImporter(int argc, char** argv) { options.AddMatchingOptions(); options.Parse(argc, argv); - std::unique_ptr app; - if (options.sift_matching->use_gpu && kUseOpenGL) { - app.reset(new QApplication(argc, argv)); - } + //std::unique_ptr app; + //if (options.sift_matching->use_gpu && kUseOpenGL) { + // app.reset(new QApplication(argc, argv)); + //} std::unique_ptr feature_matcher; if (match_type == "pairs") { @@ -1008,7 +1016,9 @@ int RunMatchesImporter(int argc, char** argv) { } if (options.sift_matching->use_gpu && kUseOpenGL) { - RunThreadWithOpenGLContext(feature_matcher.get()); +// RunThreadWithOpenGLContext(feature_matcher.get()); + std::cerr << "ERROR: OpenGL Disabled."; + return EXIT_FAILURE; } else { feature_matcher->Start(); feature_matcher->Wait(); @@ -1289,17 +1299,19 @@ int RunSequentialMatcher(int argc, char** argv) { options.AddSequentialMatchingOptions(); options.Parse(argc, argv); - std::unique_ptr app; - if (options.sift_matching->use_gpu && kUseOpenGL) { - app.reset(new QApplication(argc, argv)); - } + //std::unique_ptr app; + //if (options.sift_matching->use_gpu && kUseOpenGL) { + // app.reset(new QApplication(argc, argv)); + //} SequentialFeatureMatcher feature_matcher(*options.sequential_matching, *options.sift_matching, *options.database_path); if (options.sift_matching->use_gpu && kUseOpenGL) { - RunThreadWithOpenGLContext(&feature_matcher); + //RunThreadWithOpenGLContext(&feature_matcher); + std::cerr << "ERROR: OpenGL Disabled."; + return EXIT_FAILURE; } else { feature_matcher.Start(); feature_matcher.Wait(); @@ -1668,17 +1680,19 @@ int RunSpatialMatcher(int argc, char** argv) { options.AddSpatialMatchingOptions(); options.Parse(argc, argv); - std::unique_ptr app; - if (options.sift_matching->use_gpu && kUseOpenGL) { - app.reset(new QApplication(argc, argv)); - } + //std::unique_ptr app; + //if (options.sift_matching->use_gpu && kUseOpenGL) { + // app.reset(new QApplication(argc, argv)); + //} SpatialFeatureMatcher feature_matcher(*options.spatial_matching, *options.sift_matching, *options.database_path); if (options.sift_matching->use_gpu && kUseOpenGL) { - RunThreadWithOpenGLContext(&feature_matcher); + //RunThreadWithOpenGLContext(&feature_matcher); + std::cerr << "ERROR: OpenGL Disabled."; + return EXIT_FAILURE; } else { feature_matcher.Start(); feature_matcher.Wait(); @@ -1693,17 +1707,19 @@ int RunTransitiveMatcher(int argc, char** argv) { options.AddTransitiveMatchingOptions(); options.Parse(argc, argv); - std::unique_ptr app; - if (options.sift_matching->use_gpu && kUseOpenGL) { - app.reset(new QApplication(argc, argv)); - } + //std::unique_ptr app; + //if (options.sift_matching->use_gpu && kUseOpenGL) { + // app.reset(new QApplication(argc, argv)); + //} TransitiveFeatureMatcher feature_matcher(*options.transitive_matching, *options.sift_matching, *options.database_path); if (options.sift_matching->use_gpu && kUseOpenGL) { - RunThreadWithOpenGLContext(&feature_matcher); + //RunThreadWithOpenGLContext(&feature_matcher); + std::cerr << "ERROR: OpenGL Disabled."; + return EXIT_FAILURE; } else { feature_matcher.Start(); feature_matcher.Wait(); @@ -1800,17 +1816,19 @@ int RunVocabTreeMatcher(int argc, char** argv) { options.AddVocabTreeMatchingOptions(); options.Parse(argc, argv); - std::unique_ptr app; - if (options.sift_matching->use_gpu && kUseOpenGL) { - app.reset(new QApplication(argc, argv)); - } + //std::unique_ptr app; + //if (options.sift_matching->use_gpu && kUseOpenGL) { + // app.reset(new QApplication(argc, argv)); + //} VocabTreeFeatureMatcher feature_matcher(*options.vocab_tree_matching, *options.sift_matching, *options.database_path); if (options.sift_matching->use_gpu && kUseOpenGL) { - RunThreadWithOpenGLContext(&feature_matcher); + //RunThreadWithOpenGLContext(&feature_matcher); + std::cerr << "ERROR: OpenGL Disabled."; + return EXIT_FAILURE; } else { feature_matcher.Start(); feature_matcher.Wait(); @@ -2008,7 +2026,7 @@ int main(int argc, char** argv) { InitializeGlog(argv); std::vector> commands; - commands.emplace_back("gui", &RunGraphicalUserInterface); +// commands.emplace_back("gui", &RunGraphicalUserInterface); commands.emplace_back("automatic_reconstructor", &RunAutomaticReconstructor); commands.emplace_back("bundle_adjuster", &RunBundleAdjuster); commands.emplace_back("color_extractor", &RunColorExtractor); diff --git a/src/feature/extraction.h b/src/feature/extraction.h index 141681812..da848f836 100644 --- a/src/feature/extraction.h +++ b/src/feature/extraction.h @@ -35,7 +35,7 @@ #include "base/database.h" #include "base/image_reader.h" #include "feature/sift.h" -#include "util/opengl_utils.h" +//#include "util/opengl_utils.h" #include "util/threading.h" namespace colmap { @@ -129,7 +129,7 @@ class SiftFeatureExtractorThread : public Thread { const SiftExtractionOptions sift_options_; std::shared_ptr camera_mask_; - std::unique_ptr opengl_context_; +// std::unique_ptr opengl_context_; JobQueue* input_queue_; JobQueue* output_queue_; diff --git a/src/feature/matching.h b/src/feature/matching.h index 2fb2f01b3..fa058586f 100644 --- a/src/feature/matching.h +++ b/src/feature/matching.h @@ -40,7 +40,7 @@ #include "feature/sift.h" #include "util/alignment.h" #include "util/cache.h" -#include "util/opengl_utils.h" +//#include "util/opengl_utils.h" #include "util/threading.h" #include "util/timer.h" @@ -259,7 +259,7 @@ class SiftGPUFeatureMatcher : public FeatureMatcherThread { JobQueue* input_queue_; JobQueue* output_queue_; - std::unique_ptr opengl_context_; +// std::unique_ptr opengl_context_; // The previously uploaded images to the GPU. std::array prev_uploaded_image_ids_; @@ -303,7 +303,7 @@ class GuidedSiftGPUFeatureMatcher : public FeatureMatcherThread { JobQueue* input_queue_; JobQueue* output_queue_; - std::unique_ptr opengl_context_; +// std::unique_ptr opengl_context_; // The previously uploaded images to the GPU. std::array prev_uploaded_image_ids_; diff --git a/src/feature/sift.cc b/src/feature/sift.cc index fc18cc62f..0e82706bb 100644 --- a/src/feature/sift.cc +++ b/src/feature/sift.cc @@ -34,6 +34,9 @@ #include #include #include +#include +#include +#include #include "SiftGPU/SiftGPU.h" #include "VLFeat/covdet.h" @@ -43,7 +46,7 @@ #include "util/logging.h" #include "util/math.h" #include "util/misc.h" -#include "util/opengl_utils.h" +//#include "util/opengl_utils.h" namespace colmap { namespace { diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 79da54f7a..5f77bf3df 100755 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -40,7 +40,7 @@ COLMAP_ADD_SOURCES( math.h math.cc matrix.h misc.h misc.cc - opengl_utils.h opengl_utils.cc +# opengl_utils.h opengl_utils.cc option_manager.h option_manager.cc ply.h ply.cc random.h random.cc diff --git a/src/util/opengl_utils.cc b/src/util/opengl_utils.cc index 90de7824b..93d730cbc 100755 --- a/src/util/opengl_utils.cc +++ b/src/util/opengl_utils.cc @@ -30,15 +30,14 @@ // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) #include "util/opengl_utils.h" - -#include +#include #include "util/logging.h" namespace colmap { OpenGLContextManager::OpenGLContextManager() - : parent_thread_(QThread::currentThread()), + : parent_thread_(std::this_thread::get_id()), current_thread_(nullptr), make_current_action_(new QAction(this)) { CHECK_NOTNULL(QCoreApplication::instance()); diff --git a/src/util/option_manager.cc b/src/util/option_manager.cc index 70975fb36..87f50621c 100755 --- a/src/util/option_manager.cc +++ b/src/util/option_manager.cc @@ -43,7 +43,7 @@ #include "mvs/meshing.h" #include "mvs/patch_match.h" #include "optim/bundle_adjustment.h" -#include "ui/render_options.h" +//#include "ui/render_options.h" #include "util/misc.h" #include "util/version.h" @@ -70,7 +70,7 @@ OptionManager::OptionManager(bool add_project_options) { stereo_fusion.reset(new mvs::StereoFusionOptions()); poisson_meshing.reset(new mvs::PoissonMeshingOptions()); delaunay_meshing.reset(new mvs::DelaunayMeshingOptions()); - render.reset(new RenderOptions()); +// render.reset(new RenderOptions()); Reset(); @@ -179,7 +179,7 @@ void OptionManager::AddAllOptions() { AddStereoFusionOptions(); AddPoissonMeshingOptions(); AddDelaunayMeshingOptions(); - AddRenderOptions(); +// AddRenderOptions(); } void OptionManager::AddLogOptions() { @@ -671,7 +671,7 @@ void OptionManager::AddDelaunayMeshingOptions() { AddAndRegisterDefaultOption("DelaunayMeshing.num_threads", &delaunay_meshing->num_threads); } - +/* void OptionManager::AddRenderOptions() { if (added_render_options_) { return; @@ -688,7 +688,7 @@ void OptionManager::AddRenderOptions() { AddAndRegisterDefaultOption("Render.projection_type", &render->projection_type); } - +*/ void OptionManager::Reset() { FLAGS_logtostderr = false; FLAGS_v = 2; @@ -719,7 +719,7 @@ void OptionManager::Reset() { added_stereo_fusion_options_ = false; added_poisson_meshing_options_ = false; added_delaunay_meshing_options_ = false; - added_render_options_ = false; +// added_render_options_ = false; } void OptionManager::ResetOptions(const bool reset_paths) { @@ -742,7 +742,7 @@ void OptionManager::ResetOptions(const bool reset_paths) { *stereo_fusion = mvs::StereoFusionOptions(); *poisson_meshing = mvs::PoissonMeshingOptions(); *delaunay_meshing = mvs::DelaunayMeshingOptions(); - *render = RenderOptions(); +// *render = RenderOptions(); } bool OptionManager::Check() { @@ -775,7 +775,7 @@ bool OptionManager::Check() { if (poisson_meshing) success = success && poisson_meshing->Check(); if (delaunay_meshing) success = success && delaunay_meshing->Check(); - if (render) success = success && render->Check(); +// if (render) success = success && render->Check(); return success; } diff --git a/src/util/option_manager.h b/src/util/option_manager.h index 9f67b42ff..c7a78a2de 100755 --- a/src/util/option_manager.h +++ b/src/util/option_manager.h @@ -136,7 +136,7 @@ class OptionManager { std::shared_ptr poisson_meshing; std::shared_ptr delaunay_meshing; - std::shared_ptr render; +// std::shared_ptr render; private: template @@ -172,7 +172,7 @@ class OptionManager { bool added_stereo_fusion_options_; bool added_poisson_meshing_options_; bool added_delaunay_meshing_options_; - bool added_render_options_; +// bool added_render_options_; }; ////////////////////////////////////////////////////////////////////////////////