cv2.imshow()在Mac上崩溃 [英] cv2.imshow() crashes on Mac
问题描述
当我在ipython (MacOS /python 2.7.13)
cv2.startWindowThread()
cv2.imshow('img', img)
cv2.waitKey()
cv2.destroyAllWindows()
内核崩溃.当图像出现时,我唯一可以按下的按钮是minimise
(中间的那个,当我按下任意键时,纺车将显示出来,而我唯一可以做的就是强制退出.
the kernel crashes. When the image appears, the only button that I can press is minimise
(the one in the middle and when I press any key then the spinning wheel shows up and the only thing I can do is force quit.
P.S.我已经通过home-brew
下载了最新的python版本.
P.S. I have downloaded the latest python version through home-brew
.
推荐答案
您是否只想查看图像?我不确定您要使用startWindowThread做什么,但是如果您想以最简单的方式安装opencv,请打开图像,然后查看该图像:
Do you just want to look at the image? I'm not sure what you want to do with startWindowThread, but if you want to install opencv the easiest way, open the image, and view it try this:
安装 conda (与自制软件相比,opencv的软件包管理器更好)
install conda (A better package manager for opencv than homebrew)
然后创建一个简历环境:
then create a cv environment:
conda create -n cv
激活它并从menpo的频道安装opencv
activate it and install opencv from menpo's channel
source activate cv
conda install -c menpo opencv
然后在python中(按q
退出):
then in python (hit q
to exit):
import cv2
cv2.namedWindow('imageWindow')
img = cv2.imread('path/to/your/image.png')
cv2.imshow('imageWindow',img)
wait = True
while wait:
wait = cv2.waitKey()=='q113' # hit q to exit
这篇关于cv2.imshow()在Mac上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!