-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
ORB extraction #283
Comments
RANSAC uses random seeds. And RanSaC is used everywhere. Initialization process involves some randomness too. |
Hi AlejandroSilvestri, thanks for your help. |
Ok. I'm trying to locate the reason. I'm reading your code. What is The code would be cleaner if you repeat the extraction on a new ORBextractor instance, so it guarantees same initial conditions. Let's say, repeat |
I'm sorry I forgot to say that I changed the ORBextractor constructor to
I rewrite the test code with the original ORBextractor as follows:
And the output is
The resluts are still different even I initialize the extractor each time. |
@jcchen1987 , in other experiments I noticed FAST has that behavior, I don't know why, I guess non-max suppression can do that if FAST divide its tasks in many parallel threads. I believe parallel threads include some randomness in the time they take to complete their task, because the OS control them, not the application. |
@AlejandroSilvestri, your suppose is very likely to be right, I will check it later. Thanks for you help! |
Sorry to re-open this issue, but I was analysing the same. I am not fully convinced by the multi-thread of FAST as I haven not found any thread in the OpenCV implementation. Moreover, if it was so, even the normal ORB implementation of OpenCV should show a similar behaviour. In my opinion, this behaviour seems occurring inside the octree detections. I will further check such a behaviour, but if you have found something, please let me know. |
The weird behaviour is caused by std::sort within the DistributeOctTree( ) function along with When there are nodes with same number of features, sort randomly orders equivalent values and it happens that the if condition breaks the for loop exactly between two nodes (different cells) with same number of features, which can be ordered differently over multiple runs inside a program. This generates results with swapped key-points at different position and some more (or less) key-points. However, running a bash script that calls multiple times the ORB extractor generates the same results as the random seed within sort is re-initialise. The suggestions and current solution I am using is to change std::sort with std::stable_sort from the Here, my current working solution: Please let me know if there is something not clear in the explanation. |
@kerolex , Thank you for the neat explanation. Believe it or not, I was worry about not understanding this weird behaviour. Now I have to understand why sort operates randomly on equivalent values, on the exactly same data. And this behaviour can vary on different implementations of std::sort. But this is way beyond orb-slam2 scope. |
from my knowledge and understanding, I think that sort repeats exactly the same elements on the same data if called within a bash script (you call the ORBextractor only once for that program run), because of the seed in rng. This is not longer true if you called it twice within the program as the random generator has a different seed (probably depending on the elapsing time). |
@kerolex , Where does that ramdom generator take place? In std::sort or in orb-slam2 code? |
Sorry, I replied quickly earlier. From the current behaviour, I guess there is a seed inside std::sort, otherwise I cannot explain to myself why it can generate the same order with a bash script. So, I do not know if there is really a random generator inside sort. |
@kerolex , I don't believe there is a random generator in sort, but your findings are enlightening. |
@jianchong-chen Hi jianchong, for the problem that orb extraction will crash in DistributeOctTree(nIni = 0) if the image width is smaller than height, could you share your solution? I am having the same problem. Thank you. |
@Shar-pei-bear
|
@jianchong-chen Hi jianchong, sorry to respond so late. I managed to come up with a fix: github repo. I would love to read your solution to this problem. |
I rewrite the code to filter the keypoints with quad-tree.
|
I found 2 issues in orb extraction when I used it in another project.
The text was updated successfully, but these errors were encountered: