Last active
July 5, 2021 19:47
-
-
Save lucagessi/a7353d1f64f2e5c6da7fa9a2ce54006d to your computer and use it in GitHub Desktop.
Script used for face images generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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