我是OpenCV的新手,遇到了cv2.imshow的问题。这是我的代码:
import numpy as np
import cv2
print("Version is", cv2.__version__)
print("Build info", cv2.getBuildInformation())
img = cv2.imread('../coelacanth.jpeg', cv2.IMREAD_COLOR)
if img is None:
print("no image")
else:
print("there is an image")
cv2.line(img, (0,0), (150, 150), (255, 255, 255), 15)
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
我收到此错误:
line 16, in <module>
cv2.imshow('image', img)
line 16, in <module>
cv2.imshow('image', img)
cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:583: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
对cv2.line
的调用似乎有效。如果在没有cv2.waitKey(0)
的情况下尝试imshow
,我会收到同样的错误。
我用
安装了OpenCV3brew install --with-examples --with-contrib --with-python3 --with-qt --without-python -v opencv3
所以,显然我需要
Rebuild the library with Windows, GTK+ 2.x or Carbon support
但我不知道该怎么做,也无法通过搜索其他问题来解决这个问题。有没有人有什么建议?
答案 0 :(得分:1)
这是一个路径问题。在.bash_profile
中,我们注释掉了
#PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
#export PATH
然后使用brew uninstall opencv3
卸载并使用原始问题中给出的brew命令重新安装。