Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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>