-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfaceMash.h
87 lines (61 loc) · 1.5 KB
/
faceMash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include "Filters.h"
#include "BufferContainer.h"
#include <opencv2/objdetect.hpp>
#include <opencv2/imgproc.hpp>
namespace FaceDetector
{
class cascadeDetector
{
BufferContainer::imageContainer pkg;
//flags..
bool pkg_avail;
int _process(bool detailed)
{
return faceMash(detailed);
}
protected:
int faceMash(bool fidelity=false)
{
cv::Mat image_(pkg.h,pkg.w,CV_8UC4,pkg.image);
//cv::namedWindow("wind",CV_WINDOW_NORMAL);
//cv::imshow("wind",image_);
//cv::waitKey(500);
cv::CascadeClassifier face("./classifier/haarcascade_frontalface_alt.xml");
assert(!face.empty());
cv::Mat tmp(image_.rows,image_.cols,image_.type());
image_.copyTo(tmp);
cv::Size size;
if(fidelity==false)
size=cv::Size(100,100);
else
size=cv::Size(50,50);
cv::Mat image_grey;
cvtColor(tmp,image_grey,cv::COLOR_BGR2GRAY);
// cv::imshow("wind",image_grey);
//cv::waitKey(500);
cv::equalizeHist(image_grey,image_grey);
std::vector<cv::Rect>detectedfaces;
face.detectMultiScale(image_grey,detectedfaces,1.2,3,0|cv::CASCADE_SCALE_IMAGE,size);
printf("\n\n%d",detectedfaces.size());
return detectedfaces.size();
}
public:
cascadeDetector()
{
pkg_avail=false;
}
void setParam(BufferContainer::imageContainer src)
{
pkg.setParams(src);
pkg_avail=true;
}
int detect(bool detail=false)
{
return _process(detail);
}
~cascadeDetector()
{
}
};
}