【问题标题】:openCV: The function is not implementedopenCV:该功能未实现
【发布时间】:2017-09-30 02:08:16
【问题描述】:

尝试运行 python 脚本并抛出以下错误:

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 cvDestroyAllWindows, file /io/opencv/modules/highgui
 /src/window.cpp, line 577
Traceback (most recent call last):
  File "/home/ldsvm/PycharmProjects/tagging/C1_DrawBboxesOnImages.py", line 
  116, in <module> cv2.destroyAllWindows()
cv2.error: /io/opencv/modules/highgui/src/window.cpp:577: 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  
 cvDestroyAllWindows

我已经安装了libgtk2.0-devpkg-config 并重新安装了opencv3,但仍然出现同样的错误。

我在 CentOS 上。

【问题讨论】:

  • 一个快速(可能不安全)的解决方法是从您的代码中删除 destroyAllWindows。无论如何,当您的主退出时,所有opencv 窗口都将关闭。

标签: python opencv centos


【解决方案1】:

最简单的方法是删除opencv包更新你的conda,然后使用第三个命令找到丢失的包。

conda remove opencv
conda update conda
conda install --channel menpo opencv

另一个选项是使用 ma​​tplotlib 来代替使用 opencv 内置函数....

import cv2
import matplotlib.pyplot as plt

img = cv2.imread('img.jpg',0)

plt.imshow(img, cmap='gray')
plt.show()

【讨论】:

  • MacOS 和 Linux 轮子目前有一些限制:不支持视频相关功能(不使用 FFmpeg 编译)例如 cv2.imshow() 将不起作用(不使用 GTK+ 2.x 或 Carbon 支持编译)
猜你喜欢
  • 1970-01-01
  • 2013-01-17
  • 2020-12-01
  • 2018-11-19
  • 1970-01-01
  • 2015-08-17
  • 1970-01-01
  • 1970-01-01
  • 2015-04-30
相关资源
最近更新 更多