当我像这样使用 cv2.imshow
时:
import numpy as np
import cv2
img = cv2.imread('galaxy.jpg',0)
cv2.imshow('image',img)
我收到以下错误:
OpenCV Error: Unspecified error (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 cvShowImage, file -------src-dir-------/opencv-2.4.10/modules/highgui/src/window.cpp, line 501
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: -------src-dir-------/opencv-2.4.10/modules/highgui/src/window.cpp:501: 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
附言刚刚编辑了编程部分代码。感谢 stackoverflow 的反馈
最佳答案
我猜您使用 Cmake 自己构建了 OpenCV 库?然后你忘了打开一些必要的标志(显然是 GTK 支持)。您将必须在启用正确的编译器标志的情况下重建库。为了帮助您做到这一点,OpenCV 官方网站上有一个 python 的“入门”页面。
关于python - 尝试使用 cv2.imshow 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30966744/