Hello,I use the OPENMV H7 to load the code:
import sensor, image, time, lcd, gc
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.CIF)
sensor.set_windowing([0,0,136,200])
sensor.skip_frames(time = 2000)
clock = time.clock()
#Find the line function closest to the center of the field of view
def find_theline(lines):
min_dis = 100
for line in lines:
if (abs(line[0] - img.width()/2) < min_dis):
the_line = line
min_dis = abs(line[0] - img.width()/2)
return the_line
#=================================================================
#=================================================================
kernel_size = 1
kernel = [-1, -1, -1,\
-1, +8, -1,\
-1, -1, -1]
thresholds = [(0, 36)]
#=================================================================
while(True):
clock.tick()
img = sensor.snapshot().lens_corr(strength = 1.0,zoom = 1)
img.morph(kernel_size, kernel)
img.binary(thresholds)
img.erode(1, threshold = 2)
lines = img.get_regression([(0,36)], robust = True)
if (lines):
theline = find_theline(lines)
if(theline.magnitude() > 8):
rho_err = abs(theline.rho())-img.width()/2
print("rho_error:",rho_err)
img.draw_line(theline.line())
gc.collect()
print("fps:",clock.fps())
But why the IDE told me"‘line’ object isn’t iterable"?