python - 尝试使用 cv2.imshow 时出错

标签 python image opencv computer-vision

当我像这样使用 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/

相关文章:

python - 将 py2neo v3 与谷歌应用引擎一起使用

python - 如何顺序聚合dask Bag的内容?

python - 具有相似模式的多个 if 语句

javascript - 将鼠标悬停在图像区域上以更改图像 src

opencv - 如何对垫子进行 bool 运算,例如 mat3 = mat1 和 mat2?

OpenCV 显示彩色 Cb Cr channel

python - 无法将 InMemoryUploadedFile 保存到 Django 中的模型

ruby-on-rails-3 - 导轨 3 : Why does my image_tag automatically add inline style attributes to the HTML making it invisible?

css - 如何在 div 中(在 WordPress 上)使缩略图的宽度为 100%,而不是更大?

c++ - 使用 OpenCV 和 C 裁剪图像