mediapipe
mediapipe copied to clipboard
How do I save detected face?
How do I save detected face? Is there a special function for that?
Hi @martinenkoEduard, Is it implemented through python, JavaScript or others? Could you please help me in reproducing the same with complete steps at our end. Thank you!
Hi @martinenkoEduard, Is it implemented through python, JavaScript or others? Could you please help me in reproducing the same with complete steps at our end. Thank you!
#https://www.youtube.com/watch?v=jn1HSXVmIrA
from unittest import result
import cv2
import mediapipe as mp
mp_face_detection = mp.solutions.face_detection
mp_drawing = mp.solutions.drawing_utils
faceDetection = mp_face_detection.FaceDetection()
# Create a VideoCapture object and read from input file
# If the input is the camera, pass 0 instead of the video file name
cap = cv2.VideoCapture('Faces from around the world.mp4')
# Check if camera opened successfully
if (cap.isOpened()== False):
print("Error opening video stream or file")
# Read until video is completed
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == True:
# rgb_frame = frame[:, :, ::-1]
imgRGB = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
results = faceDetection.process(imgRGB)
#print(results)
if results.detections:
for id, detection in enumerate(results.detections):
print(detection)
mp_drawing.draw_detection(frame,detection)
# face_locations = face_recognition.face_locations(rgb_frame)
# for top, right, bottom, left in face_locations:
# # Draw a box around the face
# cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
# Display the resulting frame
cv2.imshow('Frame',frame)
# Press Q on keyboard to exit
if cv2.waitKey(25) & 0xFF == ord('q'):
break
# Break the loop
else:
break
# When everything done, release the video capture object
cap.release()
# Closes all the frames
cv2.destroyAllWindows()
Hi @martinenkoEduard, MediaPipe does return detections, or face images, or rendered detection rectangles but does not have any APIs for storage of these returned results. Thank you!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.