-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (33 loc) · 831 Bytes
/
main.cpp
File metadata and controls
48 lines (33 loc) · 831 Bytes
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
#include "src/MovingObjectDetector.h"
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main() {
std::string videoPath = "../human_1.mp4";
// Load an video from file
VideoCapture cap(videoPath);
if (!cap.isOpened()) {
cerr << "Error opening video file" << endl;
return -1;
}
MovingObjectDetector detector;
while (true) {
cv::Mat frame;
cap >> frame;
if (frame.empty()) {
break; // End of video
}
auto boxes = detector.detect(frame);
for (const auto &box : boxes) {
cv::rectangle(frame, box, cv::Scalar(0, 0, 255), 2);
}
cv::imshow("Detected moving objects", frame);
if (cv::waitKey(10) >= 0) {
break; // Exit on any key press
}
}
cap.release();
cv::destroyAllWindows();
return 0;
}