Skip to content

Instantly share code, notes, and snippets.

@lucagessi
Last active July 5, 2021 19:47
Show Gist options
  • Save lucagessi/a7353d1f64f2e5c6da7fa9a2ce54006d to your computer and use it in GitHub Desktop.
Save lucagessi/a7353d1f64f2e5c6da7fa9a2ce54006d to your computer and use it in GitHub Desktop.
Script used for face images generation
import cv2
import time
video_capture = cv2.VideoCapture(0)
folder = "./test/luca"
while True:
# Capture frame-by-frame
ret, frame = video_capture.read()
cv2.imshow('Video', frame)
key = cv2.waitKey(1) & 0xff
if key == ord('q'):
print("Exiting...")
break
if key == ord('s'):
timestr = time.strftime("%Y-%m-%d %H:%M:%S")
print("Saving image: "+timestr + ".jpeg")
filename = folder + timestr + ".jpeg"
cv2.imwrite(filename, frame)
if key == 13: ## enter key
timestr = time.strftime("%Y-%m-%d %H:%M:%S")
print("Saving image: "+timestr + ".jpeg")
filename = folder + timestr + ".jpeg"
cv2.imwrite(filename, frame)
video_capture.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment