問題描述
這是我得到的確切錯誤.我的操作系統是 Ubuntu 16.10.
This is the exact error that I am getting. My OS is Ubuntu 16.10.
OpenCV 錯誤:未指定錯誤(該功能未實現.使用 Windows、GTK+ 2.x 或 Carbon 支持重建庫.如果您在 Ubuntu 或 Debian 上,請安裝 libgtk2.0-dev 和 pkg-config,然后重新運行 cmake 或配置腳本)在 cvShowImage,文件/feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp,第 545 行回溯(最近一次通話最后):文件untitled.py",第 7 行,在cv2.imshow('圖片',img)cv2.error:/feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp:545: error: (-2) 功能沒有實現.使用 Windows、GTK+ 2.x 或 Carbon 支持重建庫.如果你在 Ubuntu 或 Debian 上,安裝 libgtk2.0-dev 和 pkg-config,然后重新運行 cmake 或在函數 cvShowImage 中配置腳本
我的代碼是:
import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('0002.png',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
0002.png 是與程序位于同一目錄中的圖像.我首先用python 3.5安裝了anaconda,然后我使用命令安裝了opencv
0002.png is an image in the same directory as the program. I first installed anaconda with python 3.5, then I installed opencv by using the command
conda install -c conda-forge opencv
我安裝了 libgtk2.0-dev,就像錯誤所說的那樣,但我仍然得到同樣的錯誤.任何幫助將非常感激.我已經嘗試解決這個問題幾個小時了.
I installed libgtk2.0-dev just as the error said to but I still get the same error. Any help would be much appreciated. I've been trying to solve this for several hours.
推薦答案
1.最簡單的方法:
conda remove opencv
conda update conda
conda install --channel menpo opencv
或(對于 OpenCV 3.1):
or (for OpenCV 3.1) :
conda install -c menpo opencv3
2.如果你不想這樣做,你可以嘗試使用ma??tplotlib.
2.And if u don't want to do this, you can try to use matplotlib .
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('img.jpg',0)
plt.imshow(img, cmap='gray')
plt.show()
3.或者嘗試使用選項 WITH_GTK=ON
自己構建庫,或者類似的東西.
3.Or try to build library by your own with option WITH_GTK=ON
, or smth like that.
更新 - 2019 年 6 月 18 日
Update - 18th Jun 2019
我的 Ubuntu(18.04.1 LTS) 系統上的 openCV 3.4.2 出現此錯誤,因為對 cv2.imshow 的方法調用失敗.我正在使用蟒蛇.僅以下 2 個步驟幫助我解決了問題:
I got this error on my Ubuntu(18.04.1 LTS) system for openCV 3.4.2, as the method call to cv2.imshow was failing. I am using anaconda. Just the below 2 steps helped me resolve:
conda remove opencv
conda install -c conda-forge opencv=4.1.0
如果你用的是pip,可以試試
If you are using pip, you can try
pip install opencv-contrib-python
這篇關于OpenCV 在 Linux 上的 python 與 anaconda 無法正常工作.收到未實現 cv2.imshow() 的錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!