Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

warpAffine execution time varying

Hello,

I'm working on global motion estimation in videos. And I noticed that the execution time of the warpAffine function varies a lot (same input image, same transformation). Here's a small test :

Mat im = imread("image_test.png");
Mat wavimg = Mat(im.rows,im.cols,CV_8UC1);
Mat mapMatrix = Mat(2,3,CV_32F);
mapMatrix.at<float>(0,0) = 1.05;
mapMatrix.at<float>(0,1) = 0.0001;
mapMatrix.at<float>(0,2) = 5.3;
mapMatrix.at<float>(1,0) = -0.0001;
mapMatrix.at<float>(1,1) = 1.05;
mapMatrix.at<float>(1,2) = -0.8;

double tic, toc, tictoc;
for (int i=0; i<1000; i++){
    tic = (double)cvGetTickCount();
    warpAffine(im,wavimg,mapMatrix,wavimg.size(),CV_INTER_LINEAR+WARP_INVERSE_MAP);
    toc = (double)cvGetTickCount();
    tictoc = (toc-tic)/(1000*(double)cvGetTickFrequency());
    printf("time: %fms\n",(float)tictoc);
}
return 0;

Here are the execution times for 300 samples. These times are mainly around 0.8 ms but some of them are higher (up to 1.4 ms). I don't understand why and I'd like to know the reason. My configuration : windows 7 pro, visual studio express 2013, opencv 2.4.8, Intel Core i7-4700MQ CPU @ 2.4Ghz, 64 bits

Could anybody help me please ?

Regards, image description