I did not download and unzip OpenCV manually. Instead I relied on apt-get to install OpenCV.
The only place I can find are header files in /usr/include/opencv2
No link to OpenCV GitHub link please. It would be a pain later if it turns out that the code I am using on my PC is different from the one in GitHub.
I have looked at this post but I am not sure where OPENCV_HOME is.
If you do a pkg-config:
pkg-config --cflags opencv
You will find the include files, header files like you give above. I think you are referring to cpp files. Since you downloaded with apt-get you dont have cpp files on your disk. You are going to face the github reality in this case. Just get the same version source code from github. But I dont think of any usage of source code besides compiling. If you want to search the source of a function just use the github web interface, it is easier and a lot helpful
Related
Having loads of problems trying to make my own Haar Cascade Classifier using Opencv. I have followed this tutorial (https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/) and with initial success I have been unable to replicate my results. I have turned to the Opencv Documentation and it has suggested using CMAKE but I keep getting the following error;
Im sure its something simple but i cant see it. I would appreciate any help, thank you.
Simple answer is build a temporary folder in the OPENCV directory. Go into the new directory. Then type;
cmake /root/opencv/
In the new folder and type
make
then;
sudo make install
I am new to Ubuntu and OpenCV. Apologies for my amateurishness.
I think I messed up OpenCV installation.
I had installed OpenCV 2.4 months back. The installation was successful (built openCV from source using CMake)
Couple of days back I had also installed OpenCV 3.0 using the same procedure.
The problem began when one of my code gave a segmentation fault for seemingly no reason. On suggestion by a friend on Caffe Neural Network issues forum (https://github.com/BVLC/caffe/issues/3416), it seems that I am compiling with 3.0 headers but linking against the 2.4 libraries.
I checked /usr/local/include. It has the standard openCv header files ( I didn't understand what 'compiling with 3.0 header means' )
In /usr/local/lib I have OpenCV 3.0 libraries ( no 2.4.8 at all).
Now compilation was successful, but when I try to run it, I get the following error.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff76c49bc in cv::merge(cv::_InputArray const&,
cv::_OutputArray const&) ()
from /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4
Just to add
"pkg-config --modversion opencv"
3.0.0
whereas dpkg -l | grep libopencv
gave out
i libopencv-calib3d-dev:amd64 2.4.8+dfsg1-2ubuntu1 amd64 development files for libopencv-calib3d
ii libopencv-calib3d2.4:amd64 2.4.8+dfsg1-2ubuntu1 amd64 computer vision Camera Calibration library
ii libopencv-contrib-dev:amd64 2.4.8+dfsg1-2ubuntu1 amd64 development files for libopencv-contrib
.......
q.1> why does my code link to libopencv_core.so.2.4 instead of 3.0. I have checked in /usr/local/lib and did not see a single 2.4 library. I have tried manually defining links to header files and libraries in CMake but still same result.
q.2> Do OpenCV headers have a version number? I don't understand how they are called '2.4 headers'. I have checked the source code but did not see any specific requirement for a version of library. Then what dictates to link to 2.4 version libraries?
Sorry if this is theoretical but this would be highly beneficial to beginners like me. Please do comment for a suitable question title if the current one is not appropriate.
Thanks
Your opencv2.4 libraries are located in /usr/lib/x86_64-linux-gnu/ while the new opencv3 libraries are most likely located in /usr/local/lib. The linker is first looking in the /usr/lib/x86_64-linux-gnu/ directory, and thus finding the opencv2.4 libs first. To fix this you can tell the linker to look in /usr/local/lib first by adding the following to your ~/.bashrc file
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Reload the bashrc file in the terminal as follows (or simply close and re-open the terminal):
source ~/.bashrc
And update the library database:
sudo ldconfig
To check the order in which the linker will search for libraries, you can use the following:
ld -lopencv_core --verbose | grep attempt
When I compile a simple program : hello_world.cpp
**I get the error-
**fatal error: cv.h: No such file or directory
compilation terminated.****
Solutions I found but didn't work:
I checked for cv.h and highgui.h if they are there, and got these results:
/home/snu/OpenCV-2.4.0/include/opencv/highgui.h
/usr/lib/perl/5.14.2/CORE/cv.h
/home/snu/OpenCV-2.4.0/include/opencv/cv.h
I checked if opencv is correctly installed by using
pkg-config opencv --libs, this is what i got :
-lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -lopencv_core -lopencv_ml -lopencv_features2d -lopencv_objdetect -lopencv_flann -lopencv_video -lopencv_highgui
I made some changes in the header files of hello_world.cpp as-
#include "opencv2/highgui/highgui.hpp"
Welcome to Stack Overflow, the land of the non-answer.
"You are not doing it right, is the problem"
"Do this", with no explanation. Doesn't work.
The cmake answer is ok, but I don't really want to use cmake for the sole purpose of making a single library import.
--- end of roast, my answer:
As per https://answers.opencv.org/question/225224/opencvcvh-not-found/
OpenCV 4 discontinued the C-API in favor of the C++ one, apparently.
So you should install the latest version of OpenCV 3. This can be done using platform specific installer listed below:
https://sourceforge.net/projects/opencvlibrary/files/3.4.10/
For Linux specifically, you want this file from the ones in the link above.
Download and extract it.
Then based on these instructions to install it,
Make a directory, I called my opencv-install and put the extracted folder in it.
opencv-install/opencv-opencv-25a1900
cd opencv-install
rm opencv-opencv-25a1900/CMakeCache.txtls
cmake opencv-opencv-25a1900
make
sudo make install # global install
Then change your import to #include "opencv/cv.h"
Well how about that, you still needed cmake, but at least you don't have to make your project a "cmake project". In fact, if someone else with the same operating system has already done up to step 5, you can simply use their build !
For Linux beginners (requires Debian-base, cmake not needed)
As a little courtesy, and to put my "money" where my "mouth" is, I will provide to you my own build. Understand that using someone else's build assumes a bit more trust than compiling it yourself. I know when I first start with C/Linux compiling OS projects can be kind of daunting so.... here you go! It is for For Debian GNU/Linux 11 (bullseye) x86_64. I think this means it works on Ubuntu, and maybe other OSes that use apt. If you try it and it doesn't work, you should try a different build or make one yourself by starting at step one above.
You are probably not compiling correctly. Add the opencv-include folder in the compiler settings.
Use CMake to link libraries and include directories. It makes your life easier and also for anyone else who will be extending/reading your code in the future. You will not need to add folders specifically into projects as CMake will do that for you automatically.
For example, to link OpenCV, use the follow lines of code:
FIND_PACKAGE( OpenCV REQUIRED )
TARGET_LINK_LIBRARIES( myProject ${OpenCV_LIBS} )
please use the code below for such errors:
#include <opencv/cv.h>
in the place of
#include <cv.h>
I want to build vlc for iOS.
My environment is MacOS 10.8.3, Xcode4.6.2 with iOS6.1 SDK.
I cloned the vlc lib form https://github.com/videolan/vlc.git, cd into the /extras/package/ios, and run the build.sh in terminal, everything goes okay except when I start making the chromaprint, I got this error:
FFTW3 lib not found. Set FFTW3_DIR to find it.
CMake Error at CMakeLists.txt:114 (message):
Neither FFmpeg with avfft.h nor FFTW3 found
This is because chromaprint needs the fft library, it will find FFMPEG and also FFTW3.
I want to use the FFMPEG for an fft calculation, so I have download a copy of ffmpeg source code and complied it,the libs and headers are in the directories: /Users/king/ffmpeg/complied/include and /Users/king/ffmpeg/complied/lib,
then I set the FFMPEG_ROOT as /Users/king/ffmpeg/complied in the cmake/modules/FindFFmpeg.cmake, just before the FIND_PATH() function.
something like : set(${FFMPEG_ROOT} /Users/king/ffmpeg/complied)
,I hope the FIND_PATH() can find the releated libs and headers, this doesn't work.
So my question is, How do i set the FFMPEG path or FFTW3_DIR for chromaprint?
Thanks in advance, I am really run out of my head!
I have same problem on VLC Windows cross build.
After I upgrade cmake to 3.22.0, this problem is fixed.
I download latest cmake source code and build.
I also download fftw3 package and extracted under /home/[username]/fftw3.
Set FFTW3_DIR to ~/fftw3 by
export FFTW3_DIR=/home/[username]/fftw3
I am working on a harr detecttion project. I want to generate the exe files using the .cpp files that come with Opencv. I am using CMake for it. When I try to do that I am getting an error like this. Don`t know how to solve it.
CMake Error at CMakeLists.txt:7 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
Configuring incomplete, errors occurred!
Source link: C:/opencv/apps/haartraining
Destination link: D:/build
Please help me.
I was working on some image processing that involves Haar detection. And i was having a hard time trying to configure with Cmake at first but i finally found manual configuration tutorial with out using Cmake or else. It has helped me a lot and you can get it here. I hope it will work perfect as it worked for me too. Click here -> http://www.anlak.com/using-opencv-2-3-1-with-visual-studio-2010-tutorial/. The tutorial uses open CV 2.3.1 but it will work perfect for recent versions too with the need for Cmake ore else.If you more questions, hit me up and i will explain.Good luck!
It looks like You need to compile the whole library with build examples option enabled (if You are using windows then I bet You use graphic cmake interface, so it shouldn't be a problem), and then You will find the .exe in bin directory,
or You would need to include OpenCVModule.cmake file found in cmake catalogue to CMake file You are trying to use for the build.
I didn't test the second option myself, but it looks like CMake file You are trying to use does not load all macros needed for it to run, but macros are loaded when the root library CMake file is used.