关于OPENCV中使用RNG类产生随机数问题
最近在看OpenCV cvKmeans2()函数源代码时,遇到一个随机数问题,其中有一句RNG& rng=theRNG();产生随机数rng,不是很理解。既然是随机数,为什么程序每次运行时产生的随机数都是一样的?例如下面的程序:
#include "stdafx.h"
#include "cv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
RNG& rng=theRNG();
int random=(unsigned)rng;
double a= (double)rng;
printf("the random number:%d ,%f\n",random,a);
return 0;
}
在RNG& rng=theRNG();语句之后,每次用到rng变量的地方,会产生变化的数值,但是程序重新运行,其结果还是一样的。求高手解答!!!!