remove some rand functions

* make test more reproducible
pull/9203/head
Tomoaki Teshima 8 years ago
parent dcb3c4ff1e
commit e63d628677
  1. 13
      modules/calib3d/test/test_undistort_points.cpp
  2. 4
      modules/core/test/test_eigen.cpp
  3. 11
      modules/core/test/test_ippasync.cpp
  4. 3
      modules/dnn/test/test_halide_layers.cpp
  5. 3
      modules/photo/test/test_hdr.cpp

@ -29,16 +29,13 @@ CV_UndistortTest::~CV_UndistortTest() {}
void CV_UndistortTest::generate3DPointCloud(vector<Point3f>& points, Point3f pmin, Point3f pmax)
{
const Point3f delta = pmax - pmin;
RNG rng_Point = ::theRNG(); // fix the seed to use "fixed" input 3D points
for (size_t i = 0; i < points.size(); i++)
{
Point3f p(float(rand()) / RAND_MAX, float(rand()) / RAND_MAX,
float(rand()) / RAND_MAX);
p.x *= delta.x;
p.y *= delta.y;
p.z *= delta.z;
p = p + pmin;
points[i] = p;
float _x = rng_Point.uniform(pmin.x, pmax.x);
float _y = rng_Point.uniform(pmin.y, pmax.y);
float _z = rng_Point.uniform(pmin.z, pmax.z);
points[i] = Point3f(_x, _y, _z);
}
}
void CV_UndistortTest::generateCameraMatrix(Mat& cameraMatrix)

@ -389,11 +389,11 @@ bool Core_EigenTest::check_full(int type)
{
const int MAX_DEGREE = 7;
srand((unsigned int)time(0));
RNG rng = ::theRNG(); // fix the seed
for (int i = 0; i < ntests; ++i)
{
int src_size = (int)(std::pow(2.0, (rand()%MAX_DEGREE)+1.));
int src_size = (int)(std::pow(2.0, (rng.uniform(0, MAX_DEGREE) + 1.)));
cv::Mat src(src_size, src_size, type);

@ -110,17 +110,6 @@ PARAM_TEST_CASE(IPPAsyncShared, Channels, hppAccelType)
sts = hppQueryMatrixAllocParams(accel, (hpp32u)(matrix_Size.width*cn), (hpp32u)matrix_Size.height, HPP_DATA_TYPE_8U, &pitch, &size);
if (pitch!=0 && size!=0)
{
uchar *pData = (uchar*)_aligned_malloc(size, 4096);
for (int j=0; j<matrix_Size.height; j++)
for(int i=0; i<matrix_Size.width*cn; i++)
pData[i+j*pitch] = rand()%upValue;
matrix = Mat(matrix_Size.height, matrix_Size.width, type, pData, pitch);
}
matrix = randomMat(matrix_Size, type, 0, upValue);
}

@ -612,10 +612,11 @@ TEST_P(Eltwise, Accuracy)
eltwiseParam.set("operation", op);
if (op == "sum" && weighted)
{
RNG rng = cv::theRNG();
std::vector<float> coeff(1 + numConv);
for (int i = 0; i < coeff.size(); ++i)
{
coeff[i] = ((float)rand() / RAND_MAX) * 4 - 2;
coeff[i] = rng.uniform(-2.0f, 2.0f);
}
eltwiseParam.set("coeff", DictValue::arrayReal<float*>(&coeff[0], coeff.size()));
}

@ -141,9 +141,10 @@ TEST(Photo_AlignMTB, regression)
int errors = 0;
Ptr<AlignMTB> align = createAlignMTB(max_bits);
RNG rng = ::theRNG();
for(int i = 0; i < TESTS_COUNT; i++) {
Point shift(rand() % max_shift, rand() % max_shift);
Point shift(rng.uniform(0, max_shift), rng.uniform(0, max_shift));
Mat res;
align->shiftMat(img, res, shift);
Point calc = align->calculateShift(img, res);

Loading…
Cancel
Save