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

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

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

2019-11-11 04:58:51
字體:
供稿:網(wǎng)友
使用ShiqiYu老師的 face landmark detection方法進(jìn)行人臉識(shí)別與人臉轉(zhuǎn)動(dòng)角度的計(jì)算,使用的是ShiqiYu老師在2017年1月更新的代碼。Github地址:https://github.com/ShiqiYu/libfacedetection其代碼較2015年的版本做了一些修改,其中提供了frontal,frontal-surveillance,multiview,multiview_reinforce四種方法。每種方法的耗費(fèi)時(shí)間與檢測(cè)的人臉轉(zhuǎn)向的范圍有所不同,在Github中對(duì)其效果差異做了詳細(xì)說明。使用multiview_reinforce為例進(jìn)行編寫,此次改動(dòng)在調(diào)用函數(shù)中做了參數(shù)的修改需要注意。各個(gè)參數(shù)的含義如下: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例子上進(jìn)行了修改,使用OpenCV接口讀取攝像頭的圖片,進(jìn)行實(shí)時(shí)操作。代碼如下:
//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;   	}  } 效果圖如下:評(píng)價(jià)一下性能的話,識(shí)別效果確實(shí)不錯(cuò)。不足點(diǎn)的話一是當(dāng)人臉有部分遮擋、低頭或仰頭時(shí)無法識(shí)別,因此更適合應(yīng)用于正面下人臉左右擺動(dòng)識(shí)別,如各種身份確認(rèn)等領(lǐng)域。不是用在安防等領(lǐng)域的檢測(cè)跟蹤的應(yīng)用背景中。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 吉首市| 长沙市| 四子王旗| 宁夏| 响水县| 黑河市| 嘉峪关市| 名山县| 平阴县| 乌兰县| 南康市| 汝州市| 中方县| 濮阳市| 桂阳县| 通许县| 平昌县| 大冶市| 建宁县| 义乌市| 伊金霍洛旗| 广东省| 思茅市| 嘉兴市| 大足县| 澄江县| 江源县| 南昌县| 台南市| 德兴市| 乐清市| 松阳县| 龙江县| 扎赉特旗| 蛟河市| 通化县| 海南省| 金寨县| 武鸣县| 鸡泽县| 白山市|