Ask Your Question
1

How can i get a real random number?

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

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
3

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

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

Stats

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

Seen: 510 times

Last updated: Nov 08 '16