danini / graph-cut-ransac

The Graph-Cut RANSAC algorithm proposed in paper: Daniel Barath and Jiri Matas; Graph-Cut RANSAC, Conference on Computer Vision and Pattern Recognition, 2018. It is available at http://openaccess.thecvf.com/content_cvpr_2018/papers/Barath_Graph-Cut_RANSAC_CVPR_2018_paper.pdf
Other
431 stars 93 forks source link

The homograpy results are not stable #21

Closed zxp771 closed 4 years ago

zxp771 commented 4 years ago

Hi @danini Thanks for your great work and sharing. I tried your code on d2-net matching test. I noticed the Homography results are different even I ran the same data in the same parameters(I mean the same threshold) which the fluctuations can not be ignored. Could you give me some suggestions to get a stable result?

danini commented 4 years ago

RANSAC is a randomized algorithm, so it is expected to get different results every time. The reason why you don't see this in OpenCV is that the same random seed is used there every time when applied. You can simulate this "deterministic" behavior in GC-RANSAC by fixing the seed of variable "random_generator" in file "uniform_sampler.h".

zxp771 commented 4 years ago

Hi @danini Thanks for your reply. Could you tell me how to fix the seed of variable "random_generator"?

danini commented 4 years ago

Hey!

https://github.com/danini/graph-cut-ransac/blob/0776ef77c2b32422b06d6251713df5a68db00b16/src/pygcransac/include/uniform_random_generator.h#L53

Here, replace "rand_dev()" with some constant, e.g., 0.

Also, remove this line: https://github.com/danini/graph-cut-ransac/blob/0776ef77c2b32422b06d6251713df5a68db00b16/examples/cpp_example.cpp#L160

zxp771 commented 4 years ago

@danini Thx