cv2.VideoCapture() works on python 2 but not on 3, ubuntu 16.04, opencv v3.2.0
I got a OpenCV 3.2.0 on an Ubuntu 16.04. When this code is executed with Python 2.7.12 it works like a charm. In exactly the same code with Python 3.5.2, cv2.VideoCapture() returns FALSE.
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Most likely there is just a library or binding missing in the Python 3 environment. Also pip freeze and pip3 freeze return the same libs installed ... Could really need a hint.
Thanks in advance :)
Just tried and I don't have such problem (Ubuntu 16.04, OpenCV 3.2.0):
Are you sure your camera is not busy? Did you use GCC 5.4.0 to compile OpenCV?
Did you ever find a solution? I have the exact same issue @Tarhann