def test_detector():
print('test detector:')
# load model
detector = Detector('SeetaFaceEngine/model/seeta_fd_frontal_v1.0.bin')
detector.set_min_face_size(30)
image_color = cv2.imread('data/chloecalmon.png', cv2.IMREAD_COLOR)
image_gray = cv2.cvtColor(image_color, cv2.COLOR_BGR2GRAY)
faces = detector.detect(image_gray)
for i, face in enumerate(faces):
print('({0},{1},{2},{3}) score={4}'.format(face.left, face.top, face.right, face.bottom, face.score))
cv2.rectangle(image_color, (face.left, face.top), (face.right, face.bottom), (0,255,0), thickness=2)
cv2.putText(image_color, str(i), (face.left, face.bottom),cv2.FONT_HERSHEY_COMPLEX, 1, (0,255,0), thickness=1)
cv2.imshow('test', image_color)
cv2.waitKey(0)
detector.release()
评论列表
文章目录