[英]Installation of OpenCV in Ubuntu 14.04
I built OpenCV from Source but I can't manage to use it. 我从Source构建了OpenCV,但我无法使用它。 Every time I try to even load an image with the next code I get No module named cv2.cv
. 每当我尝试使用下一个代码加载图像时,我得到的是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 我从GitHub的主页面下载了zip文件,在我创建的目标目录中,我使用了OpenCV
cmake OpenCV_Source_Directory
Then on the destination directory I run 然后在我运行的目标目录上
make
sudo make install
I found the solution to my problem. 我找到了解决问题的方法。 I had to install python-opencv
as follows: 我必须安装python-opencv
如下:
sudo apt-get install python-opencv
After that OpenCV works fine. 之后OpenCV工作正常。
You've likely installed opencv 3, which doesn't have the cv2.cv
module. 你可能已经安装了opencv 3,它没有cv2.cv
模块。 It's all in cv2
now. 它现在都在cv2
。
To verify run this in a python interpreter 验证在python解释器中运行它
import cv2
print cv2.__version__
Anything like 3.0.0
or 3.1.0
means that the cv2.cv
module doesn't exist. 像3.0.0
或3.1.0
这样的cv2.cv
意味着cv2.cv
模块不存在。
Presumable you did: 推测你做了:
git clone git@github.com: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. 也就是说,默认分支是OpenCV 3,它没有cv2.cv模块。 Either change your code to work with the OpenCV 3 cv2 module. 更改代码以使用OpenCV 3 cv2模块。 Or downgrade to OpenCV2. 或者降级到OpenCV2。 You can do this by: 你可以这样做:
cd opencv
git checkout 2.4.13.1
cd ../build && so on ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.