-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount.cpp
More file actions
67 lines (55 loc) · 1.5 KB
/
count.cpp
File metadata and controls
67 lines (55 loc) · 1.5 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
57
58
59
60
61
62
63
64
65
66
67
#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>
#include<string>
#include<sstream>
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[1].x=1000;
int prev=1000;
VideoCapture vid("video.mp4");
//int LV=150;
if(!face_cscd.load("haarcascade_frontalface_alt.xml")){
cout<<"NOT LOADED"<<endl;
}
while(vid.isOpened()) {
int count=0;
while(count<10){
vid>>img;
count ++;
}
// Mat img=imread("faces.jpg");
face_cscd.detectMultiScale(img,face1,1.3, 7);
for(int i=0;i<face1.size();i++){
if(prev > face1[i].x){
count_person++;
prev=face1[i].x;
}
else
prev = face1[i].x;
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,255,0),2);
}
// cout<<"DONE"<<endl;
namedWindow("IP",WINDOW_AUTOSIZE);
Point P(100,200);
cout<<"NO. OF PERSONS="<<count_person<<endl;
char c=(char)(count_person)+'0';
cout<<c<<endl;
string out=("NO. OF VISITORS=");out[16]=c;out[17]='\0';
putText(img,out,P,FONT_HERSHEY_DUPLEX,2,Scalar(255,255,255),3);
imshow("IP",img);
waitKey(10);
}
}