OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
楼主: Shiqi Yu

免费、高性能的人脸检测库

  [复制链接]
发表于 2015-10-23 10:21:14 | 显示全部楼层
china_clear 发表于 2015-10-22 21:44
我只是在一个线程里调用的,本来是想做成2个线程的,在一开始时就会出错,后来就使用一个线程进行调用。 ...

我又调查了下,发现上层调用时使用了并发,我修改了后,到现在还没出错!
回复 支持 反对

使用道具 举报

发表于 2015-10-25 12:52:11 | 显示全部楼层
china_clear 发表于 2015-10-23 10:21
我又调查了下,发现上层调用时使用了并发,我修改了后,到现在还没出错! ...

有没有处理视频的例子,速度如何啊?
回复 支持 反对

使用道具 举报

发表于 2015-10-25 12:53:44 | 显示全部楼层
hustjoyboy 发表于 2015-7-31 16:26
用DLL再封装一下,就能给delphi或者VB等工具调用了
#include
#include "facedetect-dll.h"

能给个执行文件看看运行效果吗?谢谢
回复 支持 反对

使用道具 举报

发表于 2015-10-26 10:18:41 | 显示全部楼层
于老师,这个程序能够运行,只跳出一个结果窗口之后迅速关闭了,我要检测一张合影图片,怎么样才能显示图片窗口而且把人脸圈出来?
回复 支持 反对

使用道具 举报

发表于 2015-10-26 13:05:08 | 显示全部楼层
于老师好。用的时候发现 没法释放 int *result  (人脸坐标) 我检测出来后想释放 free(result),发现程序中断
回复 支持 反对

使用道具 举报

发表于 2015-10-27 19:40:53 | 显示全部楼层
强烈赞一下,谢谢分享啊
回复 支持 反对

使用道具 举报

发表于 2015-10-27 21:14:02 | 显示全部楼层
于老师,有点厉害啊,学习下
回复 支持 反对

使用道具 举报

发表于 2015-10-28 14:41:12 | 显示全部楼层
超级好用,又免费,太感谢于博士了,多么想知道宝刀是怎样练得的~~~能讲讲原理么?
回复 支持 反对

使用道具 举报

发表于 2015-10-28 15:15:48 | 显示全部楼层
借花献佛,发一下展示于博士人脸检测算法效果的代码:
/*
The MIT License (MIT)

Copyright (c) 2015 Shiqi Yu
shiqi.yu@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#include <opencv2/opencv.hpp>
#ifdef _DEBUG
#pragma comment(lib,"opencv_core249d.lib")
#pragma comment(lib,"opencv_highgui249d.lib")
#pragma comment(lib,"opencv_imgproc249d.lib")
#else
#pragma comment(lib,"opencv_core249.lib")
#pragma comment(lib,"opencv_highgui249.lib")
#pragma comment(lib,"opencv_imgproc249.lib")
#endif

#include "../include/facedetect-dll.h"
#pragma comment(lib,"../lib/libfacedetect.lib")

using namespace cv;

int main(int argc, char* argv[])
{
        //load an image and convert it to gray (single-channel)
        for( int i=0; i<100; i++ )
        {
                char filename[64]={0};
                sprintf_s(filename, 64, "../Probe/test%d.jpg", i+1);
                IplImage* iplImg = cvLoadImage(filename, CV_LOAD_IMAGE_ANYCOLOR);
                if( !iplImg )
                {
                        continue;
                }

                //Mat gray = imread("test.png", CV_LOAD_IMAGE_GRAYSCALE);//失败
                Mat gray(iplImg), src(iplImg); cvtColor(src, gray, CV_RGB2GRAY);
                if(gray.empty())
                {
                        fprintf(stderr, "Can not load the image file.\n");
                        return -1;
                }

                int * pResults = NULL;

                cvNamedWindow("orig", 1);//       
                //imshow("orig", gray);//有乱码
               
                ///////////////////////////////////////////
                // frontal face detection
                // it's fast, but cannot detect side view faces
                //////////////////////////////////////////
                //!!! The input image must be a gray one (single-channel)
                //!!! DO NOT RELEASE pResults !!!
                pResults = facedetect_frontal((unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, gray.step,
                                                                                                   1.2f, 2,  24);
                printf("%d frontal faces detected.\n", (pResults ? *pResults : 0));
                //print the detection results
                for(int i = 0; i < (pResults ? *pResults : 0); i++)
                {
                        short * p = ((short*)(pResults+1))+6*i;
                        int x = p[0];
                        int y = p[1];
                        int w = p[2];
                        int h = p[3];
                        int neighbors = p[4];

                        printf("face_rect=[%d, %d, %d, %d], neighbors=%d\n", x,y,w,h,neighbors);

                        cvRectangle(iplImg, cvPoint(x,y), cvPoint(x+w, y+h), CV_RGB(255,0,0), 2);
                }

                cvShowImage("orig", iplImg);//放在绘图函数后,才会显示
                cvWaitKey(0);//等待绘图

                ///////////////////////////////////////////
                // multiview face detection
                // it can detection side view faces, but slower than the frontal face detection.
                //////////////////////////////////////////
                //!!! The input image must be a gray one (single-channel)
                //!!! DO NOT RELEASE pResults !!!
                pResults = facedetect_multiview((unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, gray.step,
                                                                                                   1.2f, 4, 24);
                printf("%d faces detected.\n", (pResults ? *pResults : 0));

                //print the detection results
                for(int i = 0; i < (pResults ? *pResults : 0); i++)
                {
                        short * p = ((short*)(pResults+1))+6*i;
                        int x = p[0];
                        int y = p[1];
                        int w = p[2];
                        int h = p[3];
                        int neighbors = p[4];
                        int angle = p[5];

                        printf("face_rect=[%d, %d, %d, %d], neighbors=%d, angle=%d\n", x,y,w,h,neighbors, angle);

                        cvRectangle(iplImg, cvPoint(x,y), cvPoint(x+w, y+h), CV_RGB(0,255,0), 2);
                }

                cvShowImage("orig", iplImg);//放在绘图函数后,才会显示
                cvWaitKey(0);//等待绘图

                ///////////////////////////////////////////
                // reinforced multiview face detection
                // it can detection side view faces, but slower than the frontal face detection.
                //////////////////////////////////////////
                //!!! The input image must be a gray one (single-channel)
                //!!! DO NOT RELEASE pResults !!!
                pResults = facedetect_multiview_reinforce((unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, gray.step,
                                                                                                   1.2f, 4, 24);
                printf("%d faces detected.\n", (pResults ? *pResults : 0));

                //print the detection results
                for(int i = 0; i < (pResults ? *pResults : 0); i++)
                {
                        short * p = ((short*)(pResults+1))+6*i;
                        int x = p[0];
                        int y = p[1];
                        int w = p[2];
                        int h = p[3];
                        int neighbors = p[4];
                        int angle = p[5];

                        printf("face_rect=[%d, %d, %d, %d], neighbors=%d, angle=%d\n", x,y,w,h,neighbors, angle);

                        cvRectangle(iplImg, cvPoint(x,y), cvPoint(x+w, y+h), CV_RGB(0,0,255), 2);
                }

                cvShowImage("orig", iplImg);//放在绘图函数后,才会显示
                cvWaitKey(0);//等待绘图

                cvReleaseImage(&iplImg);
        }

        return 0;
}





回复 支持 反对

使用道具 举报

发表于 2015-10-30 11:59:34 | 显示全部楼层
第一页中的图片,Angle是怎么得出的?这三个函数里好像没看到呀
另外neighbors是什么?该定多大合适?我的意思是1-100还是30-50大概范围?
谁能解答一下,谢谢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-17 04:46 , Processed in 0.010969 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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