The task is to determine the optical flow.
From the methods presented by you, the "differentiaol_translation" method has the best characteristics of accuracy. But it does not detect a slow movement. How can this be combated?

The same rate is controlled by the frame rate the system runs at. By default it just runs as fast as possible. If you'd like to slow down the sample rate just add a pyb.delay(100) to the main loop. Make sure to import the pyb module.

Is it possible to calculate the optical flow only on a part of the frame? If so, сould you show an example of using a function "find_displacement" with all variables.

It was also found that when using the sensor under vibration conditions (for example, on a UAV), there is an offset hunting (to the large side) calculated by the optical flow. What could be causing this?

Hi, the find_displacement() method takes a ROI such that you can target a specific area of the image to run it on. There's an example showing it being run on multiple locations that comes with OpenMV IDE. See the image-patches-differential-translation.py script under Optical Flow examples.

As for your second question... are you using a power of 2 resolution? Can you give me some more information?

So, yes, filtering is necessary to improve the accuracy. Realistically, systems that do very accurate SLAM have numerous filters working with other data inputs like gryo scopes and such to obtain high accuracy. Our method just provides about the same functionality of a computer mouse. It's good for determining a displacement direction but not for absolute positioning.

That said, performance should improve if it's being used in a system where the camera is in a rigid body such that the direction of motion has no height variations.

Yes, it will. Also, you should definitely lower the res to using B64X32. This is much faster than 128X128. The FFTs used by phase correlation don't really need much pixels. They just need to see edges to work.

Alternatively, you can use the B64X64 res and then do use the mean_pool(2,2) method on the image to get a 32x32 image. Things will run even faster on that.

You need the speed to make sure that the phase correlation output is accurate. Note there's also a couple confidence value output by the method. You should use that to determine the weighting of a result and if you should trust it or not.

Thank you! there is a problem with the accumulation of the error. A median filter was applied, but the problem remained. with rectilinear forward-backward motion, the error grows. how to neutralize it?

I honestly don't know. I just implemented the algorithm and confirmed it indeed works.

Um, question, what's your FPS? Also, what do you do about the confidence value? Once the confidence falls below a threshold the value is not longer valid to read... in your code I don't see you filtering by the confidence. A confidence below 0.2 means the reading is likely bad.