[英]Trying to use opencv with python on mac os x 10.6
I'm new to python and I'm trying to use the openCV libraries. 我是python的新手,正在尝试使用openCV库。 After lots of reading and lots of trial and error I decided to ask here.
经过大量阅读和反复试验后,我决定在这里询问。
I installed the openCV with macports, still I keep getting the same error (as I did when installing using the setup.py file inside openCV pkg). 我安装了OpenCV的与MacPorts的,我还是继续得到同样的错误(我使用OpenCV的PKG里面的setup.py文件安装时所做的那样)。 My script is a "Hello world" script I wrote (copied) from http://www.neuroforge.co.uk/index.php/getting-started-with-python-a-opencv and the "import cv" is not working.
我的脚本是我从http://www.neuroforge.co.uk/index.php/getting-started-with-python-a-opencv编写(复制)的“ Hello world”脚本,而“ import cv”不是工作。 Is that because of path?
那是因为道路吗? I tried adding:
我尝试添加:
import sys
sys.path.append('/opt/local/include/opencv')
but no change... 但没有变化...
Thanks, Yonathan 谢谢,Yonathan
the full script is: 完整的脚本是:
import cv
cv.NamedWindow('a_window', cv.CV_WINDOW_AUTOSIZE)
image = cv.LoadImage('picture.png', cv.LOAD_IMAGE_COLOR)
font = cv.InitFont(cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0, 3, 8)
x = 200
y = 200
cv.PutText(frame,"Hello World!!!", (x,y),font, 255)
cv.ShowImage('a_window', image)
cv.Waitkey(10000)
cv.SaveImage('image.png', image)
I also had trouble getting the Python OpenCV bindings to work with a MacPorts OpenCV installation. 我也很难使Python OpenCV绑定与MacPorts OpenCV安装一起使用。
But, I got OpenCV installed on a mac using Homebrew, and I can import cv
and import cv2
in Python. 但是,我使用Homebrew在Mac上安装了OpenCV,并且可以在Python中
import cv
和import cv2
。
I installed Homebrew , then did brew install opencv
, and then everything worked properly. 我安装了Homebrew ,然后
brew install opencv
,然后一切正常。
If installing via MacPorts make sure that you add the python variant when you install. 如果通过MacPorts安装,请确保在安装时添加python变体。
sudo port install opencv +python27
Then make sure that you are running the MacPorts version of python (usually /opt/local/bin/python2.7), not the default OSX version. 然后确保您运行的是MacPorts版本的python(通常是/opt/local/bin/python2.7),而不是默认的OSX版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.