【发布时间】:2016-12-27 17:58:05
【问题描述】:
我正在关注this tutorial 进行角点检测,我必须使用 cv2.imshow。这是我的代码:
import cv2
import numpy as np
filename = '1.jpg'
img = cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv2.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255]
cv2.imshow('dst',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 /root/mc-x86-2.7/conda-bld/opencv-3_1482254836916/work/opencv-3.1.0/modules/highgui/src/window.cpp, line 545
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: /root/mc-x86-2.7/conda-bld/opencv-3_1482254836916/work/opencv-3.1.0/modules/highgui/src/window.cpp:545: 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
所以,我安装了 libgtk2.0-dev 和 pkg-config,但并没有解决问题。错误消息说要运行 cmake 但在哪里?我的驱动器中没有 CMakeLists.txt 文件。
然后,我在这个网站上关注了一些答案,比如this one:首先,我直接在网站上下载了 OpenCV,然后运行 cmake、make 和 make install。一切都很好,但是当我使用 Anaconda 时我仍然有同样的错误,但是当我从 /usr/bin/python 打开 Python 时它得到了另一条消息:
init done
opengl support available
目前,我无法显示我的图像。我该怎么办?
【问题讨论】:
-
您可以使用以下命令安装 opencv: conda install -c conda.binstar.org/menpo opencv。它不需要建造。
-
我已经做到了。它不起作用;我得到同样的错误。
-
您在运行 CMake 时是否启用了 GTK?默认情况下它可能被禁用。
-
您可能会发现这有助于在从源设置时设置 conda:stackoverflow.com/a/30281466/3051961