0

I wrote some code to generate a live feed from my laptop webcam. I'm using the openCV library for Python 3.7 with Pycharm.

This is my code:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while True:
    #capture frame by frame
    ret, img = cap.read()
#    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    cv2.imshow('test', img)

cv2.waitKey(0) & 0xFF
cv2.destroyAllWindows()
cap.release()

This is the error message that I got:

Traceback (most recent call last): File "D:/Python Programs/OpenCV/VideoCapture.py", line 10, in cv2.imshow('test', img) cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:627: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa 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'

[ WARN:0] terminating async callback

HFBrowning
  • 2,196
  • 3
  • 23
  • 42
  • Possible duplicate of [OpenCV error: the function is not implemented](https://stackoverflow.com/questions/14655969/opencv-error-the-function-is-not-implemented) – HFBrowning Jun 25 '19 at 16:42
  • The [OpenCV Forum](https://answers.opencv.org/questions/) might be able to help you more quickly. –  Jun 25 '19 at 17:12
  • Aside from the `highgui` backend build issue suggested by the GTK+ error, you need to make sure the `waitKey()` call is in the loop after `imshow()`. Currently, it is listed after the `while True` loop and is never invoked, since the loop is infinite. You'd also want to check for a key to exit the loop via the result from the `waitKey()` call. – rob3c Jun 26 '19 at 07:16

0 Answers0