正确的代码:
import sensor, image, time, pyb
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot().lens_corr(1.8)
circles = img.find_circles(threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10,
r_min = 2, r_max = 100, r_step = 2)
for c in circles:
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
if len(circles) > 0:
c0=circles[0].x()
print(c0)