OSX终端上交互式CV2 Python会话中的无响应键

时间:2014-12-25 04:17:49

标签: python macos opencv homebrew

使用自制软件(brew install opencv)安装opencv并运行一些OpenCV示例脚本作为library的一部分。

脚本似乎没有抱怨,但键盘输入似乎没有响应。字母键只是将字母输入终端窗口,esc产生^[

有些arbitrary-seeming google results暗示此问题可能因为python没有作为系统框架运行,但我尝试通过python和{{1}运行脚本具有相同结果的那些可执行文件概述如下:

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 内的python可执行文件是如何到达那里的(尝试配置psql / python /时尝试了很多安装(fink,python gui,homebrew)和配置psycopg2)。

这个问题可能与需要向(空)PYTHONPATH添加内容有关吗?它是/usr/bin/python安装在homebrew的所谓的绑定,是否需要链接,复制或移动到我安装的某个python版本?

ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py内,我添加了两个符号链接:

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 安装python的想法,但我愿意接受它。

1 个答案:

答案 0 :(得分:0)

阿。如此简单(当然)。 OpenCV windowbuttons(分配给waitKey)是相互依赖的,因此waitKey仅在OpenCV窗口具有焦点时捕获输入。

感谢PACKT发布 OpenCV计算机视觉与Python 一书的线索。当然,R TFM {{1}}也许可以很方便地完成这个技巧。