-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
53 lines (42 loc) · 1.34 KB
/
main.cpp
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
#include <iostream>
#include <opencv2/objdetect.hpp>
#include "Header Files/Detection.hpp"
using namespace std;
int main() {
CascadeClassifier carCascade, pedCascade, bikeCascade;
carCascade.load("Resources/cars.xml");
pedCascade.load("Resources/pedestrian.xml");
bikeCascade.load("Resources/two_wheeler.xml");
string path = "Resources/test2.mp4";
// Create a VideoCapture object and open the input file
// If the input is the web camera, pass 0 instead of the video file name
VideoCapture cap(path);
// Check if camera opened successfully
if(!cap.isOpened()){
cout << "Error opening video stream or file" << endl;
return -1;
}
while(1){
Mat frame;
// Capture frame-by-frame
cap >> frame;
// If the frame is empty, break immediately
if (frame.empty())
break;
// Detect cars
detectCars(frame, carCascade);
// Detect Pedestrians
detectPedestrians(frame, pedCascade);
// Detect Bikes
detectBikes(frame, bikeCascade);
// Press ESC on keyboard to exit
char c=(char)waitKey(25);
if(c==27)
break;
}
// When everything done, release the video capture object
cap.release();
// Closes all the frames
destroyAllWindows();
return 0;
}