openCV:该功能未实现

sal*_*hin 5 python opencv centos

尝试运行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
Run Code Online (Sandbox Code Playgroud)

我已经安装了libgtk2.0-dev和,pkg-config然后重新安装,opencv3但仍然收到相同的错误。

我在CentOS上。

小智 1

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

conda remove opencv
conda update conda
conda install --channel menpo opencv
Run Code Online (Sandbox Code Playgroud)

另一种选择是不使用 opencv 内置函数,而是使用matplotlib来实现这一点......

import cv2
import matplotlib.pyplot as plt

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

plt.imshow(img, cmap='gray')
plt.show()
Run Code Online (Sandbox Code Playgroud)