How to use the mtcnn.initFaceDetector 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 wujiyang / BossRecognition / detectionAndAlign.py View on Github external
def main():
    '''
    function test
    '''
    # model initialization, only do once !
    minsize, PNet, RNet, ONet, threshold, factor = mtcnn.initFaceDetector()

    # read image
    img = cv2.imread('images/wujiyang-0000438.jpg')
    alignfaces, img = fac_detection_alignment(img, minsize, PNet, RNet, ONet, threshold, factor)

    for i in range(len(alignfaces)):
        cv2.imshow('img', alignfaces[i])
        cv2.waitKey()
github wujiyang / BossRecognition / demo.py View on Github external
def main():
    #--------------------------------------------------------
    # step 1: model initialization
    #--------------------------------------------------------
    minsize, PNet, RNet, ONet, threshold, factor = mtcnn.initFaceDetector()
    net = extractFeature.initFeatureExtractor()
    transformer = extractFeature.setTransformer(net)

    #--------------------------------------------------------
    # step 2: load facelib feature from lib folder
    #--------------------------------------------------------
    libFeature = loadFaceLib(net, transformer, minsize, PNet, RNet, ONet, threshold, factor)
    print libFeature.shape

    #--------------------------------------------------------
    # step 3: read image from camera and calculate similarity
    #--------------------------------------------------------
    cap = cv2.VideoCapture(0)
    while(1):
        frame = cameraCapture.getFrameFromCamera(cap)
        cv2.putText(frame, "press 'q' to exit", (10, 30), 0, 1, (255, 0, 0), 1, False)