Giter Site home page Giter Site logo

python-seetaface2's Introduction

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

python-seetaface2's People

Contributors

twmht avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.