Ask Your Question

How can i get a real random number?

asked 2016-11-07 20:04:04 -0500

MQ gravatar image

Hi, I've used the RNG function but it doesn't give me a real random value. I get the same values every time I execute my program. The code I use is the next one:

RNG rng;
int a1;
a1 = rng.uniform((double)0, (double)1)*512;

Can anybody help me?

Thanks in advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-11-08 01:03:17 -0500

berak gravatar image

you have to seed your random generator, e.g. like this:

RNG rng(cv::getTickCount());
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-11-07 20:04:04 -0500

Seen: 254 times

Last updated: Nov 08 '16