Giter Club home page Giter Club logo

pysample-for-shiqiyu's Introduction

Update @ Oct 10 ,2019

Profartssor Yu update new version. Change the mod from float to long. It's only 915K. すごい
"facedetectcnn-floatdata.cpp" change to "facedetectcnn-int8data.cpp"

So , you have to change the C++ DLL project"

  1. Open the fd-shiqiyu.sln
  2. Remove "facedetectcnn-floatdata.cpp"
  3. Copy all files(*.h and *.cpp) from https://github.com/ShiqiYu/libfacedetection/tree/master/src to your project
  4. Add "facedetectcnn-int8data.cpp" into the project
  5. Recompile the project to generate "fd-shiqiyu_v2.dll"

pySample-for-ShiqiYu

The DLL inferface & python sample code base on new version of libfacedetection (https://github.com/ShiqiYu/libfacedetection )by Shiqi.Yu.

于仕琪 老师新版本人脸识别(https://github.com/ShiqiYu/libfacedetection )的DLL接口及Python语言案例。

Step1 : Create a Dll for proivide an interface to python

  1. Create a C++ DLL project and named "fd-shiqiyu" in VS2017
  2. Copy all files(*.h and *.cpp) from https://github.com/ShiqiYu/libfacedetection/tree/master/src to your project
  3. Create the "dll-interface.cpp" to export the function
  4. Compile the project to generate "fd-shiqiyu.dll"

第一步:创建用于python接口的DLL
1)VS2017中创建新 “C++ DLL”项目,名称为 “fd-shiqiyu”
2)将 https://github.com/ShiqiYu/libfacedetection/tree/master/src 下所有文件复制到项目中
3)新建 "dll-interface.cpp" ,提供DLL访问接口
4)编译项目,生成 "fd-shiqiyu.dll"

Step2 : The sample code of Python call the DLL

  1. Copy the "fd-shiqiyu.dll" file to Dlls folder of python code's path
  2. Create the "ex.py" sample code file to call the Dll 3)Run "ex.py"

第2步:Python 调用 Dll 案例代码
1)拷贝 "fd-shiqiyu.dll" 文件到 Python 代码的 “Dlls” 子目录下
2)新建 "ex.py" 案例代码
3)运行 "ex.py"

The diffrences between new version and old version of Shiqi.Yu's library.

  1. The new version can detect the any angle face, include upside-down face, the old version can't
  2. But the new version can't output the angle & 68 landmark points of face now, the old version can do it

于老师新旧版本的比较
1)新版本可以检测任何角度的脸,包括倒立的,旧版本不行
2)但新版本现在还不能提供 角度 和 68关键点 参数,旧版本可以

pysample-for-shiqiyu's People

Contributors

armstrong1972 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pysample-for-shiqiyu's Issues

Ubuntu 下运行错误

你好,我在Ubuntu 16.04运行时,在载入dll的时候,出现了 invalid ELF header 错误
是只能在windows上运行吗?如果是,那怎么才能在Ubuntu上运行呢

谢谢

批量检测目录中的图片时 程序会异常中断

我在ex.py的基础上写了遍历目录取照片的代码,这时候会异常中断

# coding: utf-8
# 
# 程序功能 :使用 于仕琪 老师的lib,做人脸识别
#     重点 :调用 C++ 提供的 DLL 接口时,如何处理 指针 类型

import numpy as np
import cv2
from ctypes import *
import types
import sys
import os
import tqdm

Max_Faces = 256
Size_one_Face = 6 + 68 * 2
Size_FaceLandMarks = Size_one_Face * Max_Faces
class FaceResults(Structure): 
    _fields_ = [("face_num", c_int32), 
                ("datas", c_int16 * Size_FaceLandMarks)
               ]

for root, dirs, files in os.walk("E:\\43"):
    for name in files:
        img_path = os.path.join(root, name)
        print(img_path)
        img = cv2.imread(img_path)
        h,w = img.shape[:2]
        st = w*3

        p_img = img.ctypes.data_as(POINTER(c_ubyte))

        #dll = CDLL('./dlls/fd-shiqiyu.dll')    # old version
        dll = CDLL('./dlls/fd-shiqiyu_v2.dll')
        dll.shiqi_fd.restype = POINTER(FaceResults)

        p_results = dll.shiqi_fd(p_img,w,h,st) 
        face_num = p_results.contents.face_num


        for i in range(face_num):
            j =  Size_one_Face * i
            x = p_results.contents.datas[j]
            y = p_results.contents.datas[j+1]
            w = p_results.contents.datas[j+2]
            h = p_results.contents.datas[j+3]
            confidence = p_results.contents.datas[j+4]
            angle = p_results.contents.datas[j+5]

BGR or RGB?

in the orgal libfacedetect:
//!!! The input image must be a #BGR# one (three-channel) instead of RGB
// pResults = facedetect_cnn(pBuffer, (unsigned char*)(image.ptr(0)), image.cols, image.rows, (int)image.step);
and in this pySample-for-ShiqiYu:
//input image, it must be RGB (three-channel) image!原版要求BGR?
int * shiqi_fd(unsigned char * rgb_image_data, int width, int height, int step)
{
unsigned char * pBuffer = (unsigned char *)malloc(DETECT_BUFFER_SIZE);
return facedetect_cnn(pBuffer, rgb_image_data, width, height, step);
}
??

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.