資源簡介
Opencv中文網(wǎng)Yu老師的人臉識別VS2015工程,opencv環(huán)境自己配置,Release下有可執(zhí)行文件。
代碼片段和文件信息
/*
The?MIT?License?(MIT)
Copyright?(c)?2015-2017?Shiqi?Yu
shiqi.yu@gmail.com
Permission?is?hereby?granted?free?of?charge?to?any?person?obtaining?a?copy
of?this?software?and?associated?documentation?files?(the?“Software“)?to?deal
in?the?Software?without?restriction?including?without?limitation?the?rights
to?use?copy?modify?merge?publish?distribute?sublicense?and/or?sell
copies?of?the?Software?and?to?permit?persons?to?whom?the?Software?is
furnished?to?do?so?subject?to?the?following?conditions:
The?above?copyright?notice?and?this?permission?notice?shall?be?included?in?all
copies?or?substantial?portions?of?the?Software.
THE?SOFTWARE?IS?PROVIDED?“AS?IS“?WITHOUT?WARRANTY?OF?ANY?KIND?EXPRESS?OR
IMPLIED?INCLUDING?BUT?NOT?LIMITED?TO?THE?WARRANTIES?OF?MERCHANTABILITY
FITNESS?FOR?A?PARTICULAR?PURPOSE?AND?NONINFRINGEMENT.?IN?NO?EVENT?SHALL?THE
AUTHORS?OR?COPYRIGHT?HOLDERS?BE?LIABLE?FOR?ANY?CLAIM?DAMAGES?OR?OTHER
LIABILITY?WHETHER?IN?AN?ACTION?OF?CONTRACT?TORT?OR?OTHERWISE?ARISING?FROM
OUT?OF?OR?IN?CONNECTION?WITH?THE?SOFTWARE?OR?THE?USE?OR?OTHER?DEALINGS?IN?THE
SOFTWARE.
*/
/*??API接口函數(shù)說明
int?*?facedetect_multiview(?unsigned?char?*?gray_image_data?int?width?int?height?int?step
float?scale
int?min_neighbors
int?min_size
int?max_size=0);
/*API
1.it?can?detect?side?view?faces?but?slower?than?facedetect_frontal().
facedetect_multiview
2.it‘s?fast?but?cannot?detect?side?view?faces
facedetect_frontal
3.it?can?detect?side?view?faces?better?but?slower?than?facedetect_multiview().
facedetect_multiview_reinforce
4.it?can?detect?faces?with?bad?illumination.
facedetect_frontal_surveillance
*/
#include?
#include?
#include?“facedetect-dll.h“
//#pragma?comment(lib“l(fā)ibfacedetect.lib“)
#pragma?comment(lib“l(fā)ibfacedetect-x64.lib“)
//define?the?buffer?size.?Do?not?change?the?size!
#define?DETECT_BUFFER_SIZE?0x20000
using?namespace?cv;
int?main(int?argc?char*?argv[])
{
//if?(argc?!=?2)?
//{
// printf(“Usage:?%s?\n“?argv[0]);
// return?-1;
//}
while?(1)
{
Mat?gray?image?dstImage;
//load?an?image?and?convert?it?to?gray?(single-channel)
/*??image?=?imread(argv[1]);*/
//image?=?imread(“00.jpeg“);//?keliamoniz1.jpg??face.jpeg
//if?(image.empty())
//{
// fprintf(stderr?“Can?not?load?the?image?file?%s.\n“?argv[1]);
// return?-1;
//}
VideoCapture?capture(0);????//從攝像頭讀入視頻
capture?>>?image;
//namedWindow(“原圖“?CV_WINDOW_AUTOSIZE);
//imshow(“原圖“?image);
cvtColor(image?gray?CV_BGR2GRAY);//轉(zhuǎn)化為灰度圖
equalizeHist(gray?gray);//直方圖均衡化,增加對比度方便處理
int?*?pResults?=?NULL;
//pBuffer?is?used?in?the?detection?functions.
//If?you?call?functions?in?multiple?threads?please?create?one?buffer?for?each?thread!
unsigned?char?*?pBuffer?=?(unsigned?char?*)malloc(DETECT_BUFFER_SIZE);?//動態(tài)內(nèi)存分配
if?(!pBuffer)
{
fprintf(stderr?“Can?no
- 上一篇:《微型計算機原理與接口技術第3版》馮博琴 教學課件
- 下一篇:射頻天線設計基礎
評論
共有 條評論