logo

用find_lines找直线并用draw_line将线画出,直线找到了线却没画出来。

2022-04-27 10:52
S
飞吧托利

代码如下:

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.XGA)
sensor.skip_frames(time = 2000)

clock = time.clock()

while(True):
    clock.tick()
    #img = sensor.snapshot()
    #img.lens_corr(1.8)
    img = image.Image('1new.bmp',copy_to_fb=True)
    for l in img.find_lines(roi=(531,100,116,124),x_stride=3,threshold =1000, theta_margin = 25, rho_margin = 25):
        img.draw_line(l.line(), color = (255, 0, 0))
        #a=(l.theta()-90)*0.167
       # a=l.theta()
        #print(a)
        print(l)
    #img.draw_line((646,103,539,223),color=(255,0,0))
38908a55-334a-4df1-a2e6-67d119c4f4e8.png

代码中若直线被检测到,会由print(l)将直线打印,可以看到程序运行后有直线信息被打印,说明直线有被检测到,但是却没有直线画出

2022-04-27 19:50
I
网红小智智 星瞳科技

其实是画出来了,只是没更新到IDE。如果你用img.save()就会看到。

因为其实是每次调用sensor.snapshot()才会把上次的图像发送到IDE

2022-04-27 19:59
S
飞吧托利
d8fc449e-60e1-437a-b7c0-28be0ccb4d9a.png

为啥用了img.save报错了

2022-04-27 20:49
I
网红小智智 星瞳科技

img.save("a.jpg")

或者

img.save("a.bmp")