Skip to content

Latest commit

 

History

History
92 lines (64 loc) · 2.23 KB

README.md

File metadata and controls

92 lines (64 loc) · 2.23 KB

python-seetaface2

A python API interface for SeetaFaceEngine2

Installation

Prerequisite

Download binary models and libraries from SeetaFaceEngine2

git clone --recursive https://github.com/twmht/python-seetaface2
cd python-seetaface2 
cp $seetaface_lib ./
python setup.py install

$seetaface_lib is a lib directory after you unzip the library SDK.

If you want to build with opencv3

USE_OPENCV3=ON python setup.py build

Notes

Sometimes opencv package installed from apt-get may not be built successfully, you can try to build opencv from source.

opencv-3.4.2 from source has been verified.

Be sure to include the build

include_directories(${OPENCV_BUILD}/include)
link_directories(${OPENCV_BUILD}/lib)

Usage

detect faces and their landmarks

import seetaface
import cv2

root = 'example1.jpg'

im = cv2.imread(root)
image = seetaface.SeetaImage(im)
# or you can pass the image path to build SeetaImage
# image = seetaface.SeetaImage(root)

fd = seetaface.FaceDetector('/home/tumh/python-seetaface2/SeetaFaceDetector2.0.ats')
pd = seetaface.PointDetector('/home/tumh/python-seetaface2/SeetaPointDetector2.0.pts5.ats')

rects = fd.detect(image)
for rect in rects:
    cv2.rectangle(im, (rect.x, rect.y), (rect.x + rect.width, rect.y + rect.height), (0,0,255), 2)
    points = pd.detect(image, rect)
    for p in points:
        cv2.circle(im, (int(p.x), int(p.y)), 2, (0,0,255), -1)
        

Result

given a bounding box and detect the landmark

import seetaface
import cv2

root = 'example2.jpg'

image = seetaface.SeetaImage(root)

pd = seetaface.PointDetector('/home/tumh/python-seetaface2/SeetaPointDetector2.0.pts5.ats')

# given a boudning box
rect = seetaface.SeetaRect()
rect.x = 221
rect.y = 130
rect.width = 232
rect.height = 278

im = cv2.imread(root)
cv2.rectangle(im, (rect.x, rect.y), (rect.x + rect.width, rect.y + rect.height), (0,0,255), 2)
points = pd.detect(image, rect)
for p in points:
    cv2.circle(im, (int(p.x), int(p.y)), 2, (0,0,255), -1)

President of Taiwan