Untitled
unknown
python
a year ago
881 B
4
Indexable
import cv2 from facenet_pytorch import MTCNN import torch from datetime import datetime import os device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') print(device) IMG_PATH = './data/test_images/' # usr_name = input("Input ur name: ") USR_PATH = IMG_PATH leap = 1 mtcnn = MTCNN(margin = 20, keep_all=False, post_process=False, device = device) cap = cv2.VideoCapture(0) cap.set(cv2.CAP_PROP_FRAME_WIDTH,640) cap.set(cv2.CAP_PROP_FRAME_HEIGHT,480) while cap.isOpened(): isSuccess, frame = cap.read() if mtcnn(frame) is not None and leap%2: path = str(USR_PATH+'/face.jpg') face_img = mtcnn(frame, save_path = path) img = cv2.imread(path) print(img) leap+=1 cv2.imshow('Face Capturing', frame) if cv2.waitKey(1)&0xFF == 27: break cap.release() cv2.destroyAllWindows()
Editor is loading...
Leave a Comment