Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: opencv2/xfeatures2d.hpp: No such file or directory #3

Closed
suljaxm opened this issue Jul 15, 2019 · 10 comments
Closed

fatal error: opencv2/xfeatures2d.hpp: No such file or directory #3

suljaxm opened this issue Jul 15, 2019 · 10 comments
Labels
good first issue Good for newcomers

Comments

@suljaxm
Copy link

suljaxm commented Jul 15, 2019

I installed opencv4.1.0 but when I ran the project, I couldn't find xfeatures2d.hpp.

the error is

matching2D.hpp:16:35: fatal error: opencv2/xfeatures2d.hpp: No such file or directory
 #include <opencv2/xfeatures2d.hpp>
                                   ^
compilation terminated.
CMakeFiles/2D_feature_tracking.dir/build.make:62: recipe for target 'CMakeFiles/2D_feature_tracking.dir/src/matching2D_Student.cpp.o' failed
make[2]: *** [CMakeFiles/2D_feature_tracking.dir/src/matching2D_Student.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/2D_feature_tracking.dir/all' failed
make[1]: *** [CMakeFiles/2D_feature_tracking.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

What should I do?

@roman-smirnov
Copy link
Contributor

see this issue opencv/opencv_contrib#1301

@suljaxm
Copy link
Author

suljaxm commented Jul 16, 2019

Thanks, I added opencv_contrib and it is still compiling.

-DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>

I was curious why add opencv_contrib because I also saw features2d in opencv-4.1.0\module.
1

@AmbatiHemasree
Copy link

AmbatiHemasree commented Jul 18, 2019

Hi, The same issue has occurred to me. But i dont the xfeaures2d module as my application is not on that. How could i disable this? Please suggest me with a solution

Thanks and regards!

@yihe2018
Copy link

@AmbatiHemasree -DBUILD_opencv_xfeatures2d=OFF
in cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/home/heyi/Myir/Tools/opencv-3.4.1 -D OPENCV_EXTRA_MODULES_PATH=/home/heyi/Myir/Tools/opencv_contrib-3.4.1/modules/ -DBUILD_opencv_xfeatures2d=OFF -D CMAKE_TOOLCHAIN_FILE=arm-linux-gnueabihf.cmake ..

@Shivani1796
Copy link

opencv2/xfeatures2d.hpp: No such file or directory.

Can anyone help solve this issue.

opencv2

@Nuri-benbarka
Copy link

The xfeatures2d.hpp file is in the OpenCV contrib repository, so I guess you need to install the OpenCV library with the modules in the OpenCV contrib repository. Check this link for installation guidance:
https://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html

@jaytxrx
Copy link

jaytxrx commented Dec 27, 2020

You need to download the opencv_contrib package and reinstall opencv
Below steps were tried on Ubuntu 20.04

Note: if you already have OpenCV installed, then do from step 2. In step 3, your build directory might already have files, you can delete them

  1. If you have not installed OpenCV, follow the below steps
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.1.0
cd .. #get out of opencv folder
  1. now get opencv_contrib
https://github.com/opencv/opencv_contrib/
cd opencv_contrib
git checkout 4.1.0
cd .. #get out of opencv_contrib folder
  1. lets create a build directory inside opencv folder and install opencv where we will refer opencv_contrib
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D WITH_GTK=ON ..
make
sudo make install

@pkeir
Copy link

pkeir commented Mar 23, 2021

On Ubuntu 20.10 the libopencv-features2d-dev package includes features/features2d.hpp, but not xfeatures2d.hpp (as reported by dpkg -L libopencv-features2d-dev). libopencv-contrib-dev also doesn't have it. I don't know what the 'x' signifies.

@SudKul SudKul added the good first issue Good for newcomers label Mar 24, 2021
@SudKul
Copy link
Contributor

SudKul commented Mar 24, 2021

Intentionally keeping this thread open to help new students.

Though we encourage such user-specific issues to be raised on the Knowledge hub so that our experienced mentors can chime-in and new students can also learn from the discussion thread.

Thanks, @jeffreyantony, and @Nuri-benbarka for pointing out the missing step

@SudKul SudKul mentioned this issue Mar 25, 2021
@abhiojha8 abhiojha8 pinned this issue Feb 24, 2022
@ok-kewei
Copy link

ok-kewei commented Sep 9, 2022

You need to download the opencv_contrib package and reinstall opencv Below steps were tried on Ubuntu 20.04

Note: if you already have OpenCV installed, then do from step 2. In step 3, your build directory might already have files, you can delete them

  1. If you have not installed OpenCV, follow the below steps
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.1.0
cd .. #get out of opencv folder
  1. now get opencv_contrib
https://github.com/opencv/opencv_contrib/
cd opencv_contrib
git checkout 4.1.0
cd .. #get out of opencv_contrib folder
  1. lets create a build directory inside opencv folder and install opencv where we will refer opencv_contrib
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D WITH_GTK=ON ..
make
sudo make install

Thanks for sharing. It works for me at Ubuntu 18.04 <3
My experience told the opencv and opencv_contrib both have to be in the same version.
Reference: https://answers.opencv.org/question/221263/make-error-about-opencv_contrib-348/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests