-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (39 loc) · 1.23 KB
/
main.cpp
File metadata and controls
61 lines (39 loc) · 1.23 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
//c++ headers
#include <iostream>
#include <conio.h>
//include the created headers
#include "Vehicle.h"
int main()
{
Vehicle vehicle;
VideoCapture carVideo;
//open the video file
carVideo.open("carVideo7.mp4");
//check if the video was loaded properly
if (!carVideo.isOpened()) {
cout << "Couldn't load the video!\nExiting the program now..\n";
return -1;
}
//get the first frame from the video stream,may also add some additional error check
//to check if the video has atleast one frame.
vector <Blob> existingBlob;
vehicle.getFirstframe(carVideo, existingBlob);
while (1) {
//the below method to resize the video does work if
//you capture the video from the webcam but not if the video is loaded from local computer.
/*carVideo.set(CV_CAP_PROP_FRAME_WIDTH, 768);
carVideo.set(CV_CAP_PROP_FRAME_HEIGHT, 576);*/
//check if the video has ended and display a message to the user
if ((carVideo.get(CV_CAP_PROP_POS_FRAMES)+1) < carVideo.get(CV_CAP_PROP_FRAME_COUNT)) {
vehicle.trackVehicles();
}
else {
cout << "\nVideo ended...\nPress any key to exit the program now!";
_getch();
break;
}
//wait for some time between grabbing two successive frames
waitKey(20);
}
return 0;
}