0
$\begingroup$

Rosanswers logo

I am using OpenCV to create some random numbers. I initialize the generator as:

RNG rng( 0xFFFFFFFF );

And then to get a number:

rng.uniform( 0, 100);

But everytime I run my program the generated sequence is the same. How do I get a different sequence?


Originally posted by Luis Ruiz on ROS Answers with karma: 114 on 2014-06-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As stated in the doc

http://docs.opencv.org/modules/core/doc/old_basic_structures.html?highlight=random%20number%20generator#rng

RNG takes a seed as arg. If you need a different sequence every time you have to initialize it with a different value every time, e. g. use time, thread id or some thing like this as seed....


Originally posted by Wolf with karma: 7555 on 2014-06-16

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.