I picked up an M7 to make a proof-of-concept of a tire slip angle sensor. The camera needs to be able to detect a dx/dy of the road surface moving beneath the car. The code right now is REALLY simple as I am still learing uPython, this camera, and ARM.
import sensor, image, time, pyb, utime
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.B64x64)
sensor.skip_frames(time = 2000)
clock = time.clock()
oldImage = sensor.snapshot().mean_pooled(4, 4)
while(True):
clock.tick()
newImage = sensor.snapshot().mean_pooled(4, 4)
x,y,c = newImage.find_displacement(oldImage)
oldImage = newImage
print("dx: %10f dy: %10f confidence: %10f FPS: %f time: %d" % (x, y, c, clock.fps(), utime.ticks_ms()))
Like I said, real simple.
The camera is about 4" off of the desk and is moved back and forth about 18" over a 5 second period. The desk that I’m testing on is unfinished plywood so there is definition in the surface. I ploted the data in Excel to see the measured displacement and it looks like statistical noise (I’ve attached the graphs).
Am I missing something here? Am I using find_displacement() correctly?