erode 2 : 노이즈가 많이 사라졌지만 차선이 많이 얇아져서 끊기는 부분이 생김
open 1 : 큰 노이즈는 살아있다 + 차선이 조금 끊기는 느낌이...
open 2 : 큰 노이즈는 없어졌지만 기존의 얇았던 차선은 사라진다.
open 1 + close 1
Note
The number of iterations is the number of times erosion or dilatation operation will be applied. For instance, an opening operation (MORPH_OPEN) with two iterations is equivalent to apply successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
이진화 수행 후 가우시안 블러링 하기 전에 적용
가우시안 블러링 이후에 수행하면 블러 때문에 캐니에지에서 에지로 검출된다
if((slope < 0) && (x2 < frame.cols / 2))
else if((slope > 0) && (x1 > frame.cols /2))
if((slope < 0) && (x1 < frame.cols / 2))
else if((slope > 0) && (x2 > frame.cols /2))
if((slope < -0.1) && (x1 < frame.cols / 2))
else if((slope > 0.1) && (x2 > frame.cols /2))
if((lpos >= 0) && (k_under_limit < abs(left_slope)) && (abs(left_slope) < k_upper_limit)){
rpos = lpos + k_lane_width;
if(rpos > k_lane_width) rpos = k_frame_width;
right_slope = -left_slope;
right_intercept = k_offset - right_slope * rpos;
}
-그랬더니...이렇게 이상하게 예측...
if((lpos >= 0) && (k_under_limit < abs(left_slope)) && (abs(left_slope) < k_upper_limit)){
rpos = lpos + k_lane_width;
right_slope = -left_slope;
right_intercept = k_offset - right_slope * rpos;
if(rpos > k_lane_width) rpos = k_frame_width;
}
void calculatePos(const double& slope, const double& intercept, int32_t& pos, bool left = false, bool right = false)
{
if(cvRound(slope) == 0 && cvRound(intercept) == 0){
if (left)
pos = -1;
else if (right)
pos = frame_width << 1;
}
else{
pos = static_cast<int32_t>((offset - intercept)/ slope);
if (left){
if (pos < 0) pos = 0;
}
if (right){
if(pos > frame_width) pos = frame_width;
}
}
}
void estimatePos(double& left_slope, double& left_intercept, double& right_slope, double& right_intercept, int32_t& lpos, int32_t& rpos)
{
if((lpos < 0) && (rpos <= frame_width)){
if((0.6 < abs(right_slope)) && (abs(right_slope) < 1)){
lpos = rpos - lane_width;
left_slope = -right_slope;
left_intercept = offset - left_slope * lpos;
}
}
else if((rpos > frame_width) && (lpos >= 0)){
if((0.6 < abs(left_slope)) && (abs(left_slope) < 1)){
rpos = lpos + lane_width;
right_slope = -left_slope;
right_intercept = offset - right_slope * rpos;
}
}
}
else if((abs(slope) <= 0.15) && (x1 > k_frame_width/4) && (x1 < k_frame_width/4 * 3))
stop_lines.emplace_back(x1,y1,x2,y2);
else if((abs(slope) <= 0.15) && (x1 > k_frame_width/4) && (x2 < k_frame_width/4 * 3))
stop_lines.emplace_back(x1,y1,x2,y2);
else if((abs(slope) <= 0.15) && (x1 > k_frame_width/5) && (x2 < k_frame_width/5 * 4))
stop_lines.emplace_back(x1,y1,x2,y2);