报错'Image' object has no attribute 'findlines',代码全部发出来了
enable_lens_corr = False # turn on for straighter lines...打开以获得更直的线条…
import sensor, image, time
from pyb import Pin, Timer
sensor.reset()
sensor.set_pixformat(sensor.RGB565) #灰度更快
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
light = Timer(2, freq=50000).channel(1, Timer.PWM, pin=Pin("P6"))
light.pulse_width_percent(50) # 控制亮度 0~100
clock = time.clock()
min_degree = 0
max_degree = 179
while(True):
clock.tick()
img = sensor.snapshot()
time.sleep_ms(1)
if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...
for l in img.find_lines(threshold = 1000, theta_margin = 25, rho_margin = 25):
if (min_degree <= l.theta()) and (l.theta() <= max_degree):
img.draw_line(l.line(), color = (255, 0, 0))
lines = img.findlines()
if lines:
line = l[0]
print(line.x1())
print("FPS %f" % clock.fps())