VideoCapture freezes immediately after calling in code | Python 3
I'm trying to simply open up a USB Camera but cannot for the life of me figure out what in the world is going on. It seems to be freezing immediately after calling VideoCapture(1)
import numpy as np
import cv2
print(1)
cap = cv2.VideoCapture(1) #This is opening the camera stream and assigning it to cap
while (True):
print(2)
ret, frame = cap.read() #Assigning ret and frame
print(3)
if not ret:
break
print(4)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #Changing caps color
print(5)
cv2.imgshow('frame', gray) #Display it
print(6)
if cv2.waitKey(30) & 0xFF == ord('1'):
print(7)
break
cap.release()
print(8)
cv2.destroyAllWindows()
print(9)
I've tried changing
cv2.waitKey(30)
to
cv2.waitKey(0)
and
cv2.waitKey(1)
none of which had any sort of success
I'm pretty sure any more of this will cause me to rip my hair out, thanks for any help.
waitKey(0) or waitKey() will wait "forever".
not what you want.
os ? opencv version ? how did you install it ?
Ubuntu 18.04 OpenCV 4.0.0 installed via pip