OpenCV 中有自己的随机数生成类 RNG,先来看看 OpenCV 文档的介绍:
Random number generator. It encapsulates the state (currently, a 64-bit integer) and has methods to return scalar random values and to fill arrays with random values. Currently it supports uniform and Gaussian (normal) distributions. The generator uses Multiply-With-Carry algorithm, introduced by G. Marsaglia ( http://en.wikipedia.org/wiki/Multiply-with-carry ). Gaussian-distribution random numbers are generated using the Ziggurat algorithm ( http://en.wikipedia.org/wiki/Ziggurat_algorithm ), introduced by G. Marsaglia and W. W. Tsang.
构造函数
RNG::RNG()
RNG::RNG(uint64 state)
RNG 类有以上两个构造函数,第二个构造函数传入一个 uint64 类型的种子,若使用第一个构造函数则会使用默认的种子,一般使用系统时间来指定种子,这样可以使得程序每次运行生成的随机数不同。
RNG::next
unsigned int RNG::next()
返回下一个随机数。
RNG::operator T
RNG::operator uchar()
RNG::operator schar()
RNG::