How to use the mtcnn.detector.detect_faces function in mtcnn

To help you get started, we’ve selected a few mtcnn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foamliu / InsightFace-v3 / test / test_align.py View on Github external
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)
github LcenArthas / CCF-BDCI2019-Multi-person-Face-Recognition-Competition-Baseline / utils.py View on Github external
def get_all_face_attributes(full_path):
    img = Image.open(full_path).convert('RGB')
    bounding_boxes, landmarks = detect_faces(img)
    return bounding_boxes, landmarks
github LcenArthas / CCF-BDCI2019-Multi-person-Face-Recognition-Competition-Baseline / utils.py View on Github external
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
github foamliu / InsightFace / utils.py View on Github external
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
github foamliu / InsightFace / utils.py View on Github external
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
github LcenArthas / CCF-BDCI2019-Multi-person-Face-Recognition-Competition-Baseline / utils.py View on Github external
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