Opencv_contrib: SFM error when compiling with a vector resize function?

Created on 26 Jul 2017  Â·  20Comments  Â·  Source: opencv/opencv_contrib

Hi,

I try to launch the Scene reconstruction code from sfm mofule in opencv.

Scene reconstrucrion
I already install all the libraries. The compilation works but when I launch my program whith the line command, I have this erreur:

Initialize nViewMatcher ... OK
Performing Cross Matching ...
And the debugger crash.

I know the debugger stops here (which is my main file)
reconstruct_function
Then I follow where the error comes and I found it there:
features.resize(features_cv.size());
previously declared liked that "libmv::vector features;"

I don't know where the issue comes. I assure I don't change a line of the main program I think I well install all the dependencies but her i'm blocked if someone can helps me.

Im running on Windows.

System information
  • OpenCV => 3.2 (contrib_mod too)
  • Operating System / Platform => Windows10 64 Bit
  • Compiler => QT 5.9, MingW53_32

Thanks

builinstall question (invalid tracker)

Most helpful comment

OK thanks the building works. ( I added typedef unsigned int in robust_estimation.h to)
But now in qt : 'reconstruct' was not declared ...
It may come from this line in reconstruct.hpp:

#if defined(CV_DOXYGEN) || defined(CERES_FOUND)

or
#if CERES_FOUND

but in Cmake opencv seems have found ceres.
I watch on this issue but It's not helping me.
Issues 476

All 20 comments

When you post an issue please fill all values:
System information (version)
Example

  • OpenCV => 3.1 ?
  • Operating System / Platform => Windows 64 Bit ?
  • Compiler => Visual Studio 2015 ?

Instead of giving a window path to the error you can give a link to git :
features.resize(features_cv.size());

Ok sorry it's my first post here. I don't know how to set a label for this issue to.

You mean label 'incomplete'? I cannot set too. only admin user can set it
About your config MingW3.2 is it a 32 bits or 64 bits compiler? I think you have compile ceres and eigen?

It's Mingw53_32 32bits I correct. Yes I have Ceres and Eigen install with opencv and I don't not have this message anymore :

sfm disabled because depedencies

So opencv find all the dependencies.

But you may have right in
reconstruct.hpp
sfm.hpp
I Comment if 'CERES_FOUND` because it didn't work with the if. But in opencv all is fine and eigen,glog and gflags is well found so i suppose CERES to. I don't know what is wrong.

You cannot change source code. If ceres is not found problem is elsewhere. Have you compile ceres,glog and gflag and link ceres ?

Check your build configuration. Don't mix Debug/Release C++ binaries (including glog/gflags/ceres/OpenCV/OpenCV contrib/etc).

I install again the dependencies and I don't change a line of code but still the same issue
Here my Opencv Cmake configure message:

Found VTK ver. 7.1.1 (usefile: C:/Program Files (x86)/VTK/lib/cmake/vtk-7.1/UseVTK.cmake)
Caffe: NO
Protobuf: NO
Glog: YES
freetype2: NO
harfbuzz: NO
Found required Ceres dependency: Eigen version 3.3.4 in C:/ceres/Eigen3/include/eigen3
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found Gflags: C:/ceres/gflags/include
Found installed version of glog: C:/ceres/glog-bin
Detected glog version: 0.3.5
Found required Ceres dependency: glog
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found required Ceres dependency: gflags
Found Ceres version: 1.12.0 installed in: C:/ceres/Ceres with components: [EigenSparse, SparseLinearAlgebraLibrary, SchurSpecializations, OpenMP]
Checking SFM deps... TRUE
.....
Found required Ceres dependency: Eigen version 3.3.4 in C:/ceres/Eigen3/include/eigen3
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found installed version of glog: C:/ceres/glog-bin
Detected glog version: 0.3.5
Found required Ceres dependency: glog
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found required Ceres dependency: gflags
Found Ceres version: 1.12.0 installed in: C:/ceres/Ceres with components: [EigenSparse, SparseLinearAlgebraLibrary, SchurSpecializations, OpenMP]
Checking SFM deps... TRUE
...
Extra modules:
Location (extra): C:/opencv_contrib-3.2.0/modules
Version control (extra): unknown

Platform:
Timestamp: 2017-07-26T13:49:09Z
Host: Windows 10.0.14393 AMD64
CMake: 3.9.0-rc3
CMake generator: MinGW Makefiles
CMake build tool: C:/Qt/Tools/mingw530_32/bin/mingw32-make.exe
Configuration: Release
..
...
Other third-party libraries:
Use IPP: NO
Use IPP Async: NO
Use Lapack: NO
Use Eigen: YES (ver 3.3.4)
Use Cuda: NO
Use OpenCL: YES
Use OpenVX: NO
Use custom HAL: NO

The message appears two times during Cmake configure but for me it found eigen glog gflags and ceres. I don't know why the programs stops here

Performing Cross Matching ...

Can you try sfm-example-match_reconstruct without parameters? What is exactly error message?

it works without parameters:
And the sfm-example-match_reconstruct works without parameters to.

### This program shows the multiview reconstruction capabilities in the
OpenCV Structure From Motion (SFM) module.
It reconstruct a scene from a set of 2D images
Usage:
example_sfm_scene_reconstruction
where: path_to_file is the file absolute path into your system which contains
the list of images to use for reconstruction.
f is the focal lenght in pixels.
cx is the image principal point x coordinates in pixels.
cy is the image principal point y coordinates in pixels.

But when I give the parameters with the good path file, the files doesn't appear and it stops there in the console:

Initialize nViewMatcher ... OK
Performing Cross Matching ...

cause of this function:
features.resize(features_cv.size());

I don't understand you have got problem with this program sfm-example-scene_reconstruction.

Have you try sfm-example-match_reconstruct ? You have got VTK you should have VIZ and you must see two spheres.

The sfm-example_reconstruct worked fine without parameters and others viz programs to. It's when I give parameters the execution fail.

When I install again the problem seem to come from a math redeclaration of sincos of sf numeric.h header (static function) and in math.h of qt/ tools mingw my compiler:

Scanning dependencies of target numeric
[ 82%] Building CXX object modules/sfm/src/libmv_light/libmv/numeric/CMakeFiles/numeric.dir/numeric.cc.obj
In file included from C:\opencv_contrib-3.2.0\modules\sfm\src\libmv_light\libmv\numeric\numeric.cc:22:0:
C:/opencv_contrib-3.2.0/modules/sfm/src/libmv_light/libmv/numeric/numeric.h: In function 'void sincos(double, double, double)':
C:/opencv_contrib-3.2.0/modules/sfm/src/libmv_light/libmv/numeric/numeric.h:37:56: error: 'void sincos(double, double, double)' was declared 'extern' and later 'static' [-fpermissive]
static void sincos(double x, double sinx, double *cosx) {
^
In file included from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/cmath:44:0,
from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/complex:44,
from C:/ceres/Eigen3/include/eigen3/Eigen/Core:80,
from C:/ceres/Eigen3/include/eigen3/Eigen/Cholesky:11,
from C:/opencv_contrib-3.2.0/modules/sfm/src/libmv_light/libmv/numeric/numeric.h:28,
from C:\opencv_contrib-3.2.0\modules\sfm\src\libmv_light\libmv\numeric\numeric.cc:22:
C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/math.h:248:16: note: previous declaration of 'void sincos(double, double
, double)'
void __cdecl sincos (double __x, double *p_sin, double *p_cos);
^
modules\sfm\src\libmv_light\libmv\numeric\CMakeFiles\numeric.dir\build.make:62: recipe for target 'modules/sfm/src/libmv_light/libmv/numeric/CMakeFiles/numeric.dir/numeric.cc.obj' failed
mingw32-make[2]:
[modules/sfm/src/libmv_light/libmv/numeric/CMakeFiles/numeric.dir/numeric.cc.obj] Error 1
CMakeFiles\Makefile2:21070: recipe for target 'modules/sfm/src/libmv_light/libmv/numeric/CMakeFiles/numeric.dir/all' failed
mingw32-make[1]:
[modules/sfm/src/libmv_light/libmv/numeric/CMakeFiles/numeric.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *
* [all] Error 2

disable qt in opencv. You can still use opencv in QT

Thank you LaurentBerger for your help but always the same issue.
I compiled with the mingw compiler from QT installed in Tools subdirectories of QT here:

C:\Qt\Tools\mingw530_32\bin

Even if I unchecked WITH_QT the same erreur happened "_sincos pprevious declared in QT/tool..._"

I tried to install the original MINGW compiler but other issues have come so I prefer stay on the first compiler install in the subdirectories of QT.
On my Windows Path there is only this path:C:\Qt\Tools\mingw530_32\bin to compile.

How really disable QT in Opencv?

don't forget to delete cmakecache.txt

Yes I did it. I install again all opencv contrib and source. select mingw from C:\Qt\Tools\mingw530_32\bin.
In opencv I put the path for CERES Eigen, glog et gflags for sfm.
Put (WITH_QT=OFF). Configure, generate, see:

Detected version of GNU GCC: 53 (503)
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Found VTK ver. 7.1.1 (usefile: C:/Program Files (x86)/VTK/lib/cmake/vtk-7.1/UseVTK.cmake)
Glog: YES
Found required Ceres dependency: Eigen version 3.3.4 in C:/ceres/Eigen3/include/eigen3
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found Gflags: C:/ceres/gflags/include
Found installed version of glog: C:/ceres/glog-bin
Detected glog version: 0.3.5
Found required Ceres dependency: glog
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found required Ceres dependency: gflags
Found Ceres version: 1.12.0 installed in: C:/ceres/Ceres with components: [SchurSpecializations, OpenMP]
Checking SFM deps... TRUE
Found required Ceres dependency: Eigen version 3.3.4 in C:/ceres/Eigen3/include/eigen3
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found installed version of glog: C:/ceres/glog-bin
Detected glog version: 0.3.5
Found required Ceres dependency: glog
Found installed version of gflags: C:/ceres/gflags/lib/cmake/gflags
Detected gflags version: 2.2.1
Found required Ceres dependency: gflags
Found Ceres version: 1.12.0 installed in: C:/ceres/Ceres with components: [SchurSpecializations, OpenMP]
Checking SFM deps... TRUE
Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE
General configuration for OpenCV 3.2.0 =====================================
Version control: unknown
Extra modules:
Location (extra): C:/opencv_contrib-3.2.0/modules
Version control (extra): unknown
Platform:
Timestamp: 2017-07-29T08:53:56Z
Host: Windows 10.0.14393 AMD64
CMake: 3.9.0-rc3
CMake generator: MinGW Makefiles
CMake build tool: C:/Qt/Tools/mingw530_32/bin/mingw32-make.exe
Configuration: Release
C/C++:
Built as dynamic libs?: YES
C++ Compiler: C:/Qt/Tools/mingw530_32/bin/g++.exe (ver 5.3.0)
C++ flags (Release): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: C:/Qt/Tools/mingw530_32/bin/gcc.exe
C flags (Release): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -O2 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
ccache: NO
Precompiled headers: YES
Extra dependencies: comctl32 gdi32 ole32 setupapi ws2_32 vfw32 winmm correspondence multiview numeric glog::glog gflags_static simple_pipeline vtkRenderingOpenGL2 vtkCommonCore vtksys vtkCommonDataModel vtkCommonMath vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkIOImage vtkDICOMParser vtkmetaio vtkzlib vtkjpeg vtkpng vtktiff vtkImagingCore vtkRenderingCore vtkCommonColor vtkCommonComputationalGeometry vtkFiltersCore vtkFiltersGeneral vtkFiltersGeometry vtkFiltersSources vtkglew vtkInteractionStyle vtkFiltersExtraction vtkFiltersStatistics vtkImagingFourier vtkalglib vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOCore vtkFiltersTexture vtkRenderingFreeType vtkfreetype vtkIOExport vtkRenderingGL2PSOpenGL2 vtkgl2ps vtkIOGeometry vtkIOLegacy
3rdparty dependencies: zlib libjpeg libwebp libpng libtiff libjasper IlmImf libprotobuf

OpenCV modules:
To be built: core flann imgproc ml photo reg surface_matching video viz dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping sfm stitching structured_light
Disabled: world contrib_world
Disabled by dependency: -
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 cnn_3dobj cvv freetype hdf matlab
Windows RT support: NO
GUI:
QT: NO
Win32 UI: YES
OpenGL support: NO
VTK support: YES (ver 7.1.1)
Other third-party libraries:
Use Eigen: YES (ver 3.3.4)
Use OpenCL: YES
Tests and samples:
Tests: YES
Performance tests: YES
C/C++ Examples: NO
Install path: C:/opencv-bin/install
cvconfig.h is in: C:/opencv-bin


Configuring done
Generating done

After I launch in cmd.exe launch mingw32-make ans the issue appears "_sincos pprevious declared in QT/tool..._"

Are you in 32 bits? if yes try to replace line #if !defined(__MINGW64__) by #if !defined(__MINGW64__) && !defined(__MINGW32__)

OK thanks the building works. ( I added typedef unsigned int in robust_estimation.h to)
But now in qt : 'reconstruct' was not declared ...
It may come from this line in reconstruct.hpp:

#if defined(CV_DOXYGEN) || defined(CERES_FOUND)

or
#if CERES_FOUND

but in Cmake opencv seems have found ceres.
I watch on this issue but It's not helping me.
Issues 476

Here I don't understand because before you can run example :

The sfm-example_reconstruct worked fine without parameters and others viz programs to.

Don't change source code I don't think that's problem origin.

But now in qt

What do you mean?

You build opencv without qt . yes ? if yes then you must copy all include in your source file

You're right, I forgot to include headers in qt creator. I will see later and I'm focusing on the example for the moment.

With the example_sfm_scene_reconstruction.exe in cmd:

example_sfm_scene_reconstruction.exe C:\Users\Yoann\Documents\ra\scan\sfm\dataset_files.txt 350 240 360

The program is launching,

Initialize nViewMatcher ... OK
Performing Cross Matching ...
And the program crash likes in the beginning. I may forget to include header you're right

I don't know if you can debug program using mingw32. In vs stack is

> opencv_sfm330d.dll!libmv::vector<libmv::Feature * __ptr64,Eigen::aligned_allocator<libmv::Feature * __ptr64> >::construct(int start, int end) Ligne 139 C++ opencv_sfm330d.dll!libmv::vector<libmv::Feature * __ptr64,Eigen::aligned_allocator<libmv::Feature * __ptr64> >::resize(unsigned __int64 size) Ligne 97 C++ opencv_sfm330d.dll!libmv::correspondence::nRobustViewMatching::computeData(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & filename) Ligne 66 C++ opencv_sfm330d.dll!libmv::correspondence::nRobustViewMatching::computeCrossMatch(const std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > & vec_data) Ligne 164 C++ opencv_sfm330d.dll!cv::sfm::libmv_solveReconstructionImpl(const std::vector<cv::String,std::allocator<cv::String> > & images, const cv::sfm::libmv_CameraIntrinsicsOptions * libmv_camera_intrinsics_options, cv::sfm::libmv_ReconstructionOptions * libmv_reconstruction_options) Ligne 133 C++ opencv_sfm330d.dll!cv::sfm::SFMLibmvReconstructionImpl<cv::sfm::SFMLibmvEuclideanReconstruction>::run(const std::vector<cv::String,std::allocator<cv::String> > & images) Ligne 215 C++ opencv_sfm330d.dll!cv::sfm::SFMLibmvReconstructionImpl<cv::sfm::SFMLibmvEuclideanReconstruction>::run(const std::vector<cv::String,std::allocator<cv::String> > & images, const cv::debug_build_guard::_InputOutputArray & K, const cv::debug_build_guard::_OutputArray & Rs, const cv::debug_build_guard::_OutputArray & Ts, const cv::debug_build_guard::_OutputArray & points3d) Ligne 229 C++ opencv_sfm330d.dll!cv::sfm::reconstruct_<std::vector<cv::String,std::allocator<cv::String> > >(const std::vector<cv::String,std::allocator<cv::String> > & input, const cv::debug_build_guard::_OutputArray & Rs, const cv::debug_build_guard::_OutputArray & Ts, const cv::debug_build_guard::_InputOutputArray & K, const cv::debug_build_guard::_OutputArray & points3d, const bool refinement) Ligne 88 C++ opencv_sfm330d.dll!cv::sfm::reconstruct(const std::vector<cv::String,std::allocator<cv::String> > images, const cv::debug_build_guard::_OutputArray & Rs, const cv::debug_build_guard::_OutputArray & Ts, const cv::debug_build_guard::_InputOutputArray & K, const cv::debug_build_guard::_OutputArray & points3d, bool is_projective) Ligne 251 C++ sfm-example-scene_reconstruction.exe!main(int argc, char * * argv) Ligne 77 C++

features_cv.size() is 8727 and features.size() is 0,is im_cv = {UINT8, 1 x 718 x 480}

Was this page helpful?
0 / 5 - 0 ratings