github地址
https://github.com/ipazc/mtcnn
本机环境
python 3.7
Keras 2.2.0
opencv-python 4.5.1.48
tensorflow 1.13.1
检测函数及实例
import cv2
from mtcnn import MTCNN
detector = MTCNN()
def detec_face(imgFileName):
image = cv2.cvtColor(cv2.imread(imgFileName), cv2.COLOR_BGR2RGB)
result = detector.detect_faces(image)
if len(result) == 0