error in compiling example_sfm_trajectory_reconstruction.cpp from opencv_contrib sfm module
I am going through this tutorial : link text
This is my CMakeLists.
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project( sfm_module )
find_package(OpenCV COMPONENTS sfm REQUIRED)
find_package( Eigen3 REQUIRED )
find_package( Ceres REQUIRED )
message(STATUS "Found OpenCV version ${OpenCV_VERSION}")
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories( /usr/local/include/Eigen )
include_directories( /usr/local/include/opencv2/sfm )
include_directories( /usr/local/include/ceres )
set(OpenCV_LIBS /usr/local/lib/)
add_executable( example_sfm_trajectory_reconstruction example_sfm_trajectory_reconstruction.cpp )
target_link_libraries( example_sfm_trajectory_reconstruction ${OpenCV_LIBS})
I am getting the following errors in make :
~/Desktop/sfm_module/build$ make
Scanning dependencies of target example_sfm_trajectory_reconstruction
[ 50%] Building CXX object CMakeFiles/example_sfm_trajectory_reconstruction.dir/example_sfm_trajectory_reconstruction.cpp.o
[100%] Linking CXX executable example_sfm_trajectory_reconstruction
CMakeFiles/example_sfm_trajectory_reconstruction.dir/example_sfm_trajectory_reconstruction.cpp.o: In function `main':
example_sfm_trajectory_reconstruction.cpp:(.text+0xa50): undefined reference to `cv::sfm::reconstruct(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_InputOutputArray const&, cv::_OutputArray const&, bool)'
example_sfm_trajectory_reconstruction.cpp:(.text+0xc27): undefined reference to `cv::viz::Viz3d::Viz3d(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
example_sfm_trajectory_reconstruction.cpp:(.text+0xc83): undefined reference to
`cv::viz::Viz3d::setBackgroundColor(cv::viz::Color const&, cv::viz::Color const&)'
example_sfm_trajectory_reconstruction.cpp:(.text+0xc9c): undefined reference to `cv::viz::Viz3d::registerKeyboardCallback(void (*)(cv::viz::KeyboardEvent const&, void*), void*)'
example_sfm_trajectory_reconstruction.cpp:(.text+0xf08): undefined reference to `cv::viz::Viz3d::wasStopped() const'
example_sfm_trajectory_reconstruction.cpp:(.text+0xf8b): undefined reference to `cv::Mat::eye(int, int, int)'
example_sfm_trajectory_reconstruction.cpp:(.text+0x10b0): undefined reference to `cv::viz::WCube::WCube(cv::Point3_<double> const&, cv::Point3_<double> const&, bool, cv::viz::Color const&)'
These are the headers :
#define CERES_FOUND true
#include <opencv2/core.hpp>
#include <opencv2/sfm.hpp>
#include <opencv2/sfm/reconstruct.hpp>
#include <opencv2/viz.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/highgui.hpp>
#define CERES_FOUND true
did you add that ?
you have to make sure, cmake finds the CERES libs during the compilation of the opencv libs, NOT when building your program (it's too late, then)
I don't understand your cmakeLists.txt. you use find_package and you give a path in include_directories
@LBerger Later I commented out those include_directories, but got the same errors.
my cmakelist is here :
I think you can remove glog
@berak Yeah, I added that line after someone suggested in github issues. I installed Ceres later when I started the tutorial, after OpenCV and contrib installation was done. So rebuilding OpenCV is the only solution?
yes. it's the opencv_sfm library, which needs CERES support (it also depends on viz !), not your code
@LBerger Thanks for your upload, I tried with the CMakeLists.txt , but this is also producing the same error.
@berak Is this enough?
Or should I build along with the other cmake flags also as per the opencv installation tutorial?
to build opencv with ceres (windows10) :
with linux cmake must be able to detect ceres