Hi, I’ve been working on the optical flow stuff all weekend and majorly overhauled everything. I’ve got translation optical flow working at 43 FPS on a 64x64 image. Let me know if you want the code and scripts right now for that.
As for rotation/scale… I put the code in for that but after reading some papers I realized that I did it in a rather weak way. So, I need to go back and redo the code somewhat.
Basically, I put this in:
1: Take logpolar() of image1/2
2: Take FFT of both images above.
3: Cross power spectrum.
4. Inverse FFT.
5. Find the peak.
This works for finding rotation/scale changes between two images as long as they have no translation…
However, you can do better:
- Take the FFT of image1/2
- Get the magnitude of both FFTs (this results in translation info being tossed)
- LogPolar convert the two FFTs.
- Take the FFT of both logpolar FFTs magnitudes.
- Cross power spectrum.
- Inverse FFT.
- Find the peak.
This gives you the rotation/scale without translation affecting the image output. However, it also requires 2 more FFTs… anyway, it will be for the best.
I’ll also add some scripts showing how to then take the above info… de-rotate and de-scale the secondary image… and run the regular translation detection method to extract translation without having to worry about scale and rotation.
That said, expect this all to run at like 10 FPS on the M7. However, at a 32x32 image we may be able to hit 20 FPS. With the H7 coming later this year we’ll be able to get much higher speeds (and global shutter imaging).
This is actually kinda of exciting. Having a script that does the full pipeline is really powerful. No one really has any thing available like this. While 32x32 or even 16x16 may sound like a low resolution you don’t need many pixels for this algorithm to work well if you’re doing differential estimation between the current and previous image. You just need a lot of speed.