搜索
bottom↓
回复: 24

于仕琪"的"免费、高性能的人脸检测库"在C#中调用

  [复制链接]

出0入10汤圆

发表于 2017-7-9 23:00:00 | 显示全部楼层 |阅读模式
本帖最后由 linbin250 于 2017-7-9 23:00 编辑

网上找到2015年"于仕琪"的帖子  "免费、高性能的人脸检测库"   
http://www.opencv.org.cn/forum.php?mod=viewthread&tid=34155

于仕琪,博士,助理研究员,深圳大学副教授,OpenCV中文站站长。
==========================================
2015年12月7日更新:

三个人脸检测函数再次提速,multiview_reinforce()提速为上一版本的2.3倍,已经比OpenCV的正面人脸检测还要快!要知道其他两个函数比这个更快哦,最快的达到232FPS!
---------------------------------------------------------------------

2015年4月22日更新:

我们的免费人脸检测库再次更新:①正面人脸检测的角度范围从[-40, 40]度提升到[-60,60]度,检测角度变大但计算量不增加;②多视角人脸检测速度提升2倍!
---------------------------------------------------------------------
本团队雕琢多年的人脸检测库现以MIT协议发布 ,供商业和非商业无限制使用,包含正面和多视角人脸检测两个算法.优点:速度快(OpenCV haar+adaboost的2-3倍), 准确度高 (FDDB非公开类评测排名第二),能估计人脸角度. 例子看下图. 希望能帮助到有需要的个人和公司。

这个库比OpenCV自带的人脸检测强大一个数量级!纯C语言生成的二进制库,不依赖任何其他的库。接口更简洁,就一个函数。正面人脸检测,多视角人脸检测的API分别如下:

    int * facedetect_frontal( unsigned char * gray_image_data, int width, int height, int step,
                                   float scale,
                                   int min_neighbors,
                                   int min_size,
                                                               int max_size=0);

    int * facedetect_multiview( unsigned char * gray_image_data, int width, int height, int step,
                                   float scale,
                                   int min_neighbors,
                                   int min_size,
                                                               int max_size=0);

DLL库的下载地址:https://github.com/ShiqiYu/libfacedetection
转发到论坛的下载:


该人脸识别库在百度上找了很久,没有成功移植到C#的方法,认真学习后,成功移植,并成功移植到C#上。例子是VS2010, NET4.0编译环境





//下面是库的声明

        [DllImport("libfacedetect.dll", CharSet = CharSet.Auto, EntryPoint = "?facedetect_frontal@@YAPAHPAE0HHHMHHHH@Z", CallingConvention = CallingConvention.Cdecl)]
        unsafe public static extern byte* facedetect_frontal(
                                [In, Out]byte* result_buffer,
                                [In, Out]byte* gray_image_data,
                                int width, int height, int step,
                                float scale, //scale factor for scan windows
                                int min_neighbors, //how many neighbors each candidate rectangle should have to retain it
                                int min_object_width, //Minimum possible face size. Faces smaller than that are ignored.
                                int max_object_width = 0, //Maximum possible face size. Faces larger than that are ignored. It is the largest posible when max_object_width=0.
                                int doLandmark = 0); // landmark detection


        [DllImport("libfacedetect.dll", CharSet = CharSet.Auto, EntryPoint = "?facedetect_frontal_surveillance@@YAPAHPAE0HHHMHHHH@Z", CallingConvention = CallingConvention.Cdecl)]
        unsafe public static extern byte* facedetect_frontal_surveillance(
                                [In, Out]byte* result_buffer, //buffer memory for storing face detection results, !!its size must be 0x20000 Bytes!!
                                [In, Out]byte* gray_image_data, int width, int height, int step, //input image, it must be gray (single-channel) image!
                                float scale, //scale factor for scan windows
                                int min_neighbors, //how many neighbors each candidate rectangle should have to retain it
                                int min_object_width, //Minimum possible face size. Faces smaller than that are ignored.
                                int max_object_width = 0, //Maximum possible face size. Faces larger than that are ignored. It is the largest posible when max_object_width=0.
                                int doLandmark = 0); // landmark detection

        [DllImport("libfacedetect.dll", CharSet = CharSet.Auto, EntryPoint = "?facedetect_multiview@@YAPAHPAE0HHHMHHHH@Z", CallingConvention = CallingConvention.Cdecl)]
        unsafe public static extern byte* facedetect_multiview(
                                [In, Out]byte* result_buffer, //buffer memory for storing face detection results, !!its size must be 0x20000 Bytes!!
                                [In, Out]byte* gray_image_data, int width, int height, int step, //input image, it must be gray (single-channel) image!
                                float scale, //scale factor for scan windows
                                int min_neighbors, //how many neighbors each candidate rectangle should have to retain it
                                int min_object_width, //Minimum possible face size. Faces smaller than that are ignored.
                                int max_object_width = 0, //Maximum possible face size. Faces larger than that are ignored. It is the largest posible when max_object_width=0.
                                int doLandmark = 0); // landmark detection

        [DllImport("libfacedetect.dll", CharSet = CharSet.Auto, EntryPoint = "?facedetect_multiview_reinforce@@YAPAHPAE0HHHMHHHH@Z", CallingConvention = CallingConvention.Cdecl)]
        unsafe public static extern byte* facedetect_multiview_reinforce(
                                [In, Out]byte* result_buffer, //buffer memory for storing face detection results, !!its size must be 0x20000 Bytes!!
                                [In, Out]byte* gray_image_data, int width, int height, int step, //input image, it must be gray (single-channel) image!
                                float scale, //scale factor for scan windows
                                int min_neighbors, //how many neighbors each candidate rectangle should have to retain it
                                int min_object_width, //Minimum possible face size. Faces smaller than that are ignored.
                                int max_object_width = 0, //Maximum possible face size. Faces larger than that are ignored. It is the largest posible when max_object_width=0.
                                int doLandmark = 0); // landmark detection

C#例子程序 VS2010编程环境 .NET4.0




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2017-7-9 23:03:18 | 显示全部楼层
很强大的样子。

出0入0汤圆

发表于 2017-7-9 23:10:26 | 显示全部楼层
看介绍,效果很不错呀~~~

下载来试试

谢谢楼主分享

出0入10汤圆

 楼主| 发表于 2017-7-9 23:11:44 | 显示全部楼层
cqfeiyu 发表于 2017-7-9 23:03
很强大的样子。

不用不知道,一用才知道!确实很厉害。

出0入10汤圆

 楼主| 发表于 2017-7-9 23:15:50 | 显示全部楼层
FireHe 发表于 2017-7-9 23:10
看介绍,效果很不错呀~~~

下载来试试

本来要用EmguCV(openCV的net版本),用的烦死了,编程技术不行,英语又不好,而且图像也不懂,还要训练模型。

完蛋了,发挥搜索能力,找到这个库,介绍说很好,但是C++用的连半斤都不到,于是拼命移植到c#,就这个声明就搞了2个通宵。

不过好处是,终于搞定了,效果非常好!

出0入442汤圆

发表于 2017-7-9 23:35:18 来自手机 | 显示全部楼层
linbin250 发表于 2017-7-9 23:15
本来要用EmguCV(openCV的net版本),用的烦死了,编程技术不行,英语又不好,而且图像也不懂,还要训练 ...

唉。其实当它报错时你就应该考虑是不是定义有问题。显然库生成时接口没有extern “C”声明。这时候你就得用IDA去找实际的导出符号,并且以后每个新版本都要去核对一下导出符号有无变化。

出0入0汤圆

发表于 2017-7-10 00:03:49 来自手机 | 显示全部楼层
这个强,先想想可以用在哪,到时试试

出0入0汤圆

发表于 2017-7-10 07:14:28 | 显示全部楼层
楼主,怎么识别同一个人的脸

出0入0汤圆

发表于 2017-7-10 07:41:12 来自手机 | 显示全部楼层
这是在图片里找出人有脸来。而不是识别出谁的脸吧?

出0入0汤圆

发表于 2017-7-10 08:50:52 | 显示全部楼层
牛!下来学习一下,感谢分享~~~~~~~~

出0入89汤圆

发表于 2017-7-10 09:48:09 | 显示全部楼层
简单的了解了下,发现不是开源的,只提供了dll,这样测试玩可以,但。。。

出0入0汤圆

发表于 2017-7-10 10:25:22 | 显示全部楼层
本帖最后由 Linda898 于 2017-7-10 10:26 编辑

直接运行例子程序,找不到DDL,怎么破?
DDL都有放在SYSTEM32中,BIN中

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2017-7-10 10:47:17 | 显示全部楼层
谢谢分享

出0入10汤圆

发表于 2017-7-10 17:36:36 | 显示全部楼层
本人写的手写识别算法:基于PCA降维的方法。语言:Python。
PCA(主成分分析):从压缩图像到手写数字识别实验:http://www.jianshu.com/p/09871c72a143

出0入0汤圆

发表于 2017-7-10 18:30:56 来自手机 | 显示全部楼层
不错,看看

出0入0汤圆

发表于 2017-7-10 19:47:49 | 显示全部楼层
这个在opencv论坛上有好长时间了

出0入0汤圆

发表于 2017-7-10 20:29:21 | 显示全部楼层
  这个是从图库中找出指定的人,还是,从图片中识别出人脸?

出0入53汤圆

发表于 2017-7-10 20:58:24 来自手机 | 显示全部楼层
10xjzheng 发表于 2017-7-10 17:36
本人写的手写识别算法:基于PCA降维的方法。语言:Python。
PCA(主成分分析):从压缩图像到手写数字识别 ...

手写汉子识别吗?

出0入10汤圆

发表于 2017-7-11 13:21:24 | 显示全部楼层
zhcj66 发表于 2017-7-10 20:58
手写汉子识别吗?

呃,理论上是可以,但是我这个算法要识别的东西越多,速度越慢。
汉字,数字,人脸都可以,但是个数越多需要CPU性能越好。那种
在公司门口的人脸识别打卡机可以用这个实现。

出0入0汤圆

发表于 2017-7-11 13:54:30 来自手机 | 显示全部楼层
厉害,到时候试试

出0入10汤圆

 楼主| 发表于 2017-7-12 08:54:09 | 显示全部楼层
Linda898 发表于 2017-7-10 10:25
直接运行例子程序,找不到DDL,怎么破?
DDL都有放在SYSTEM32中,BIN中

DLL 放到EXE旁边就好。
如果要放别的地方,我记得对于64位系统,应该放到c:\Windows\SysWOW64,32位系统放到c:\Windows\system32。

出0入10汤圆

 楼主| 发表于 2017-7-12 08:55:55 | 显示全部楼层
wye11083 发表于 2017-7-9 23:35
唉。其实当它报错时你就应该考虑是不是定义有问题。显然库生成时接口没有extern “C”声明。这时候你就得 ...

导出名是一个坎,第一个参数传递也是一个坎。混在一起的时候,都搞不明白应该是哪个坎的问题,也是运气好:)

出0入10汤圆

 楼主| 发表于 2017-7-12 08:59:37 | 显示全部楼层
10xjzheng 发表于 2017-7-10 17:36
本人写的手写识别算法:基于PCA降维的方法。语言:Python。
PCA(主成分分析):从压缩图像到手写数字识别 ...

一直听说有一个强大的Python软件。也一直没有搞明白,Python编译出来是EXE可执行程序么?核心的是周围的人和我一样,还处在多年以前的编程语言时代:)

出0入0汤圆

发表于 2017-7-12 09:05:53 | 显示全部楼层
linbin250 发表于 2017-7-12 08:54
DLL 放到EXE旁边就好。
如果要放别的地方,我记得对于64位系统,应该放到c:\Windows\SysWOW64,32位系统 ...

本来就是放在EXE边的,然后system32 里也放了,还是这个错误

出0入0汤圆

发表于 2017-7-12 10:33:51 | 显示全部楼层
这个很强大,mark下以后学习
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-20 08:51

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表