ducha-aiki / pymagsac

MAGSAC: marginalizing sample consensus, python version
Other
73 stars 14 forks source link

very slow even when only 40 points #5

Open zjhthu opened 4 years ago

zjhthu commented 4 years ago

I find pymagsac will be stuck sometimes, it can run tens of minutes and do not stop even when just 40 points. Here is an example.

import numpy as np
import pymagsac

data = np.load('test_data.npz')
for idx in range(100):
    print(idx)
    F, mask = pymagsac.findFundamentalMatrix(data['p1'], data['p2'], 3.0)

test_data.tar.gz

@danini @ducha-aiki

zjhthu commented 4 years ago

it seems the bug comes from this line. Eigen fails when the last element in polynomial is near zero.

ducha-aiki commented 4 years ago

Thanks for the catch! I remember that @danini told me a week ago about similar (or the same) problem with EIGEN and GC-RANSAC, not sure what we can do now :(

zjhthu commented 4 years ago

The 7point algorithm implemented in OpenCV does not use Eigen for solving the cubic polynomial. Actually the cubic polynomial can be solved easily like this and this. I will copy the code in OpenCV to fix it.

ducha-aiki commented 4 years ago

Thank you for the fix. @danini mentioned that he submitted bug report to the eigen. If they don't fix it, then I'll merge.

sailor-z commented 4 years ago

@zjhthu Have you fixed it? I‘ve met the same error. ’

zjhthu commented 4 years ago

you can use this repo.

sailor-z commented 4 years ago

It works. Thank you so much @zjhthu.