Error in OpenCV 3.4.0 [closed]

asked 2017-12-25 03:56:32 -0500

Sakthivel S gravatar image

updated 2017-12-25 05:43:35 -0500


reconstruction(master)$ g++ example_sfm.cpp -I /usr/include/eigen3/ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L /usr/local/share/OpenCV/3rdparty/lib/ -L/usr/local/lib/ -L /usr/include/eigen3/ -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_optflow -lopencv_sfm -lopencv_viz
    In file included from /usr/local/include/opencv2/core.hpp:56:0,
                     from /usr/local/include/opencv2/sfm/conditioning.hpp:39,
                     from /usr/local/include/opencv2/sfm.hpp:39,
                     from example_sfm.cpp:3:
    /usr/local/include/opencv2/core/traits.hpp: In instantiation of ‘struct cv::traits::Type<std::__cxx11::basic_string<char> >’:
    /usr/local/include/opencv2/core/mat.inl.hpp:85:32:   required from ‘cv::_InputArray::_InputArray(const std::vector<_Tp>&) [with _Tp = std::__cxx11::basic_string<char>]’
    example_sfm.cpp:66:86:   required from here
    **/usr/local/include/opencv2/core/traits.hpp:366:8: error: ‘type’ is not a member of ‘cv::DataType<std::__cxx11::basic_string<char> >’**
     { enum { value = DataType<T>::type }; };
            ^
    reconstruction(master)$ pkg-config --modversion opencv
    3.4.0

Please let me know the solution for this error.

Source Code : example_sfm.cpp https://github.com/alyssaq/reconstruc...

#define CERES_FOUND true


#include <opencv2/sfm.hpp>
#include <opencv2/viz.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/core.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
using namespace cv;
using namespace cv::sfm;

static void help() {
  cout
      << "\n------------------------------------------------------------------------------------\n"
      << " This program shows the multiview reconstruction capabilities in the \n"
      << " OpenCV Structure From Motion (SFM) module.\n"
      << " It reconstruct a scene from a set of 2D images \n"
      << " Usage:\n"
      << "        example_sfm_scene_reconstruction <path_to_file> <f> <cx> <cy>\n"
      << " where: path_to_file is the file absolute path into your system which contains\n"
      << "        the list of images to use for reconstruction. \n"
      << "        f  is the focal lenght in pixels. \n"
      << "        cx is the image principal point x coordinates in pixels. \n"
      << "        cy is the image principal point y coordinates in pixels. \n"
      << "------------------------------------------------------------------------------------\n\n"
      << endl;
}
int getdir(const string _filename, vector<string> &files)
{
  ifstream myfile(_filename.c_str());
  if (!myfile.is_open()) {
    cout << "Unable to read file: " << _filename << endl;
    exit(0);
  } else {;
    size_t found = _filename.find_last_of("/\\");
    string line_str, path_to_file = _filename.substr(0, found);
    while ( getline(myfile, line_str) ) {
      cout << line_str << endl;
      files.push_back(line_str);
    }
  }
  return 1;
}
int main(int argc, char* argv[])
{
  // Read input parameters
  if ( argc != 5 )
  {
    help();
    exit(0);
  }
  // Parse the image paths
  vector<string> images_paths;
  getdir( argv[1], images_paths );
  // Build instrinsics
  float f  = atof(argv[2]),
        cx = atof(argv[3]), cy = atof(argv[4]);
  Matx33d K = Matx33d( f, 0, cx,
                       0, f, cy,
                       0, 0,  1);
  bool is_projective = true;
  vector<Mat> Rs_est, ts_est, points3d_estimated;
  sfm::reconstruct(images_paths, Rs_est, ts_est, K, points3d_estimated, is_projective);

  // Print output
  cout << "\n----------------------------\n" << endl;
  cout << "Reconstruction: " << endl;
  cout << "============================" << endl;
  cout << "Estimated 3D points: " << points3d_estimated.size() << endl;
  cout << "Estimated cameras: " << Rs_est.size() << endl;
  cout << "Refined intrinsics: " << endl << K << endl << endl;
  cout << "3D Visualization: " << endl;
  cout << "============================" << endl;
  viz::Viz3d window("Coordinate ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2017-12-26 04:03:42.775523

Comments

may we see your example_sfm.cpp ?

berak gravatar imageberak ( 2017-12-25 04:10:14 -0500 )edit

please try with a vector<cv::String> , instead of vector<std::string>here

also see declaration here

berak gravatar imageberak ( 2017-12-25 05:40:14 -0500 )edit

You mean I have to change in opencv library file reconstruct.hpp at line 111.

Sakthivel S gravatar imageSakthivel S ( 2017-12-25 05:55:57 -0500 )edit

no, only your code. use cv::String, not std::string, again.

berak gravatar imageberak ( 2017-12-25 06:07:27 -0500 )edit

Thanks berak. It's compiling now.

Sakthivel S gravatar imageSakthivel S ( 2017-12-25 23:09:46 -0500 )edit