比opencv还牛的,免费、高效的人脸检测函数


深圳大学计算机副教授于仕琪及其团队编写的人脸检测函数,包含动态链接库,函数的使用说明,以及函数的调用示例。可下载学习,并与opencv提供的函数进行对比
资源截图
代码片段和文件信息
#include 

#include “facedetect-dll.h“
#pragma comment(lib“libfacedetect.lib“)

using namespace cv;


void find_face1(Mat gray);
void find_face2(Mat gray);
void find_face3(Mat gray);

int main(int argc char* argv[])
{
//load an image and convert it to gray (single-channel)
Mat gray = imread(“4.jpg“ CV_LOAD_IMAGE_GRAYSCALE);
Mat show;
cvtColor(grayshow8);
if (gray.empty())
{
fprintf(stderr “Can not load the image file.
“);
return -1;
}
find_face1(gray);
find_face2(gray);
find_face3(gray);

waitKey(0);
return 0;
}

void find_face1(Mat gray)
{
Mat show;
cvtColor(gray show 8);

int * pResults = NULL;
pResults = facedetect_frontal((unsigned char*)(gray.ptr(0)) gray.cols gray.rows gray.step
1.2f 3 24);

printf(“%d frontal faces detected.
“ (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
“ x y w h neighbors);
rectangle(show Point(x y) Point(x + w y + h) Scalar(0 0 255) 2 8);
}
imshow(“facedetect_frontal“ show);
}
void find_face2(Mat gray)
{
Mat show;
cvtColor(gray show 8);

int * pResults = NULL;
pResults = facedetect_multiview_reinforce((unsigned char*)(gray.ptr(0)) gray.cols gray.rows gray.step
1.2f 5 24);
printf(“%d faces detected.
“ (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
“ x y w h neighbors);
rectangle(show Point(x y) Point(x + w y + h) Scalar(0 0 255) 2 8);
}
imshow(“facedetect_multiview_reinforce“ show);
}

void find_face3(Mat gray)
{
Mat show;
    cvtColor(gray show 8);

    int * pResults = NULL;
pResults = facedetect_frontal_tmp((unsigned char*)(gray.ptr(0)) gray.cols gray.rows gray.step
1.2f 5 24);
printf(“%d faces detected.
“ (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
“ x y w h neighbors);
rectangle(show Point(x y) Point(x + w y + h) Scalar(0 0 255) 2 8);
}
imshow(“facedetect_frontal_tmp“ show);
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)