Skip to content

Restore LineSegmentDetector LSD & avoid license conflict #2524

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

Closed
jeanchristopheruel opened this issue May 9, 2020 · 16 comments
Closed

Restore LineSegmentDetector LSD & avoid license conflict #2524

jeanchristopheruel opened this issue May 9, 2020 · 16 comments

Comments

@jeanchristopheruel
Copy link

jeanchristopheruel commented May 9, 2020

Concerning the removal of LSD due to original code license conflict, it would be a great earning for the community to restore it back by modifying the code in order to avoid license conflict.

The original license conflict issue: #2016

Proposal:
Find an alternative way to "Compare doubles by relative error" as in original modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp between lines 625 and 824.

@barabanus
Copy link

That would be very useful because LSD line detector is very useful and robust.

@jeanchristopheruel
Copy link
Author

Currently working on it.

@alalek
Copy link
Member

alalek commented May 10, 2020

Find an alternative way to "Compare doubles by relative error"

This is not enough.
Almost all removed code by mentioned patches has license conflict.

Even derived work from GPL code is not allowed due GPL copyleft license.
Original article should be taken to create code from scratch.

@ParadoxRobotics
Copy link

As an alternative, I use the original implementation with a python wrapper
-> https://github.com/xanxys/lsd-python

@ThadHouse
Copy link

Based on the latest post in #2016, it seems like the author of the blog post realized the license issue, and released in a compatible license. Does this mean LineSegmentDetector can be added back into 4.x?

@alalek
Copy link
Member

alalek commented Feb 8, 2021

Unfortunately problem is much wider than mentioned function which compares floating-point values.
See my comment above from May 10, 2020

@olimexsmart
Copy link

If someone (I could try) took the time to implement from scratch, then it would be fine?

@sturkmen72
Copy link
Contributor

i am happy to annonce that after i send an e-mail to @rafael-grompone-von-gioi he kindly published his Computation of a NFA related to a binomial distribution code with MIT licence. He also states he will be happy to help on restoration of LDS Algorithm in OpenCV.

thank you @rafael-grompone-von-gioi for your great work.

@olokobayusuf
Copy link

olokobayusuf commented May 9, 2021

Hey all, I wanted to let you know I've written a partial implementation of the Line Segment Detector paper. It works, but unlike the paper, it relies on a density heuristic for filtering lines, instead of the NFA heuristic in the paper. I wasn't able to write a numerically-stable implementation of the NFA function. This is why it's a partial implementation.

@rafael-grompone-von-gioi I hope this can serve as a good launchpad to write a full implementation. I'm more than happy to collaborate on it!

EDIT: I should add that if we can add a stable NFA implementation, I'll be happy to merge my work into opencv_contrib.

@rafael-grompone-von-gioi
Copy link

@olokobayusuf
Copy link

Hey @rafael-grompone-von-gioi , thanks for the quick response. I have inline responses below:

Thank you for your email. I’happy to collaborate. Unfortunately, I will not be able to work on this for about two weeks, I’m overloaded with important work. So now I just send some short comments.

This is no rush at all. We can get to it whenever you are available.

I think the NFA validation is core of the LSD method; without that it is not the LSD method. Without the NFA step is more similar to a variation of Burns et al. method than to LSD. So I would be happy to help to include the NFA part.

I agree. My implementation was just a quick way to get going, because as I mentioned earlier I wasn't able to compute the NFA.

I saw you are working on a python implementation. But, LSD was already in OpenCV before. Why not using the same implementation and only updating the parts where there were doubts about the license? This should be minimal work.

My implementation is actually a Cython hybrid, and it has been hand-optimized to run as fast as possible. My understanding was that the OpenCV implementation was completely off limits because of the Affero license, so I had to start from scratch. I chose to write it in Cython for speed. I'm happy to rewrite the implementation in C++ if needed.

@sturkmen72
Copy link
Contributor

i am happy to annonce that after i send an e-mail to @rafael-grompone-von-gioi he kindly published his Computation of a NFA related to a binomial distribution code with MIT licence. He also states he will be happy to help on restoration of LDS Algorithm in OpenCV.

thank you @rafael-grompone-von-gioi for your great work.

@alalek can i prepare a patch to revert commits removing LSD and other algos using NFA?

@alalek
Copy link
Member

alalek commented Oct 1, 2021

@sturkmen72 Sure!
(please update code reference to new repo under MIT license if any)

@alalek
Copy link
Member

alalek commented Oct 2, 2021

relates opencv/opencv#13942
relates #2020

@sturkmen72
Copy link
Contributor

#3051

@alalek alalek mentioned this issue Oct 2, 2021
6 tasks
@alalek
Copy link
Member

alalek commented Dec 23, 2021

Restored in 4.5.4 release.

Thanks @sturkmen72 for the efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants