-
-
Notifications
You must be signed in to change notification settings - Fork 535
Open
Description
hi! I am newbie in python.
I needed a little magic (help) :)
I detect a face and save a picture from a video with a face.
But I would like to save not the whole picture, but only the part where there is a face.
What do I need to read to find a solution to my problem? thank
import cv2
from mtcnn import MTCNN
import os
import time
detector = MTCNN()
cap = cv2.VideoCapture("https://linktovideo")
while True:
__, frame = cap.read()
result = detector.detect_faces(frame)
if result != []:
for person in result:
bounding_box = person['box']
keypoints = person['keypoints']
cv2.rectangle(frame,
(bounding_box[0], bounding_box[1]),
(bounding_box[0]+bounding_box[2], bounding_box[1] + bounding_box[3]),
(0,155,255),
2)
timestr = time.strftime("%Y%m%d-%H%M%S")
cv2.imwrite("dataset/User." + str(timestr) + '.' + str(count) + ".jpg", frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) &0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Metadata
Metadata
Assignees
Labels
No labels