#python #opencv
#python #opencv
Вопрос:
Я новичок в OpenCV и только начал изучать, я использую macOS, python версии 3.8.1
Мой код:
import cv2
# takes facecam video
cap = cv2.VideoCapture(-1)
while True:
# Capture frame-by-frame
ret, frame = cap.read()
if cap.isOpened() == True:
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) amp; 0xFF == ord('q'):
break
else:
cap.open(-1)
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Ответ №1:
Это работает для меня
import cv2
cap = cv2.VideoCapture(0)
while True:
ne, frame = cap.read()
cv2.imshow("Webcam Capture", frame)
if cv2.waitKey(1) amp; 0xFF == ord("A"):
break
cap.release()
cv2.destroyAllWindows()