代码如下:
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))
代码中若直线被检测到,会由print(l)将直线打印,可以看到程序运行后有直线信息被打印,说明直线有被检测到,但是却没有直线画出
其实是画出来了,只是没更新到IDE。如果你用img.save()就会看到。
因为其实是每次调用sensor.snapshot()才会把上次的图像发送到IDE

为啥用了img.save报错了
img.save("a.jpg")
或者
img.save("a.bmp")