import sensor, image, time
line_threshold = (2, 51, -21, 65, -17, 18)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(10)
sensor.set_auto_whitebal(False)
clock = time.clock()
def find_max(blobs):
max_size=0
for blob in blobs:
if blob[2]*blob[3] > max_size:
max_blob=blob
max_size = blob[2]*blob[3]
return max_blob
while(True):
clock.tick()
img = sensor.snapshot()
blobs = img.find_blobs([line_threshold], x_stride=10)
if blobs:
max_blob=find_max(blobs)
if int(max_blob.w()/max_blob.h())>5 and max_blob.w()>200:
img.draw_rectangle(max_blob[0:4])
img.draw_cross(max_blob[5], max_blob[6])
print(max_blob[5], max_blob[6])
print(clock.fps())https://forum.singtown.com/topic/3865/sensor-qvga%E5%A6%82%E4%BD%95%E5%9C%A8%E7%A8%8B%E5%BA%8F%E4%B8%AD%E9%80%94%E8%BD%AC%E6%8D%A2%E6%88%90sensor-vga%E7%9A%84%E5%BD%A2%E5%BC%8F
sensor.set_framesize(sensor.QVGA)
改为
sensor.set_framesize(sensor.QQVGA)