Open blinkbink opened 5 years ago
i have finish the problem, at the facerec_from_video_file.py
while True:
ret, frame = input_movie.read()
frame_number += 1
# Quit when the input video file ends
if not ret:
break
if frame_number%5==0:
# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
rgb_frame = frame[:, :, ::-1]
frames.append(rgb_frame)
# Find all the faces and face encodings in the current frame of video
if len(frames) == 1:
batch_face_locations =
face_recognition.batch_face_locations(frames,number_of_times_to_upsample=0)
for face_locations in batch_face_locations:
face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
face_names = []
for face_encoding in face_encodings:
# See if the face is a match for the known face(s)
match = face_recognition.compare_faces(known_faces, face_encoding, tolerance=0.415)
# If you had more than 2 faces, you could make this logic a lot prettier
# but I kept it simple for the demo
name = None
if match[0]:
name = "Cui Xianghui"
elif match[1]:
name = "Li Dongsheng"
elif match[2]:
name = "Liu Jianfeng"
elif match[3]:
name = "Liu Donggang"
elif match[4]:
name = "Sun Xingxing"
elif match[5]:
name = "Yan Zhiyong"
face_names.append(name)
# Label the results
for (top, right, bottom, left), name in zip(face_locations, face_names):
if not name:
continue
# Draw a box around the face
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
# Draw a label with a name below the face
cv2.rectangle(frame, (left, bottom - 25), (right, bottom), (0, 0, 255), cv2.FILLED)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left + 6, bottom - 6), font, 0.5, (255, 255, 255), 1)
# Write the resulting image to the output video file
print("Writing frame {} / {}".format(frame_number, length))
output_movie.write(frame)
frames=[]
else:
output_movie.write(frame)
Python : 3.5.6 Face_recognition : 1.2.3 dlib : 19.16.99 GPU : Tesla P100 16Gb
hello, i have problem when working with face on ID Card on my country, many ID card can detect the face location. But sometime i can't get face location with this line code. I have try add more in upsample like 5 (but got memory allocation) :
any advices for this ? Thank you