国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

實時視頻人臉識別嘗試(使用ShiqiYu老師的人臉識別庫)

2019-11-11 04:17:05
字體:
來源:轉載
供稿:網友
使用ShiqiYu老師的 face landmark detection方法進行人臉識別與人臉轉動角度的計算,使用的是ShiqiYu老師在2017年1月更新的代碼。Github地址:https://github.com/ShiqiYu/libfacedetection其代碼較2015年的版本做了一些修改,其中提供了frontal,frontal-surveillance,multiview,multiview_reinforce四種方法。每種方法的耗費時間與檢測的人臉轉向的范圍有所不同,在Github中對其效果差異做了詳細說明。使用multiview_reinforce為例進行編寫,此次改動在調用函數中做了參數的修改需要注意。各個參數的含義如下:FACEDETECTDLL_API int * facedetect_multiview_reinforce(unsigned char * result_buffer, //buffer memory for storing face detection results, !!its size must be 0xC004 Bytes!!unsigned char * gray_image_data, int width, int height, int step, //input image, it must be gray (single-channel) image!float scale, //scale factor for scan windowsint min_neighbors, //how many neighbors each candidate rectangle should have to retain itint 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在提供的example例子上進行了修改,使用OpenCV接口讀取攝像頭的圖片,進行實時操作。代碼如下:
//2017.2.6    #include <stdio.h>  #include <opencv2/opencv.hpp>  #include "facedetect-dll.h"    #PRagma comment(lib,"libfacedetect.lib")  //#pragma comment(lib,"libfacedetect-x64.lib")    //define the buffer size. Do not change the size!  #define DETECT_BUFFER_SIZE 0x20000  using namespace cv;    void OnMouseAction(int event, int x, int y, int falgs, void *ustc);  bool stime = false;    int main(int argc, char* argv[])  {    	Mat gray;  	Mat frame;  	Mat new_frame;  	int resize_height = 480;  	int resize_width = 640;    	int * pResults = NULL;         unsigned char * pBuffer = (unsigned char *)malloc(DETECT_BUFFER_SIZE);      if(!pBuffer)      {          fprintf(stderr, "Can not alloc buffer./n");          return -1;      }  	VideoCapture capture(0);    	while (stime==false)  	{  		capture >> frame;  		cv::resize(frame, new_frame, cv::Size(resize_width, resize_height), (0.0), (0.0), cv::INTER_LINEAR);  		cvtColor(new_frame, gray, CV_BGR2GRAY);  		int doLandmark = 1;    		pResults = facedetect_multiview_reinforce(pBuffer, (unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, (int)gray.step,  			1.2f, 3, 24, 0, doLandmark);    		//printf("%d faces detected./n", (pResults ? *pResults : 0));  		Mat result_multiview_reinforce = new_frame.clone();;  		//print the detection results  		for (int i = 0; i < (pResults ? *pResults : 0); i++)  		{  			short * p = ((short*)(pResults + 1)) + 142 * 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);  			rectangle(result_multiview_reinforce, Rect(x, y, w, h), Scalar(0, 255, 0), 2);  			if (doLandmark)  			{  				for (int j = 0; j < 68; j++)  					circle(result_multiview_reinforce, Point((int)p[6 + 2 * j], (int)p[6 + 2 * j + 1]), 1, Scalar(0, 255, 0));  			}  		}  		imshow("Results_multiview_reinforce", result_multiview_reinforce);  		waitKey(30);  		setMouseCallback("Results_multiview_reinforce",OnMouseAction);  	}      //release the buffer      free(pBuffer);    	return 0;  }    void OnMouseAction(int event, int x, int y, int falgs, void *ustc)  {  	if (event==CV_EVENT_LBUTTONDOWN)  	{  		stime = true;  	}   	else  	{  		stime = false;   	}  } 效果圖如下:評價一下性能的話,識別效果確實不錯。不足點的話一是當人臉有部分遮擋、低頭或仰頭時無法識別,因此更適合應用于正面下人臉左右擺動識別,如各種身份確認等領域。不是用在安防等領域的檢測跟蹤的應用背景中。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 江津市| 涿州市| 成武县| 东乌| 安西县| 阳高县| 湖南省| 阿鲁科尔沁旗| 潜江市| 都兰县| 盐山县| 大同市| 广州市| 泊头市| 乾安县| 原平市| 盐亭县| 汉寿县| 讷河市| 开阳县| 扬州市| 德清县| 镇远县| 南涧| 江孜县| 灵宝市| 深泽县| 白河县| 中山市| 曲阜市| 时尚| 靖安县| 山阳县| 修文县| 佛山市| 龙口市| 右玉县| 望江县| 辽宁省| 喀喇沁旗| 会东县|