LibFaceDetection开源库介绍与使用 LibFaceDetection开源库介绍与使用

LibFaceDetection开源库介绍与使用

unsigned char * result_buffer // 缓冲区,大小必须为0x20000个字节。buffer memory for storing face detection results, !!its size must be 0x20000 Bytes!!
unsigned char * gray_image_data // 单通道灰色图像(YUV数据中的Y)
int width // 单通道灰色图像的宽度
int height // 单通道灰色图像的高度
int step // 单通道灰色图像的step参数,同单通道灰色图像的宽度,input image, it must be gray (single-channel) image!
float scale // 每次缩小图像的比例,不建议修改(default: 1.2f),scale factor for scan windows
int min_neighbors // 检测出的人脸框属性,越大表示是人脸可能性越大.小于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 // 数据源中近乎最大的人脸大小,若存在人脸大小比此数据还大的则忽略不检测.若此数据被指定为0, 程序会自动确认可能的最大的人脸大小.
// Maximum possible face size.Faces larger than that are ignored.It is the largest posible when max_object_width = 0.
int doLandmark = 0 // 是否进行人脸特征点检测 0: 不进行人脸特征点检测1: 进行人脸特征点检测 landmark detection
/

下面介绍一下四个API的不同:

/
正面人脸检测,无法检测“侧视人脸”和“单面人脸”
int * facedetect_frontal(…)
正面视频监控人脸检测,无法检测“侧视人脸”和“单面人脸”,可以检测光线不好情况下的人脸
int *facedetect_frontal_surveillance(…)
多视图人脸检测,无法检测“单面人脸”,但可以检测“侧视人脸”,可以检测多张人脸,比facedetect_frontal()检测时间长
int *facedetect_multiview(…)
多视图增强人脸检测,无法检测“单面人脸”,但可以检测“侧视人脸”, 可以检测多张人脸;比facedetect_multiview()效果好,但是检测时间长
int *facedetect_multiview_reinforce(…)
*/

返回值介绍:

比如返回值为int *pResults;

pResults为空代表检测失败。如果pResults不为空,*pResults为0,代表检测成功但未检测到人脸;如果pResults不为空,*pResults不为0,*pResults代表检测到的人脸个数。

具体人脸属性参数请看下面代码:

if (NULL == pResults)
{
//printf("—Detect Failed !\n");
}
else
{
if (0 == (*pResults))
{ //No Face
//printf("—Detect success, but no face here.\n");
}
else
{
//Got Face,
//得到每个人脸的位置及宽度高度,眼睛关注角度(左正右负,正脸角度为0),置信度(越大人脸的可能性越大)
for (int i = 0; i < (pResults ? pResults : 0); i++)
{
short * p = ((short
)(pResults + 1)) + 142 * i;
FaceFrame stFaceFrame;
//得到人脸的位置及宽度高度
stFaceFrame.x = p[0];
stFaceFrame.y = p[1];
stFaceFrame.width = p[2];
stFaceFrame.height = p[3];
		//置信度(越大人脸的可能性越大)
		stFaceFrame.neighbors = p[4];
		//眼睛关注角度(左正右负,正脸角度为0)
		stFaceFrame.angle = p[5];

		// 得到人脸的特征点
		for (int j = 0; j &lt; 68; j++)
		{
			//printf("FaceID : %d, Point No : %d, x = %d, y = %d\n", i, j, 
			//(int)p[6 + 2 * j], (int)p[6 + 2 * j + 1]);
		}
	}
}

}


猜你喜欢

转载自blog.csdn.net/m0_37192554/article/details/84103460