import cv2
import numpy as np
import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
while True:
ret,frame = cap.read()
cv2.imshow('capture', frame)
if cv2.waitKey(1)==ord('p'):
cv2.imwrite(r'C:\Users\ngwdy\Desktop\shexiang1.jpg',frame)
if cv2.waitKey(1)==ord('q'):
break
cap.release()
cv2.destroyAllWindows()
import numpy as np
import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
while True:
ret,frame = cap.read()
cv2.imshow('capture', frame)
if cv2.waitKey(1)==ord('p'):
cv2.imwrite(r'C:\Users\ngwdy\Desktop\shexiang1.jpg',frame)
if cv2.waitKey(1)==ord('q'):
break
cap.release()
cv2.destroyAllWindows()