How to add all extra modules of OpenCV-contrib to OpenCV library? - opencv

I have built OpenCV with extra modules based on these instractions by providing the path:
C:/opencv/opencv-4.2.0/opencv_contrib-4.2.0/modules
in OPENCV_EXTRA_MODULES_PATH in CMake GUI.
However, when I want to use MultiTracker based on this page I face this error:
Cannot open include file: 'samples_utility.hpp': No such file or directory
This error comes from this line:
#include "samples_utility.hpp"
I know samples_utility.hpp is a file in opencv_contrib-4.2.0\modules\tracking, but why is it not found in the built libraries? Do I have to add it from CMake or should I build OpenCV from scratch?

Related

OpenCV is preinstalled in google colab but I am unable to add extra modules from opencv contrib. Still getting the same- No such file or directory

I want to add opencv2/cudaimgproc.hpp module from contrib. I followed the instructions in https://github.com/opencv/opencv_contrib to build opencv contrib. I also cloned opencv master because the instructions said so even though I have opencv 4 installed in Google colab. I still get the same error-
fatal error: opencv2/cudaimgproc.hpp: No such file or directory #include
when I run the cpp code with #include . Please help.

MinGW doesn't recognize the directory opencv

I write a code using opencv library, I used codeblocks ide configuring it to work with opencv (configuring linker settings and search directory and including all the necesary path to enviroment variable) correctly and then the program works fine. The problem is when I try to compile using minGW with g++ 6.3.0 version, it gave me the next error:
ImgSeg.cpp:2:39: fatal error: opencv2/imgproc/imgproc.hpp: No such file or
directory
#include <opencv2/imgproc/imgproc.hpp>
^
compilation terminated.
I try all possible form to put the opencv2 directory in enviroment variable but it has the same error all the time, it's a little frustrating. this is what I have on path in enviroment variable:
C:\opencv_install\lib;
C:\opencv_install\include;
C:\opencv_install\bin;
I'm using windows 7 64 and opencv 2.4.9
GCC does not search PATH when looking for include files.
You will need to tell it where to look by using the -I commandline parameter:
-IC:\opencv_install\include
When linking, you'll also need to tell GCC where to find the libraries you're linking:
-LC:\opencv_install\lib -lopencv_core
In CodeBlocks you'll need to add the former to include directories (not PATH) in the project settings.
Finally I could compile the program but I had to install mingw64 version 4.9.2 from this link. The command that I use to compile was this:
g++ -std=c++11 "name of the program.cpp" -IC:/opencv_install/include -LC:/opencv_install/lib -llibopencv_core249 -llibopencv_highgui249 -llibopencv_imgproc249 -o "name of the exe"
It's important include the -l lib that you used in the program

I have installed correctly opencv_contrib but qt creator doesn't find xfeatures2d directory

I am using OpenCV with C++ on Ubuntu 16.01 I have to use SURF.
I have already installed opencv_contrib correctly (i followed this link) but when i try to write the path:
#include "xfeatures2d/xfeatures2d.hpp
in my .hpp program I found this error:
#include "xfeatures2d/xfeatures2d.hpp : No such file or directory
Also i tried to put all the directory but it doesn't work either.
I'm not an expert in opencv so i don't know if I have to change any CmakeList or something.
has anybody any ideas?
Try to include path:
INCLUDEPATH += "C://opencv_contrib-3.2.0/modules/xfeatures2d/include"
in your .pro file.

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

I am trying to build this code:
https://docs.opencv.org/3.2.0/d5/d6f/tutorial_feature_flann_matcher.html
I am using Ubuntu 16.04 with CLion 2017.3 and have OpenCV 3.4 installed.
xfeatures2d.hpp can't be found on the system.
I have looked at many different problems on the internet, but couldn't find a solution.
Any help?
You have to include cmake comiplation flag to opencv OPENCV_EXTRA_MODULES_PATH and set it to the opencv_contrib/modules.
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules
Here's what I had to do to compile OpenCV with xfeatures2d:
Download opencv_contrib (I took a release from the releases page). This step is what gives us xfeatures2d.
Unpack the tarball somewhere, e.g., ~/src/opencv_contrib-4.5.5
When configuring OpenCV (the main OpenCV source like opencv-4.5.2) with CMake, add the following option to cmake command line (adjusting the value to be your actual path to the modules subdirectory of the opencv_contrib tarball):
-DOPENCV_EXTRA_MODULES_PATH=$HOME/src/opencv_contrib-4.5.5/modules/
Now just build as you normally would and install.
The above actions gave me the expected file (among others): /usr/include/opencv4/opencv2/xfeatures2d.hpp.

How to add header directory to C++ using CMakeLists.txt?

I have configured OpenNI+PCL+OpenCV with CMakeLists.txt. I didn't write it myself. Just copied fragments of PCL documentation, OpenCV manual and some code I found to integrate OpenNI into one project. I'm able to build it and successfully find all includes & libs. The problem comes when OpenNI samples use GL/glut.h or GLES, or opengles.h . I can't understand how to add that includes to my project with cmake.
My commands to build:
>projectDir/build/cmake ..
>projectDir/build/make
>projectDir/build/./project
projectDir has GLES/ GL/
CMakeLists.txt which will help many beginner people with OpenNI+PCL+OpenCV.

Resources