資源簡介
詳細內容見博客:https://blog.csdn.net/li_wen01/article/details/78369751

代碼片段和文件信息
#include?“opencv2/objdetect.hpp“
#include?“opencv2/highgui.hpp“
#include?“opencv2/imgproc.hpp“
#include?
using?namespace?std;
using?namespace?cv;
#define?IMAGE_NAME “01.jpg“
void?detectAndDraw(?Mat&?img?CascadeClassifier&?cascade
????????????????????CascadeClassifier&?nestedCascade
????????????????????double?scale?bool?tryflip?);
string?cascadeName;
int?main(?int?argc?const?char**?argv?)
{
????VideoCapture?capture;
????Mat?frame?image;
????string?inputName;
????bool?tryflip;
????CascadeClassifier?cascade?nestedCascade;
????double?scale?=?1.3;
????if(?!cascade.load(“./haarcascade_frontalface_alt2.xml“)?)
????{
????????cerr?<“ERROR:?Could?not?load?classifier?cascade“?<????????return?-1;
????}
????image?=?imread(IMAGE_NAME?1?);
????if(?!image.empty()?)
????{
????????detectAndDraw(?image?cascade?nestedCascade?scale?tryflip?);
????????//waitKey(0);
????}
????
????return?0;
}
void?detectAndDraw(?Mat&?img?CascadeClassifier&?cascade
????????????????????CascadeClassifier&?nestedCascade
????????????????????double?scale?bool?tryflip?)
{
????double?t?=?0;
????vector?faces?faces2;
????const?static?Scalar?colors[]?=
????{
????????Scalar(25500)
????????Scalar(2551280)
????????Scalar(2552550)
????????Scalar(02550)
????????Scalar(0128255)
????????Scalar(0255255)
????????Scalar(00255)
????????Scalar(2550255)
????};
????Mat?gray?smallImg;
????cvtColor(?img?gray?COLOR_BGR2GRAY?);
????double?fx?=?1?/?scale;
????resize(?gray?smallImg?Size()?fx?fx?INTER_LINEAR?);
????equalizeHist(?smallImg?smallImg?);
????t?=?(double)getTickCount();
????cascade.detectMultiScale(?smallImg?faces
????????1.1?2?0
????????//|CASCADE_FIND_BIGGEST_object
????????//|CASCADE_DO_ROUGH_SEARCH
????????|CASCADE_SCALE_IMAGE
????????Size(30?30)?);
????t?=?(double)getTickCount()?-?t;
????printf(?“detection?time?=?%g?ms\n“?t*1000/getTickFrequency());
????
for?(?size_t?i?=?0;?i?????{
????????Rect?r?=?faces[i];
#if?0
printf(“face?num?=?%d?\n“(int)i);
cout?<“矩形左上角的橫坐標:“?< cout?<“矩形左上角的縱坐標:“?< cout?<“矩形的寬度:“?< cout?<“矩形的高度:“?< cout?<“矩形的尺寸:“?< cout?<“矩形的面積:“?< cout?<“矩形左上角的點坐標:“?< cout?<“矩形右下角的點坐標:“?< cout?<#endif
if(3600? {
Mat?roi=?img(Rect(r.x*(scale-0.1)?r.y*(scale-0.1)?r.width*(scale+0.2)r.height*(scale+0.3)));
Mat?img1;
roi.copyTo(img1);
//namedWindow(“gag“1);
imwrite(“Roi.jpg“img1);
//imshow(“face“img1);
}
????????Scalar?color?=?colors[i%8];
????????????rectangle(?img?cvPoint(cvRound(r.x*(scale))?cvRound(r.y*(scale)))
???????????????????????cvPoint(cvRound((r.x?+?r.width-1)*scale)?cvRound((r.y?+?r.height-1)*scale))
???????????????????????color?3?8?0);
????????
????}
????//imshow(?“result“?img?);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????237750??2018-11-25?12:27??OpenCV\arm_test\001.jpg
?????文件???????3084??2018-10-19?09:48??OpenCV\arm_test\example.cpp
?????文件?????601661??2018-10-19?08:51??OpenCV\arm_test\haarcascade_eye_tree_eyeglasses.xm
?????文件?????540616??2017-10-17?19:00??OpenCV\arm_test\haarcascade_frontalface_alt2.xm
?????文件???????3153??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cv.h
?????文件???????2649??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cv.hpp
?????文件???????2523??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cvaux.h
?????文件???????2374??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cvaux.hpp
?????文件???????2176??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cvwimage.h
?????文件???????2424??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cxcore.h
?????文件???????2443??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cxcore.hpp
?????文件???????2257??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cxeigen.hpp
?????文件????????129??2017-10-18?10:09??OpenCV\arm_test\include\opencv\cxmisc.h
?????文件???????2226??2017-10-18?10:09??OpenCV\arm_test\include\opencv\highgui.h
?????文件???????2145??2017-10-18?10:09??OpenCV\arm_test\include\opencv\ml.h
?????文件???????2369??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\calib3d\calib3d.hpp
?????文件??????20138??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\calib3d\calib3d_c.h
?????文件?????122181??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\calib3d.hpp
?????文件??????15392??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\affine.hpp
?????文件??????26644??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\ba
?????文件????????723??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\bufferpool.hpp
?????文件???????2366??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\core.hpp
?????文件?????131224??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\core_c.h
?????文件???????8327??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\cuda\block.hpp
?????文件??????24756??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\cuda\border_interpolate.hpp
?????文件??????15518??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\cuda\color.hpp
?????文件???????3814??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\cuda\common.hpp
?????文件???????4720??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\cuda\datamov_utils.hpp
?????文件?????222523??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\cuda\detail\color_detail.hpp
?????文件??????15400??2017-10-18?10:09??OpenCV\arm_test\include\opencv2\core\cuda\detail\reduce.hpp
............此處省略248個文件信息
- 上一篇:NIKON D800 SDK 開發包 尼康
- 下一篇:工業防火墻白皮書
評論
共有 條評論