logo

识别车道线杂线太多求助

2019-11-16 21:44
6
n2zb
269c847f-d72d-48eb-93aa-3b05c76c93e0.jpg
2019-11-16 22:39
6
n2zb

能不能像巡线小车例程那样用线性回归返回直线

不过却需要返回多条line对象

我们需要两条直线对象计算偏转角度

mport sensor, image, time, math

min_degree = 0
max_degree = 179
theta_1=0
theta_2=0
i=0.00001
j=0.00001
THRESHOLD = (0,70)
# 导入 image

img = image.Image("F_example1.bmp", copy_to_fb=True).binary([THRESHOLD],invert=True)


# 添加画线的代码
for l in img.get_regression([(100,100,0,0,0,0)], robust = True):

       if (min_degree <= l.theta()) and (l.theta() <= max_degree):
           img.draw_line(l.line(), color = (255, 0, 0))
           if l.theta()<=90 :
               theta_1=theta_1+l.theta()
               i=i+1
           else:
               theta_2=theta_2+l.theta()
               j=j+1
lamb=math.atan((math.tan((theta_1/i/180)*math.pi)+math.tan((theta_2/j/180)*math.pi))/2)
lamb=lamb/math.pi*180
print(lamb)

sensor.flush()


![0_1573915063037_Fexample1.bmp](正在上传 100%) 

time.sleep(100)
![0_1573915001606_求助.bmp](正在上传 100%)
a64e5fa7-ded5-4e4f-8562-0c3b80be62f9.jpg
1e8063ba-6bce-4e09-aef0-3eb910dd036b.png
6
n2zb

第十六行这个100,100,0,0,0,0是什么意思

2019-11-18 18:52
I
网红小智智 星瞳科技

get_regression只能返回一条直线。

你可以分成左右两边分别调用get_regression