Call the camera to take pictures
- Press the
s
button to take pictures and save it; - Press the
q
key to exit. - You can change the path where the photos are saved by yourself
import cv2
if __name__ == '__main__':
i=0
cap=cv2.VideoCapture(0)
while(1):
ret ,frame = cap.read()
cv2.imshow("capture", frame)
k=cv2.waitKey(1)
if k==ord('s'):
cv2.imwrite('code/opencv/save_pics/'+str(i)+'.jpg',frame)
i+=1
elif k==ord("q"):
break
cap.release()
cv2.destroyAllWindows()