-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (58 loc) · 2.24 KB
/
Copy pathmain.cpp
File metadata and controls
72 lines (58 loc) · 2.24 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
68
69
70
71
72
#include <fstream>
#include <opencv2/opencv.hpp>
#include "filesystem_include.h"
#include "lane_detector.h"
using namespace std;
using namespace cv;
// Global variables for lane detection processing
static cv::Mat input_image;
static cv::Mat lane_line_mask;
static cv::Mat detected_line_image;
static cv::Mat reduced_line_image;
static cv::Mat output_image;
static bool lane_departure_warning;
static bool lane_detection_complete = false;
void laneDetectionThread() {
LaneDetector lane_detector;
while (true) {
std::vector<LaneLine> detected_lines = lane_detector.detectLaneLines(
input_image, lane_line_mask, detected_line_image,
reduced_line_image, lane_departure_warning);
lane_detection_complete = true;
}
}
int main(int argc, char** argv) {
// Start lane detection in separate thread
std::thread lane_detection_thread(laneDetectionThread);
lane_detection_thread.detach();
// Configuration paths
std::string input_folder_path = "../input_folder";
std::string output_folder_path = "output_folder";
std::string video_file_path = "../lane_line.mp4";
// Display window setup
cv::namedWindow("ADAS Camera View", cv::WINDOW_AUTOSIZE);
// Image blending parameters
double alpha = 0.6;
double beta = 1.0 - alpha;
VideoCapture video_capture(video_file_path);
cv::Mat processed_line_image;
// Display dimensions
int display_height = 500;
int display_width = 900;
while (true) {
video_capture >> input_image;
if (lane_detection_complete) {
cv::addWeighted(input_image, alpha, reduced_line_image, beta, 0.0, output_image);
// cv::resize(output_image, output_image, cv::Size(display_width, display_height));
// cv::imshow("ADAS Camera View", output_image);
} else {
output_image = input_image;
// cv::imshow("ADAS Camera View", input_image);
}
cv::resize(output_image, output_image, cv::Size(display_width, display_height));
cv::imshow("ADAS Camera View", output_image);
int key_code = cv::waitKey(30) & 0xff;
if (key_code == 27) break; // ESC key to exit
}
return 0;
}