I am facing a slow execution time of the FIRST usage of the opencv (3.0) resize funtion (using visual studio on Windows). The following simple program shows the problem:
int _tmain(int argc, _TCHAR* argv[])
{
DECLARE_TIMING(ttt);
START_TIMING(ttt);
cv::Mat tmp1=cv::Mat::ones(100,100, CV_8UC3);
cv::Mat res1=cv::Mat::zeros(100*0.25, 100*0.25, CV_8UC3);
cv::resize(tmp1, res1, cv::Size(0,0), 0.25f, 0.25f, CV_INTER_AREA);
STOP_TIMING(ttt);
double runTime = GET_TIMING(ttt);
std::cout << "First resize run time = " << runTime << " mSec\n";
START_TIMING(ttt);
cv::Mat tmp2=cv::Mat::ones(100,100, CV_8UC3);
cv::Mat res2=cv::Mat::zeros(100*0.25, 100*0.25, CV_8UC3);
cv::resize(tmp2, res2, cv::Size(0,0), 0.25f, 0.25f, CV_INTER_AREA);
STOP_TIMING(ttt);
runTime = GET_TIMING(ttt);
std::cout << "Second resize run time = " << runTime << " mSec\n";
return 0;
}
The result is:
First resize run time = 259.575 mSec
Second resize run time = 0.0769735 mSec
Now why does the first resize usage takes 259 msec while the second takes way less ?? (note, I am aware that the pre allocations of res1 and res2 is not needed, this was part of my effort to overcome the issue)