1 Star 0 Fork 0

FlameVision/SmarterRingV2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
submit_face.py 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
Atharv 提交于 2021-03-06 08:44 . Bugfixes
import cv2
from face_recognition import detect_face
from ring import main
from utils import get_specific_frames
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument('name', type=str, help='Name of person to take a picture of', nargs='+')
parser.add_argument('from_door', type=bool, help='If the images will directly come from the ring', nargs='+')
args = parser.parse_args()
print(args.from_door)
print(args.name)
if args.from_door[0]:
main(download_only=True)
times = [3, 6, 9, 12, 15, 18]
img_dir = 'data/faces/' + args.name[0] + '/'
if not os.path.exists(img_dir):
os.mkdir(img_dir)
frames = get_specific_frames('last_ding.mp4', times)
for frame in frames:
img = detect_face(frame)
if img is None:
print("[ERROR] An image isn't clear! skipping download!")
continue
cv2.imwrite(img_dir + str(len(os.listdir(img_dir))) + '.jpg', img)
print('[INFO] {} Saved Successfully'.format(args.name))
else:
cam = cv2.VideoCapture(0)
cv2.namedWindow("Your Face!")
while True:
ret, frame = cam.read()
if not ret:
print("[ERROR] failed to grab frame")
break
cv2.imshow("Your Face!", frame)
k = cv2.waitKey(1)
if k % 256 == 27:
# ESC pressed
print("[INFO] Escape hit, closing...")
break
elif k % 256 == 32:
# SPACE pressed
img = detect_face(frame)
if img is None:
print("[ERROR] Image isn't clear! Try again!")
continue
img_dir = 'data/faces/' + args.name[0] + '/'
if not os.path.exists(img_dir):
os.mkdir(img_dir)
cv2.imwrite(img_dir + str(len(os.listdir(img_dir))) + '.jpg', img)
print('[INFO] {} Saved Successfully'.format(args.name))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flamevision/SmarterRingV2.git
git@gitee.com:flamevision/SmarterRingV2.git
flamevision
SmarterRingV2
SmarterRingV2
master

搜索帮助