安装了带有自制软件(brew install opencv
)的opencv,并运行了一些OpenCV示例脚本,这些脚本是其库的一部分。
脚本似乎毫无怨言地运行,但键盘输入似乎没有响应。字母键只是将键入的字母放入终端窗口,esc 产生 ^[
.
一些看似任意的谷歌结果暗示这个问题可能是因为 python 没有作为系统框架运行,但我尝试通过 python
和 python2.7
运行脚本,结果相同,这些可执行文件概述如下:
-rwxr-xr-x 1 root wheel 58608 Oct 28 09:34 python
-rwxr-xr-x 1 root wheel 925 Mar 10 2014 python-config
-rwxr-xr-x 1 root wheel 925 Oct 23 14:48 python-config-backup
lrwxr-xr-x 1 root wheel 75 Oct 28 09:34 python2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
lrwxr-xr-x 1 root wheel 82 Oct 28 09:34 python2.5-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
lrwxr-xr-x 1 root wheel 75 Oct 28 09:34 python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82 Oct 28 09:34 python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
lrwxr-xr-x 1 root wheel 75 Oct 28 09:34 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 82 Oct 28 09:34 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
-rwxr-xr-x 1 root wheel 58608 Oct 28 09:34 pythonw
lrwxr-xr-x 1 root wheel 76 Oct 28 09:34 pythonw2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5
lrwxr-xr-x 1 root wheel 76 Oct 28 09:34 pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
lrwxr-xr-x 1 root wheel 76 Oct 28 09:34 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
我实际上不记得直接驻留在/usr/bin/python
中的python可执行文件是如何到达那里的(在尝试配置psql/python/psycopg2失败时尝试了很多安装(fink,python gui,自制软件)和配置)。
这个问题可能与需要向(空)PYTHONPATH添加一些东西有关吗?是所谓的绑定homebrew
安装在ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py
,是否需要链接、复制或移动到我已安装的 python 版本之一?
在cd /Library/Python/2.7/site-packages/
内,我添加了两个符号链接:
lrwxr-xr-x 1 root wheel 64 Dec 24 19:21 cv.py -> /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py
lrwxr-xr-x 1 root wheel 65 Dec 24 19:21 cv2.so -> /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so
我不喜欢必须用homebrew
安装python的想法,但对此持开放态度。
啊。如此简单(当然)。OpenCV window
和buttons
(分配给waitKey
)是相互依赖的,因此waitKey
仅在 OpenCV 窗口具有焦点时才捕获输入。
感谢PACKT出版的OpenCV Computer Vision with Python一书提供了线索。当然,R
TFM
也可能非常方便地做到这一点。