Answer the question
In order to leave comments, you need to log in
Why doesn't cv2.Imshow() output an image?
Hi all! Faced the problem that the imshow function creates a window that is always unresponsive. Thus the script like as should work. macOS system. There is 100% access to the camera.
The code itself:
import cv2
cap = cv2.VideoCapture(0)
while True:
ret, img = cap.read()
cv2.imshow("camera", img)
if cv2.waitKey(10) == 27:
break
cap.release()
cv2.destroyAllWindows()
Answer the question
In order to leave comments, you need to log in
import cv2
cap = cv2.VideoCapture(0)
while True:
ret, img = cap.read()
if ret: # <<<<< этот параметр вам не просто так выдают
cv2.imshow("camera", img)
if cv2.waitKey(10) & 0xFF == 27: # <<<<< 0xFF
break
cap.release()
cv2.destroyAllWindows()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question