Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cv.circle(img_raw, (landms[1], landms[6]), 1, (0, 255, 255), 4)
cv.circle(img_raw, (landms[2], landms[7]), 1, (255, 0, 255), 4)
cv.circle(img_raw, (landms[3], landms[8]), 1, (0, 255, 0), 4)
cv.circle(img_raw, (landms[4], landms[9]), 1, (255, 0, 0), 4)
# save image
cv.imwrite('images/result.jpg', img_raw)
cv.imshow('image', img_raw)
cv.waitKey(0)
if __name__ == "__main__":
full_path = 'test/Jason Behr_27968.JPG'
img = Image.open(full_path).convert('RGB')
bboxes, landmarks = mtcnn.detect_faces(img)
print(bboxes)
print(landmarks)
show_bboxes(full_path, bboxes, landmarks)
bboxes, landmarks = retinaface.detect_faces(img)
print(bboxes)
print(landmarks)
show_bboxes(full_path, bboxes, landmarks)
def get_all_face_attributes(full_path):
img = Image.open(full_path).convert('RGB')
bounding_boxes, landmarks = detect_faces(img)
return bounding_boxes, landmarks
def get_face_attributes(full_path):
try:
img = Image.open(full_path).convert('RGB')
bounding_boxes, landmarks = detect_faces(img)
if len(landmarks) > 0:
landmarks = [int(round(x)) for x in landmarks[0]]
return True, landmarks
except KeyboardInterrupt:
raise
except:
pass
return False, None
def get_face_all_attributes(full_path):
try:
img = Image.open(full_path).convert('RGB')
bounding_boxes, landmarks = detect_faces(img)
if len(landmarks) > 0:
i = select_central_face(img.size, bounding_boxes)
return True, [bounding_boxes[i]], [landmarks[i]]
except KeyboardInterrupt:
raise
except:
pass
return False, None, None
def get_face_attributes(full_path):
try:
img = Image.open(full_path).convert('RGB')
bounding_boxes, landmarks = detect_faces(img)
if len(landmarks) > 0:
landmarks = [int(round(x)) for x in landmarks[0]]
return True, landmarks
except KeyboardInterrupt:
raise
except:
pass
return False, None
def get_central_face_attributes(full_path):
try:
img = Image.open(full_path).convert('RGB')
bounding_boxes, landmarks = detect_faces(img)
if len(landmarks) > 0:
i = select_central_face(img.size, bounding_boxes)
return True, [bounding_boxes[i]], [landmarks[i]]
except KeyboardInterrupt:
raise
except:
pass
return False, None, None