I have been working on opencv lately. Installed it on my Ubuntu 16.04. I think it has a few problems. Whenever I try to run the function
cv2.imshow('frame',frame)
it poses this error
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 /tmp/build/80754af9/opencv_1512687413662/work/modules/highgui/src/window.cpp, line 611
Traceback (most recent call last):
File "hands.py", line 12, in <module>
cv2.imshow('frame',frame)
cv2.error: /tmp/build/80754af9/opencv_1512687413662/work/modules/highgui/src/window.
cpp:611: 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
The code I tried to run is
import numpy as numpy
import cv2
import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
bg = cv2.bgsegm.createBackgroundSubtractorMOG()
while True:
ret,frame = cap.read()
vid = bg.apply(frame)
cv2.imshow('frame',frame)
cv2.imshow('vid',vid)
key = cv2.waitKey(0) & 0xff
if key == 27:
break
cap.release()
cap.destroyAllWindows()
I tried to google every possible thing and did everything that's possible but still aren't able to solve the issue.
I also tried using
matplotlib.pyplot.imshow('frame',frame)
matplotlib.pyplot.show()
instead of
cv2.imshow('frame',frame)
but this gives the error
TypeError: unhashable type: 'numpy.ndarray'
to show the video captured from my webcam. It either shows just a image and an error at cv2.waitkey() instead of the video or this error. Is there any method to solve this error? or to implement cv2 GUI features?