2017-04-25 79 views
0

我運行下面的代碼在pythonCV imshow拋出錯誤

import numpy as np import cv2 

print "hello" 

img = cv2.imread('image.JPG',0) print img 

cv2.imshow('sood',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 /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp, line 583 Traceback (most recent call last): File "cv2ImageProcessing.py", line 9, in cv2.imshow('sood',img) cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:583: 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

+0

我在打印「img」時得到一個數組,所以圖像越來越可能被讀取,但imshow仍然無法正常工作。 –

+0

看看[這個SO PAGE](http://stackoverflow.com/questions/40207011/opencv-not-working-properly-with-python-on-linux-with-anaconda-getting-error-th?rq = 1) –

回答

0

你爲什麼不安裝libgtk2.0-dev它似乎是要求你安裝它。嘗試sudo apt-get install libgtk2.0-dev

如果不能解決問題,請嘗試安裝script中提到的所有依賴關係。我使用這個腳本在我的系統上安裝了OpenCV,一切正常。

+2

libgtk2.0-dev和pkg-config和GTK所有這些都已經安裝,我剛纔再次驗證,但似乎仍然給出了相同的錯誤 幫助! –

+0

你檢查了腳本嗎?只要運行它並讓我知道 –

0

此腳本工作:

import numpy as np 
import cv2 

print "hello" 

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

cv2.imshow('sood',img) 
cv2.waitKey() 
cv2.destroyAllWindows() 

最有可能你的OpenCV3安裝不正確。嘗試重新安裝它。閱讀this how-to。使用*.whl file在Windows上安裝Python OpenCV3非常簡單。

+0

你的問題解決了嗎? –