我正在使用OpenCV
,并使用cv::RNG
从列表中的图片中随机生成一个百分点:
void chooseImages(const StringVector& imagesListIn, StringVector& imagesListPartOut)
{
imagesListPartOut.clear();
if (m_perecent == 1)
{
imagesListPartOut = imagesListIn;
}
else
{
// copy the imagesListIn for being able to remove the chosed images
int percent = static_cast<int>(m_perecent * imagesListIn.size() + .5);
cv::RNG randomChooser;
StringVector listCpy = imagesListIn;
int index;
int listSize = imagesListIn.size();
std::string name;
for (int i = 0; i < percent; i++)
{
index = randomChooser.next() % listSize;
std::cout << index << " ";
name = listCpy[index];
listCpy.erase(listCpy.begin() + index);
imagesListPartOut.push_back(name);
listSize = listCpy.size();
}
std::cout << std::endl;
}
}
我的问题是它总是选择相同的图像;它始终打印相同的数字(cv::RNG
始终生成相同的数字)。如何让它产生不同的随机成员?