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

Compilation error for OpenCV nonfree components #33

Closed carlomazzola closed 2 years ago

carlomazzola commented 2 years ago

Hi all,

I'm trying to compile the stereo-vision module but it returns the following error:

fatal error: opencv2/xfeatures2d/nonfree.hpp: No such file or directory 27 | #include <opencv2/xfeatures2d/nonfree.hpp> | ^~~~~~~~~ compilation terminated.

I saw in the documentation that the SIFT are among the dependencies. Is the error related to this, or the reason is another one? I use an Ubuntu 20 machine with Yarp 3.5.1 and OpenCV 4.2.0 installed.

Thanks!

pattacini commented 2 years ago

Hi @carlomazzola

How did you install OpenCV 4.2.0?

carlomazzola commented 2 years ago

Hi @pattacini,

it is the default version that is already present in Ubuntu 20.04. we recently installed it in the machine of the robot.

pattacini commented 2 years ago

The default version ain't shipped with the nonfree modules.

You ought to clone the opencv repo locally together with opencv_contrib and configure the project with the proper CMake flags.

The process is pretty much resumed at https://github.com/robotology/iol#dependencies.

You should most likely remove the default OpenCV to prevent clashes.

pattacini commented 2 years ago

I've made the README more explicit about that. See #34.

pattacini commented 2 years ago

it is the default version that is already present in Ubuntu 20.04. we recently installed it in the machine of the robot.

If the system is a PC belonging to the cluster of the robot, how did you build the ecosystem (e.g., yarp, icub-main...)?

Did you use the robotology-superbuild method?

cc @traversaro

carlomazzola commented 2 years ago

Thank you for adding the information in the readme. Yes, we installed everything with the superbuild.

pattacini commented 2 years ago

Yes, we installed everything with the superbuild.

So, I'd recommend that you do the following, in order:

  1. Uninstall the apt version of OpenCV from that PC.
  2. Build OpenCV + contrib modules as reported above.
    • If you opt for make install, then you're done.
    • Alternatively, if you stick to the build, you have to export the env var OpenCV_DIR pointing to build location.
  3. Rebuild the superbuild.
  4. Rebuild stereo-vision.

Hope this helps out.

pattacini commented 2 years ago

Closing for now. Feel free to open it up again if required.