我在恶劣天气下使用条件随机场(CRF)进行多车道检测。但是,生成的超级标记会在输出图像上产生假正曲线。
第二,EKF似乎无法很好地跟踪生成的超级标记。
我需要更改一些阈值和参数吗?
下面是车道检测代码的片段:
#pragma warning(disable: 4819)
#include "opencv.hpp"
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include "LaneDetection.h"
// Lane marking definition
#define MAX_LANE_MARKING 3000
#define MAX_LW_N 55//40 // Max lane width, nearest
#define MAX_LW_F 12//8 // Max lane width, farest
#define MAX_LW_D 10 // Max lane width, delta
#define MIN_LW_N 20 // Min lane width, nearest
#define MIN_LW_F 2 // Min lane width, farest
#define SCAN_INTERVAL1 1 //lower
#define SCAN_INTERVAL2 1 //upper
// Lane Marking Grouping
#define MAX_LANE_SEED 300
#define SEED_MARKING_DIST_THRES 90
#define VALID_SEED_MARKING_NUMBER_THRES 6
#define LOW_LEVEL_ASS_THRES 1.96
// Initializing variables depending on the resolution of the input image.
double valueAt(std::vector<float>& f, float x) {
float ans = 0.f;
for (int i = (int)f.size() - 1; i >= 0; --i)
ans = ans * x + f[i];
return ans;
}
bool LaneDetection::initialize_variable(cv::Mat in_img) {
// Image variable setting
cv::Mat img_src = in_img;
//cv::Mat img_src = cv::imread(img_name);
if (img_src.empty()) {
std::cout << "Err: Cannot find an input image for initialization: " << std::endl;
return false;
}
img_size = img_src.size();
img_height = img_src.rows;
img_width = img_src.cols;
img_roi_height = (int)(img_size.height*0.5);
img_depth = img_src.depth();
max_lw.resize(img_height);
min_lw.resize(img_height);
max_lw_d.resize(img_width);
// Estimated Lane Width
for (int hh = img_roi_height; hh < img_height; ++hh) {
max_lw[hh] = (int)((MAX_LW_N - MAX_LW_F)*(hh - img_roi_height) / (img_size.height - img_roi_height) + MAX_LW_F);
min_lw[hh] = (int)((MIN_LW_N - MIN_LW_F)*(hh - img_roi_height) / (img_size.height - img_roi_height) + MIN_LW_F);
}
int w = img_width - 1;
while (img_width - 1 - w < w) {
max_lw_d[w] = (int)(MAX_LW_D*(abs(w - (img_width - 1) / 2.0)) / ((img_width - 1) / 2.0));
max_lw_d[img_width - 1 - w] = (int)(MAX_LW_D*(abs(w - (img_width - 1) / 2.0)) / ((img_width - 1) / 2.0));
w--;
}
return true;
}
整个代码都托管在Google云端硬盘link上。