我对 RNG 课程有疑问。我想从给定的图像中随机获取不同的点,所以我使用OpenCV 文档中推荐的RNG 类。代码是:
struct SingleAnt
{
int row;
int col;
};
void initializeAnts( SingleAnt *ants, Mat *sourceImage )
{
RNG rng( 0xFFFFFFFF );
int imgWidth = sourceImage->cols;
int imgHight = sourceImage->rows;
for( int index = 0; index < ANTSNUMBER; index++ ) {
ants[ index ].col = rng.uniform( 0, imgWidth );
ants[ index ].row = rng.uniform( 0, imgHight );
}
}
但是,当我运行此代码时,每次都会得到相同的结果。代码中是否有任何错误?