def capture_frame():
# Open the "default" camera
vc = cv2.VideoCapture(0)
# Check if we succeeded in opening camera feed
if vc.isOpened():
rval, frame = vc.read()
else:
rval = False
# Display captured frames in a new window
cv2.namedWindow("Camera Video Feed")
while rval:
cv2.imshow("Camera Video Feed", frame)
# cv2.imshow("Camera Video Feed", result)
rval, frame = vc.read()
key = cv2.waitKey(20)
if key == 27: # User pressed ESC key
break
elif key == ord('s'):
break
# Destroy window
cv2.destroyWindow("Camera Video Feed")
# Close VideoCapture feed -- Important!
vc.release()
# Save the frame
cv2.imwrite('../images/captured_frame.png', frame)
return frame
评论列表
文章目录