Find displacement on M4

Discussion related to "under the hood" OpenMV topics.
bizart
Posts: 1
Joined: Wed Oct 31, 2018 2:16 pm

Find displacement on M4

Postby bizart » Wed Oct 31, 2018 2:59 pm

Dear OpenMV team,

recently I came back to your great project, looking for fast implementation of optical flow. Find_displacement() function was looking promising, so I grab "old" M4 board laying around from couple of years.
According to: viewtopic.php?f=6&t=944 you have dropped support for M4, which in my opinion is slightly disappointing, so I decide to check if it is possible to run find_displacement() with all its dependencies on my old board until waiting for newly purchased couple of M7.

Getting deeper in your implementation, admire your work of clean coding. Although there are clean definitions of used modules, I would suggest following same concept for all used / unused modules, so slightly more advanced user can decide which module to use and fit even on "restricted" space revisions.

I have found that some math functions used by find_displacement() are in apriltags.c behind definition #define IMLIB_ENABLE_APRILTAGS, so probably not best place for those..
Finally find_displacement() works satisfactory on M4 board achieving approx. 25FPS on B64X64.

I am attaching couple of rough modifications if anyone is interested in running find_displacement() on older M4 boards.

imlib_config_OPENMV2.h
(2.46 KiB) Downloaded 4 times
apriltag_OPENMV2.c
(432.54 KiB) Downloaded 5 times
py_image_OPENMV2.c
(265.93 KiB) Downloaded 3 times
Rename and replace according files for OPENMV2 in:
/src/omv/boards/OPENMV2/imlib_config.h
/src/omv/img/apriltag.c
/src/omv/py/py_image.c

Running fft analysis for finding translation, rotation, scale is pretty advanced approach, although running fft on small bins is inaccurate to achieve acceptable accuracy.
For my purposes I have implemented new function compute_flow() which gives better results for robust and fast optical flow estimation at approx. 90FPS on M7.
If anyone is interested, I can share how to include new functions into micropython and OpenMV (it would be great if there is such tutorial)

Keep up good work!

Cheers
User avatar
iabdalkader
Posts: 595
Joined: Sun May 24, 2015 3:53 pm

Re: Find displacement on M4

Postby iabdalkader » Wed Oct 31, 2018 7:32 pm

According to: viewtopic.php?f=6&t=944 you have dropped support for M4, which in my opinion is slightly disappointing,
We didn't, we still support the M4 in every new firmware release. However we can only fix bugs for the M4, we can't add any new feature because we ran out of FLASH and RAM. We're Not doing this on purpose, the F7 and H7 are selling just fine, it's just the M4 limits.
Getting deeper in your implementation, admire your work of clean coding. Although there are clean definitions of used modules, I would suggest following same concept for all used / unused modules, so slightly more advanced user can decide which module to use and fit even on "restricted" space revisions.
I have found that some math functions used by find_displacement() are in apriltags.c behind definition #define IMLIB_ENABLE_APRILTAGS, so probably not best place for those..
I agree, that's what I'm going for eventually, to make all imlib configurable and generic. If you'd like to send PRs to refactor imlib code you're welcome.
Running fft analysis for finding translation, rotation, scale is pretty advanced approach, although running fft on small bins is inaccurate to achieve acceptable accuracy.
For my purposes I have implemented new function compute_flow() which gives better results for robust and fast optical flow estimation at approx. 90FPS on M7.
If anyone is interested, I can share how to include new functions into micropython and OpenMV (it would be great if there is such tutorial)

Keep up good work!

Cheers
Again if you want to send a PR for that function, or just send the code here, I'll add it.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests