Yuface
Introduction
A super fast face detector packaged by the libfacedetection repository using pybind11.
Change Log
[2023-5-8] Project init.
Quick start
pip install yuface
Usage
- Load image
import cv2
img = cv2.imread('xxx.jpg')
import PIL
import numpy as np
img = PIL.Image.open('xxx.jpg').convert('RGB')
img = np.array(img)
img = img[:, :, ::-1]
import imageio as io
img = io.imread('xxx.jpg')
img = img[:, :, ::-1]
- Detect
from yuface import detect
confs, bboxes, landmarks = detect(img, conf_thresh=0.5)
- Deal result
import cv2
for conf, bbox, landmark in zip(confs, bboxes, landmarks):
cv2.rectangle(img, (bbox[0], bbox[1]), (bbox[0] + bbox[2], bbox[1] + bbox[3]), (0, 255, 0), 1)
cv2.putText(img, str(conf), (bbox[0], bbox[1]), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 1)
for i in range(5):
cv2.circle(img, (landmark[2*i], landmark[2*i+1]), 2, (0, 255, 0), 1)
cv2.imwrite('result.jpg', img)