-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacedet.cpp
More file actions
56 lines (43 loc) · 1.2 KB
/
facedet.cpp
File metadata and controls
56 lines (43 loc) · 1.2 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
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <stdio.h>
#include<deque>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<opencv2/core/core.hpp>
#include <opencv2/objdetect/objdetect.hpp>
using namespace cv;
using namespace std;
CascadeClassifier face_cscd;
Mat img;
int main(){
int count_person=0;
vector<Rect>face1;
vector<Rect>face2;
//face2[0].x=face2[0].y=face2[1].x=face1[1].y=1000;
VideoCapture vid(0);
//int LV=150;
if(!face_cscd.load("haarcascade_frontalface_alt.xml")){
cout<<"NOT LOADED"<<endl;
}
while(vid.isOpened()) {
int count=0;
while(count<12){
vid>>img;
count ++;
}
// Mat img=imread("faces.jpg");
face_cscd.detectMultiScale(img,face1,1.3, 2);
for(int i=0;i<face1.size();i++){
/* if(face2[0].x > face1[].x)
count_person++;*/
Point p1(face1[i].x,face1[i].y);
Point p2(face1[i].x+face1[i].height,face1[i].y+face1[i].width);
rectangle(img,p1,p2,Scalar(0,0,255),2);
}
namedWindow("IP",WINDOW_NORMAL);
imshow("IP",img);
//face2[0].x=face1[0].x;
//cout<<"NO. OF PERSONS="<<count_person<<endl;
waitKey(2);
}
}