robotology / stereo-vision

Repository containing apps for stereo vision
https://robotology.github.io/stereo-vision/
GNU General Public License v2.0
19 stars 19 forks source link

Could not build SFM #31

Closed xEnVrE closed 3 years ago

xEnVrE commented 3 years ago

As per the title,

the build process stops with the following error:

[ 91%] Building CXX object modules/SFM/CMakeFiles/SFM.dir/SFM.cpp.o
In file included from /home/xenvre/stereo-vision/modules/SFM/SFM.h:250,
                 from /home/xenvre/stereo-vision/modules/SFM/SFM.cpp:22:
/home/xenvre/stereo-vision/modules/SFM/fastBilateral.hpp: In function ‘void cv_extend::bilateralFilterImpl(cv::Mat1d, cv::Mat1d, double, double)’:
/home/xenvre/stereo-vision/modules/SFM/fastBilateral.hpp:126:24: warning: narrowing conversion of ‘(std::size_t)small_height’ from ‘std::size_t’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowing]
  126 |     int data_size[] = {small_height, small_width, small_depth};
      |                        ^~~~~~~~~~~~
/home/xenvre/stereo-vision/modules/SFM/fastBilateral.hpp:126:38: warning: narrowing conversion of ‘(std::size_t)small_width’ from ‘std::size_t’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowin ]
  126 |     int data_size[] = {small_height, small_width, small_depth};
      |                                      ^~~~~~~~~~~
/home/xenvre/stereo-vision/modules/SFM/fastBilateral.hpp:126:51: warning: narrowing conversion of ‘(std::size_t)small_depth’ from ‘std::size_t’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowin ]
  126 |     int data_size[] = {small_height, small_width, small_depth};
      |                                                   ^~~~~~~~~~~
/home/xenvre/stereo-vision/modules/SFM/SFM.cpp: In member function ‘void SFM::fillWorld3D(yarp::sig::ImageOf<yarp::sig::PixelRgbFloat>&, yarp::sig::ImageOf<yarp::sig::PixelRgbFloat>&)’:
/home/xenvre/stereo-vision/modules/SFM/SFM.cpp:1324:45: error: conversion from ‘const long int’ to non-scalar type ‘CvScalar’ requested
 1324 |             CvScalar scal = disp16m.at<long>(v_, u_);
      |                             ~~~~~~~~~~~~~~~~^~~~~~~~
make[2]: *** [modules/SFM/CMakeFiles/SFM.dir/build.make:76: modules/SFM/CMakeFiles/SFM.dir/SFM.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:202: modules/SFM/CMakeFiles/SFM.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

The error seems to be due to the following conversion:

https://github.com/robotology/stereo-vision/blob/8b61da4ce6080e792f17c12c91fc23fda903fdae/modules/SFM/SFM.cpp#L1324

That line of code was changed in a recent PR (see https://github.com/robotology/stereo-vision/pull/30/files).

I am running Ubuntu 20.04.2 with OpenCV 4.2.0 compiled from source in order to enable non-free SIFT features.

pattacini commented 3 years ago

cc @Nicogene

Nicogene commented 3 years ago

@xEnVrE which options did you enable from the cmake? From what I remember stereo-vision has several options, not explicitly dependent one from each other, and that may clash between them. For example, there is COMPILE_LIB that it is not mandatory, but without it USE_DISPARITYMODULE doesn't compile or something similar.

In any case, this seems a problem with opencv 4, recently(2 months ago) I experienced similar issues but it is not clear to me if stereo-vision support opencv2, that it is incompatible with opencv4.

xEnVrE commented 3 years ago

Hi @Nicogene,

the options that I used are COMPILE_LIB and USE_SFM.

I though that stereo-vision was supporting OpenCV 4 as there were some commits in the past about making it OpenCV 4-friendly.

Nicogene commented 3 years ago

Could you try it with this branch https://github.com/robotology/stereo-vision/tree/fix/compilationScalar ?

(I did not try it because I have issues installing some dependencies)

xEnVrE commented 3 years ago

With that change it compiles (not sure if it compiles with OpenCV < 4.2 though).

Nicogene commented 3 years ago

It should, cv::Scalar is ther since opencv3 I suppose

xEnVrE commented 3 years ago

Thank you @Nicogene