-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcascadeCount.cpp
More file actions
44 lines (35 loc) · 1.07 KB
/
cascadeCount.cpp
File metadata and controls
44 lines (35 loc) · 1.07 KB
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
#include <iostream>
#include <string>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main( int argc, char **argv )
{
//First check for invalid number of inputs
if (argc < 2) {
cerr << "Invalid number of inputs" << endl;
return 0;
}
//Load the cascade classifier file
CascadeClassifier cascadeDetect;
string cascadeFile = "./banana_classifier.xml";
if (!cascadeDetect.load(cascadeFile)) {
cerr << "Error loading the classifier file" << endl;
return 0;
}
//Load the image that was passed in as the argument
Mat inFrame = imread(argv[1]);
if (inFrame.empty()) {
cerr << "Error loading the image that was passed in" << endl;
return 0;
}
//Do some preprocessing to the image
Mat procFrame;
cvtColor(inFrame, procFrame, CV_BGR2GRAY);
equalizeHist(procFrame, procFrame);
//Look for matches and store them into our vector
vector<Rect> detected;
cascadeDetect.detectMultiScale(procFrame, detected, 1.1, 2, 0, Size(80,80));
cout << "The number of faces detected: " << detected.size() << endl;
return 1;
}