New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the iterative Lucas-Kanade (iLK) optical flow method #4161
Add the iterative Lucas-Kanade (iLK) optical flow method #4161
Conversation
Hello @rfezzani! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-10-02 08:50:49 UTC |
Ha! I didn't realise the question of how to present multiple optical flow algorithms in the API would become so relevant so soon! 😂 Thanks @rfezzani! I also notice that it's nD out of the box, a very nice touch. ;) I don't have time for a deep review right this second but it looks pretty great on first glance! |
…into Add_ilk_optical_flow_method
Both failures are due to |
# Estimate the flow at double precision | ||
flow_f64 = optical_flow_ilk(image0, image1, dtype='float64') | ||
|
||
assert flow_f64.dtype == 'float64' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time seeing that way to check dtypes. Seems a bit brittle and doesn't seem to work for cases such as np.float64 == "float64"
which will return False
. So maybe use np.float64
here (and similar at other places) instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, np.float64 == "float64"
returns False
, but np.dtype(np.float64) == 'float64'
is True
. Here I compare data type object...
But I will check if this can be done differently ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flow.dtype == np.float64
should work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely :-)
Co-Authored-By: Lars Grueter <lagru@users.noreply.github.com>
Co-Authored-By: Lars Grueter <lagru@users.noreply.github.com>
I actually don't understand why that function returns the wrong dtype 😄. Since the tests pass in the other CI checks... |
OK, I finally reproduced the CI failure: It comes from |
The CI failure is related to the issue #4189. |
…into Add_ilk_optical_flow_method
…into Add_ilk_optical_flow_method
…into Add_ilk_optical_flow_method
…into Add_ilk_optical_flow_method
…into Add_ilk_optical_flow_method
…into Add_ilk_optical_flow_method
Thank you very much @grlee77 for your review 😉 |
Thank you again @grlee77 for your excellent review, I think I addressed all your requests now 😉. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rfezzani for addressing the comments. This seems good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few comments as I was reading
Co-authored-by: Emmanuelle Gouillart <emma@plot.ly>
Co-authored-by: Emmanuelle Gouillart <emma@plot.ly>
@rfezzani one thing which I've been missing either in docstrings or in the gallery example (maybe both) is when to use which optical flow algorithm. From what I understand, one should use TV-l1 to allow for discontinuities in the flow, but when the flow is smooth one should prefer ilk which is faster. Is this correct? Could you please add a few explanations on how to select an optical flow algorithm? Algorithm selection is maybe as hard as parameter selection for our users :-). |
@rfezzani thank you very much for the PR! I have finished reading through the Plyer et al. paper, and the PR is ready to go for me. The only caveat would be to add a few explanations about when to use which algorithm, please tell us if you have the time to add it now or not. But there should not be other comments from me! |
Sorry @emmanuelle, I didn't found time yesterday :/ I will try to manage adding notes in the doc today. |
Thanks @rfezzani :-). Still in time for the release, don't worry. |
@emmanuelle, I modified
Is it enough or should I elaborate more? |
Thanks @rfezzani . Let's wait for CI and then I'll merge! |
I think CI failure is not related... |
Merged :-) ! |
🎉 Thank you @emmanuelle ! |
Description
Here is an implementation of the iterative Lucas-Kanade (iLK) method for optical flow estimation [1].
The Lucas-Kanade method is a local approach for the estimation of optical flow (as opposed to global approaches such TV-L1 for example). It is fast, robust and requires basically only one parameter that is the size of the neighborhood considered for the estimation.
[1]: Le Besnerais, G., & Champagnat, F. (2005, September). Dense optical flow by iterative local window registration. In IEEE International Conference on Image Processing 2005 (Vol. 1, pp. I-137). IEEE.
Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.@meeseeksdev backport to v0.14.x