Reputation: 485
I built OpenCV from Source but I can't manage to use it. Every time I try to even load an image with the next code I get No module named cv2.cv
. Why is that happening? How can I fix it?
from cv2.cv import *
img = LoadImage("/home/User/Desktop/Image.png")
NamedWindow("opencv")
ShowImage("opencv",img)
WaitKey(0)
The procedure I did was the following...
I downloaded the zip file from the main page of GitHub and while being in a destination directory I created, I built OpenCV using
cmake OpenCV_Source_Directory
Then on the destination directory I run
make
sudo make install
Upvotes: 3
Views: 2871
Reputation: 485
I found the solution to my problem. I had to install python-opencv
as follows:
sudo apt-get install python-opencv
After that OpenCV works fine.
Upvotes: 3
Reputation: 11951
Presumable you did:
git clone [email protected]:opencv/opencv.git
mkdir build; cd build
cmake ../opencv && make && sudo make install
But if you do this:
cd opencv
git describe
You will get something like
3.1.0-1374-g7f14a27
That is, the default branch is OpenCV 3, which doesn't have the cv2.cv module. Either change your code to work with the OpenCV 3 cv2 module. Or downgrade to OpenCV2. You can do this by:
cd opencv
git checkout 2.4.13.1
cd ../build && so on ...
Upvotes: 0
Reputation: 507
You've likely installed opencv 3, which doesn't have the cv2.cv
module. It's all in cv2
now.
To verify run this in a python interpreter
import cv2
print cv2.__version__
Anything like 3.0.0
or 3.1.0
means that the cv2.cv
module doesn't exist.
Upvotes: 1