資源簡(jiǎn)介
基于opencv,在追蹤人臉的基礎(chǔ)上自動(dòng)在人臉上打上馬賽克
代碼片段和文件信息
#include?“StdAfx.h“
#include?“opencv2/objdetect/objdetect.hpp“
#include?“opencv2/highgui/highgui.hpp“
#include?“opencv2/imgproc/imgproc.hpp“
#include?
#include?
using?namespace?std;
using?namespace?cv;
/**?Function?Headers?*/
void?detectAndDisplay(?Mat?frame?);
/**?Global?variables?*/
String?face_cascade_name?=?“l(fā)bpcascade_frontalface.xml“;
String?eyes_cascade_name?=?“haarcascade_eye_tree_eyeglasses.xml“;
CascadeClassifier?face_cascade;
CascadeClassifier?eyes_cascade;
string?window_name?=?“Capture?-?Face?detection“;
RNG?rng(12345);
/**?@function?main?*/
int?main(?int?argc?const?char**?argv?)
{
??CvCapture*?capture;
??Mat?frame;
??//--?1.?Load?the?cascade
??if(?!face_cascade.load(?face_cascade_name?)?){?printf(“--(!)Error?loading\n“);?return?-1;?};
??//--?2.?Read?the?video?stream
??capture?=?cvCaptureFromCAM(?-1?);
??if(?capture?)
??{
????while(?true?)
????{
??????frame?=?cvQueryframe(?capture?);
??????//--?3.?Apply?the?classifier?to?the?frame
??????if(?!frame.empty()?)
???????{?detectAndDisplay(?frame?);?
- 上一篇:命名管道 vc
- 下一篇:opencv數(shù)字識(shí)別.cpp
評(píng)論
共有 條評(píng)論