import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_whitebal(False)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot().lens_corr(1.8)
thr = img.histogram().get_threshold()
# print('threshold',thr[0])
# img.binary([(thr[0],255)])
img = img.binary([(0,thr[0])])
blob0 = img.find_blobs([(255,255)],pixel_threshold = 4000)
print(blob0)
lin = img.get_regression([(thr[0],255)], roi = (70,0,180,240))
# if (blob0):
# img.draw_rectangle((277, 0, 43, 69), color = 127)
if (lin):
img.draw_line(lin.line(), color = 127)
print(lin)识别到的图像如下:

打印出来的结果如下:
[{"x":100, "y":0, "w":85, "h":240, "pixels":16918, "cx":146, "cy":112, "rotation":1.518160, "code":1, "count":1, "perimeter":744, "roundness":0.091413},
{"x":268, "y":0, "w":52, "h":69, "pixels":2353, "cx":300, "cy":28, "rotation":1.209709, "code":1, "count":1, "perimeter":375, "roundness":0.503028},
{"x":315, "y":69, "w":5, "h":3, "pixels":10, "cx":318, "cy":70, "rotation":2.727168, "code":1, "count":1, "perimeter":10, "roundness":0.332269},
{"x":181, "y":83, "w":2, "h":21, "pixels":35, "cx":182, "cy":93, "rotation":1.556911, "code":1, "count":1, "perimeter":42, "roundness":0.014494}]
{"x1":140, "y1":0, "x2":153, "y2":239, "length":239, "magnitude":2, "theta":177, "rho":-140}
[{"x":100, "y":0, "w":85, "h":240, "pixels":16919, "cx":146, "cy":112, "rotation":1.517971, "code":1, "count":1, "perimeter":741, "roundness":0.091471},
{"x":268, "y":0, "w":52, "h":69, "pixels":2317, "cx":300, "cy":27, "rotation":1.202760, "code":1, "count":1, "perimeter":418, "roundness":0.512365},
{"x":181, "y":83, "w":2, "h":20, "pixels":33, "cx":182, "cy":92, "rotation":1.562700, "code":1, "count":1, "perimeter":40, "roundness":0.015920}]
{"x1":140, "y1":0, "x2":153, "y2":239, "length":239, "magnitude":2, "theta":177, "rho":-140}
非常感谢各路大神指导
pixel_threshold 改为 pixels_threshold
@kidswong999 谢谢