I am trying to run a program that uses OpenCV and I have gotten it to run on other machines, and other programs on my machine run using it, but this one returns:
programname.cpp: fatal error: opencv/cv.h: No such file or directory
Anyone know how to fix the path or what might be going wrong? I am running Ubuntu 12.04 and OpenCV-2.4.0
Not having the opencv-python package installed by running pip install opencv-python . Installing the package in a different Python version than the one you're using. Installing the package globally and not in your virtual environment. Your IDE running an incorrect version of Python.
cv2 (old interface in old OpenCV versions was named as cv ) is the name that OpenCV developers chose when they created the binding generators. This is kept as the import name to be consistent with different kind of tutorials around the internet.
The file cv2.so is stored in /usr/local/lib/python2. 7/site-packages/... There are also folders in /usr/local/lib called python3.
cv2 is the module import name for opencv-python, "Unofficial pre-built CPU-only OpenCV packages for Python". The traditional OpenCV has many complicated steps involving building the module from scratch, which is unnecessary. I would recommend remaining with the opencv-python library.
Change from:
#include <opencv/cv.h>
to:
#include <opencv2/opencv.hpp>
On my Ubuntu 11.04, the headers are in: */usr/include/opencv-2.3.1/*
, I assume it should be */usr/include/opencv-2.4.0/*
for you.
You have two solutions:
-I
option: g++ -o [name] [src] -I/usr/include/opencv-2.4.0
The second solution is useful if you're using CMake, because FindOpenCV2 does not look for OpenCV in /usr/include/opencv-2.4.0
. I hope this (ugly) hack will solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With