Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

'reconstruct' is not a member of 'cv::sfm'

I'm trying to get some simple SfM code running, but am getting the following error:

main.cpp: In function ‘int main(int, char**)’:
main.cpp:27:3: error: ‘reconstruct’ is not a member of ‘cv::sfm’
   cv::sfm::reconstruct(fns, Rs_est, ts_est, K, points3d_est, is_projective);
   ^~

I am compiling opencv using the following commands:

$ cmake -DOPENCV_EXTRA_MODULES_PATH=~/Code/opencv/opencv_contrib/modules -DBUILD_EXAMPLES=ON -DBUILD_SHARED_LIBS=ON -DBUILD_opencv_sfm=ON ~/Code/opencv/opencv
$ make -j3
$ sudo make install

(I know some of those CMake options are probably redundant, but I was trying everything I could think of.)

The example_sfm_scene_reconstruction file does not appear in my build/bin directory.

The CMake output shows that I have all of the dependencies listed in the SfM README:

-- Found installed version of gflags: /usr/local/lib/cmake/gflags
-- Detected gflags version: 2.2.0
-- Found required Ceres dependency: Eigen version 3.3.3 in /usr/local/include/eigen3
-- Found required Ceres dependency: glog
-- Found installed version of gflags: /usr/local/lib/cmake/gflags
-- Detected gflags version: 2.2.0
-- Found required Ceres dependency: gflags
-- Found Ceres version: 1.12.0 installed in: /usr/local with components: [LAPACK, SuiteSparse, SparseLinearAlgebraLibrary, SchurSpecializations, OpenMP]
-- Checking SFM deps... TRUE

I also have Doxygen, which I saw at the top of opencv_contrib/modules/sfm/include/opencv2/reconstruction.hpp, just in case that was important:

--   Documentation:
--     Doxygen:                     /usr/bin/doxygen (ver 1.8.13)

And finally, if I comment out my code that's calling "reconstruct" and instead try to use "meanAndVarianceAlongRows", I get a different error:

./sfm: error while loading shared libraries: libopencv_core.so.3.2: cannot open shared object file: No such file or directory

Here is the code I'm trying to run:

#include <opencv2/sfm.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/core.hpp>

#include <iostream>
#include <string>
#include <vector>

int main(int argc, char** argv) {
  std::vector<cv::String> fns;
  cv::glob("./meijijingu/", fns);
  cv::String a("test string");

  std::cout << "Input files:\n";
  for (int i = 0; i < fns.size(); i += 1) {
    std::cout << "  " << fns[i] << '\n';
  }
  std::cout << '\n';

  cv::Matx33d K = cv::Matx33d(
    7, 0, 400,
    0, 7, 300,
    0, 0,   1
  );
  bool is_projective = true;
  std::vector<cv::Mat> Rs_est, ts_est, points3d_est;
  cv::sfm::reconstruct(fns, Rs_est, ts_est, K, points3d_est, is_projective);

  std::cout << "Estimated 3D points: " << points3d_est.size() << '\n';
  std::cout << "Estimated cameras:   " << Rs_est.size() << '\n';
  std::cout << "Refined intrinsics:\n" << K << '\n';

  // cv::Mat A(2, 2, CV_16SC1);
  // cv::Mat m, v;
  // cv::sfm::meanAndVarianceAlongRows(A, m, v);
  // std::cout << m << '\n' << v << '\n';

  return 0;
}

And I'm compiling it like this:

g++ -g -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_calib3d -lopencv_sfm -o sfm main.cpp

Any help or insight would be really appreciated!