danini/graph-cut-ransac

The homograpy results are not stable

zxp771 opened this issue · 4 comments

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?

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".

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

Hey!

generator = std::mt19937(rand_dev());

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

Also, remove this line:

srand(static_cast<int>(time(NULL)));