Ask Your Question

Revision history [back]

Bug ? Post an issue and you give this code as example

        cv::Mat imgf(5, 5, CV_32FC3);
        cv::randu(imgf, 0, 0);
        cout << imgf << "\n";
        cout << "******************************\n";

        cv::Mat img(5, 5, CV_8UC3);
        cv::randu(img, 0, 0);
        cout << img << "\n";
        cout << "******************************\n";

        cv::randu(img, 0, 1);
        cout << img << "\n";
        cout << "******************************\n";

results :

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
******************************
[255, 255, 255,  81, 255, 255, 255,  94,   0,   0,   0,   0, 255, 255, 255;
  82,   0,   0,   0,   0, 255, 255, 255,  62, 255, 255, 255,  96,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255;
 255, 255,  26, 255, 255, 255,  12, 255, 255, 255,   6,   0,   0,   0,   0;
 255, 255, 255,  71,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0, 255]
******************************
[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]
******************************

Bug ? Post an issue and you can give this code as example

        cv::Mat imgf(5, 5, CV_32FC3);
        cv::randu(imgf, 0, 0);
        cout << imgf << "\n";
        cout << "******************************\n";

        cv::Mat img(5, 5, CV_8UC3);
        cv::randu(img, 0, 0);
        cout << img << "\n";
        cout << "******************************\n";

        cv::randu(img, 0, 1);
        cout << img << "\n";
        cout << "******************************\n";

results :

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
******************************
[255, 255, 255,  81, 255, 255, 255,  94,   0,   0,   0,   0, 255, 255, 255;
  82,   0,   0,   0,   0, 255, 255, 255,  62, 255, 255, 255,  96,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255;
 255, 255,  26, 255, 255, 255,  12, 255, 255, 255,   6,   0,   0,   0,   0;
 255, 255, 255,  71,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0, 255]
******************************
[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]
******************************

Bug ? Post an issue and you can give this code as example

        cv::Mat imgf(5, 5, CV_32FC3);
        cv::randu(imgf, 0, 0);
        cout << imgf << "\n";
        cout << "******************************\n";

        cv::Mat img(5, 5, CV_8UC3);
        cv::randu(img, 0, 0);
        cout << img << "\n";
        cout << "******************************\n";

        cv::randu(img, 0, 1);
        cout << img << "\n";
        cout << "******************************\n";

results :

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
******************************
[255, 255, 255,  81, 255, 255, 255,  94,   0,   0,   0,   0, 255, 255, 255;
  82,   0,   0,   0,   0, 255, 255, 255,  62, 255, 255, 255,  96,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255;
 255, 255,  26, 255, 255, 255,  12, 255, 255, 255,   6,   0,   0,   0,   0;
 255, 255, 255,  71,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0, 255]
******************************
[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]
******************************

I think error is here

int idiff = ip[j][0] = cvFloor(b) - ip[j][1] - 1;

cvFloor(b) - ip[j][1] - 1 should be check and when value is negative set to 0 or may be check param1arg must be < param2arg (https://github.com/opencv/opencv/blob/master/modules/core/src/rand.cpp#L511-L512)

click to hide/show revision 4
No.4 Revision

updated 2018-09-01 03:21:30 -0600

berak gravatar image

Bug ? Post an issue and you can give this code as example

        cv::Mat imgf(5, 5, CV_32FC3);
        cv::randu(imgf, 0, 0);
        cout << imgf << "\n";
        cout << "******************************\n";

        cv::Mat img(5, 5, CV_8UC3);
        cv::randu(img, 0, 0);
        cout << img << "\n";
        cout << "******************************\n";

        cv::randu(img, 0, 1);
        cout << img << "\n";
        cout << "******************************\n";

results :

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
******************************
[255, 255, 255,  81, 255, 255, 255,  94,   0,   0,   0,   0, 255, 255, 255;
  82,   0,   0,   0,   0, 255, 255, 255,  62, 255, 255, 255,  96,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255;
 255, 255,  26, 255, 255, 255,  12, 255, 255, 255,   6,   0,   0,   0,   0;
 255, 255, 255,  71,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0, 255]
******************************
[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]
******************************

I think error is here

int idiff = ip[j][0] = cvFloor(b) - ip[j][1] - 1;

1;

cvFloor(b) - ip[j][1] - 1 1 should be check checked and when value is negative set to 0 or may be check param1arg param1 arg must be < param2arg

(https://github.com/opencv/opencv/blob/master/modules/core/src/rand.cpp#L511-L512)