Page 1 of 1


Posted: Mon Sep 25, 2017 11:49 am
by mcenhillk
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.

Code: Select all

import sensor, image, time, pyb, utime

sensor.skip_frames(time = 2000)
clock = time.clock()

oldImage = sensor.snapshot().mean_pooled(4, 4)

    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).
dx-dy.png (22.33 KiB) Viewed 1252 times

Am I missing something here? Am I using find_displacement() correctly?

Re: find_displacement()

Posted: Mon Sep 25, 2017 12:15 pm
by kwagyeman
The output is really noisy by default. If you want to Clean the noise up use int() on the floating point outputs to convert them to decimal and it will work like you think.

I was trying to output the data like an accelerometer but that's probably too advanced for folks.

Re: find_displacement()

Posted: Mon Sep 25, 2017 12:17 pm
by kwagyeman
The reason it's so noisy is because someone wanted sub pixel accuracy. So it's trying to interpolate a position between pixels. This is highly affected by noise.

Re: find_displacement()

Posted: Mon Sep 25, 2017 3:54 pm
by mcenhillk
int(dy).png (11.7 KiB) Viewed 1246 times
Ok, that's a little better. The orange dots are the 'dy' output, and the green/red dots are confidence level (red if <= 0.2).

The good news, I had to slow down the loop. Hopefully this means the camera will work going 80 mph 4" above concrete. :)

The bad news, I might have to pull out my stats book to figure out how to clean the data. :cry:

Thanks for the help and the OpenMV project!

:edit: Instead of the stats book I should probably be looking at a kalman filter, especially since you wanted this to behave like an accelerameter. W00t! I've been looking for an excuse to learn those! :D

Re: find_displacement()

Posted: Sat Feb 16, 2019 1:31 pm
by jez
Sounds really cool, did you make any progress on this?