Ask Your Question

Revision history [back]

I haven't got any problem (vs2017 -opencv 3.4-dev) using this program :

#include <opencv2/opencv.hpp> 
#include <iostream>

using namespace cv;
using namespace std;

#define NBCAMERA 5

int main (int argc,char **argv)
{
    Mat img1(2048, 2048, CV_16UC1);
    RNG r;
    Mat img2(2048, 2048, CV_16UC1, Scalar(1058));
    r.fill(img1, RNG::UNIFORM, 0, 32000);
    r.fill(img2, RNG::UNIFORM, 0, 32000);
    imwrite("test1.tif", img1);
    imwrite("test2.tif", img2);
    std::vector<cv::String> filenames{ "test1.tif","test2.tif" };
    cv::Mat im;
    TickMeter t;
    t.reset();
    t.start();
    for (size_t i = 0; i<3500; i++)
    {
        im = imread(filenames[i%2], CV_LOAD_IMAGE_ANYDEPTH);
        if (i>0 && i % 100 == 0)
        {
            t.stop();
            std::cout << "Ellapsed Time  "<< i<<" -> "<<t.getTimeMilli()<< std::endl;
            t.reset();
            t.start();
        }
    }return 0;
}

results are

Ellapsed Time  100 -> 4947.4
Ellapsed Time  200 -> 4875.03
Ellapsed Time  300 -> 4823
Ellapsed Time  400 -> 4814.94
Ellapsed Time  500 -> 4768.13
Ellapsed Time  600 -> 4818.58
Ellapsed Time  700 -> 4759.5
Ellapsed Time  800 -> 4605.62
Ellapsed Time  900 -> 4641.3
Ellapsed Time  1000 -> 4631.22
Ellapsed Time  1100 -> 4650.53
Ellapsed Time  1200 -> 4633.75
Ellapsed Time  1300 -> 4649.75
Ellapsed Time  1400 -> 4681.7
Ellapsed Time  1500 -> 4647.45
Ellapsed Time  1600 -> 4663.46
Ellapsed Time  1700 -> 4642.76
Ellapsed Time  1800 -> 4634.68
Ellapsed Time  1900 -> 4502.76
Ellapsed Time  2000 -> 4539.41
Ellapsed Time  2100 -> 4735.48
Ellapsed Time  2200 -> 4743.72
Ellapsed Time  2300 -> 4708.38
Ellapsed Time  2400 -> 4735.22
Ellapsed Time  2500 -> 4717.13
Ellapsed Time  2600 -> 4726.73
Ellapsed Time  2700 -> 4785.9
Ellapsed Time  2800 -> 4685.31
Ellapsed Time  2900 -> 4674.4
Ellapsed Time  3000 -> 4732.16
Ellapsed Time  3100 -> 4682.91
Ellapsed Time  3200 -> 4843.31
Ellapsed Time  3300 -> 4730.63
Ellapsed Time  3400 -> 4674.49
Appuyez sur une touche pour continuer...