import sensor, image, time
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.B64X64) # or B40x30 or B64x64
clock = time.clock() # Tracks FPS.
old = sensor.snapshot()
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot()
[delta_x, delta_y, response] = old.find_displacement(img) #这句报的错
old = img.copy()
print("%0.1f X\t%0.1f Y\t%0.2f QoR\t%0.2f FPS" %(delta_x, delta_y, response, clock.fps()))
大佬