Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Ransac - possible bug in calculation of 'N' if pInlier = 0 #286

Closed
thorpey33 opened this issue Sep 7, 2016 · 4 comments
Closed

Ransac - possible bug in calculation of 'N' if pInlier = 0 #286

thorpey33 opened this issue Sep 7, 2016 · 4 comments

Comments

@thorpey33
Copy link

Hi,

I'm relatively new to Ransac but I've stumbled across an odd bug;

In the case that the distances function returns 0 inliers on it's first attempt (i.e. before bestInliers is set) then N evaluates to '-Infinty' (not sure why -Infinity rather than +Infinity?) causing the while loop to end on its first attempt (as then count > -Infinity).

Propose for line 332 :
((bestInliers == null && inliers.Length > 0) || inliers.Length > maxInliers) (... or something more elegant!)

Cheers,

James

@cesarsouza
Copy link
Member

Hi there! Thanks a lot for reporting the issue!

Do you think you could provide a simple test case that triggers the problem? You can just design a dummy distances function that returns 0 inliers right in the beginning, causing N to evaluate to -Infinity. This would be really super helpful!

Best regards,
Cesar

@thorpey33
Copy link
Author

accord-machinelearning-fitting-(ransac).zip

Hi Cesar,

Thanks for getting back to me so quickly, I've done a slight modification to your sample app (attached);
(1) Commented lines in the distances function so that it always returns 0 inliers
(2) Added the RANSAC source code to the solution and added a couple of lines to write to the console

"N=-Infinity" gets printed to the console and we see that only one loop through the while statement is done. The expected behavior would be to carry on trials until maxEvaluations is reached.

Hope that's what you were after? I can provide more background to my context but didn't want to muddy the water unless needed.

Cheers,

James

@cesarsouza
Copy link
Member

Thanks, I registered your example as an unit test and committed a fix! I will generate a pre-release package soon.

Regards,
Cesar

@cesarsouza
Copy link
Member

Fixed on release 3.3.0.

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

No branches or pull requests

2 participants