-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchanges.txt
executable file
·54 lines (44 loc) · 1.17 KB
/
changes.txt
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
add these at end of ransac
if(a_gl >= img.cols/2 && (a_gl + w_gl) >= img.cols/2)
w_gl = 10001;
if(a_gl < img.cols/2 && (a_gl + w_gl) < img.cols/2)
w_gl = 10002;
if (fabs(w_gl) < 225) w_gl = 10003;
//detecting horizontal lanes
vector<Vec4i> lines;
HoughLinesP(mario, lines,1, CV_PI/180, 80, 30, 10);
for (int i = 0; i < lines.size(); i++) {
double angle = atan(lines[i][1] - lines[i][3])/(lines[i][0] - lines[i][2]);
if (fabs(angle) < degree_for_horizontal*PI/180) {
way.clear();
if (is_prev_single_left) {
way.push_back(3*mario.cols/4);
way.push_back(mario.rows - (lines[i][1] + mario.rows)/2);
way.push_back(0);
break;
}
else {
way.push_back(mario.cols/4);
way.push_back(mario.rows - (lines[i][1] + mario.rows)/2);
way.push_back(PI);
break;
}
}
}
change centroid function to this:
Point centroid(Mat img, double a, double lam)
{
double sum_x = 0;
int no_of_x = 0;
for (int j = 0; j < img.rows; j++) {
float y = img.rows-j;
float x = y*y/lam + a;
if (x < 0 || x >= img.cols) continue;
sum_x += x;
no_of_x++;
}
Point centroid;
centroid.x = sum_x/no_of_x;
centroid.y = img.rows/2;
return centroid;
}