Updated by Alexander Shishkov about 13 years ago

I have been using with great succes a split warpPerspective() function to perform all kind of transforms that can be applied to many files at once.

If you precalculate the maps for remap(), you can apply them to many images (by example to a video when processing), gaining a significant performance improvement. Some examples include: fast resize, fast perspective correction, etc.

The technique can be used also on tracking algorithms, or multi-scale detectors on video, where the image must be resized.

The improvement can be achieved by splitting warpPerspective in two functions, that can be called separately from API:
buildMaps() and remap(). (The latter is already separate)

Example:

VideoCapture [[VideoCapture]] cap;
cap.open(file);
Mat H = (Mat_<float>( 0.5, 0, 0, 0, 0,5, 0, 0, 0,0, 0));
builsMaps(srcsize, dstsize, H, mapx, mapy);

Mat frame, smallframe;

for(;;)
{
cap >> frame;

// much, much faster than resize or warpAffine
remap(frame, smallframe, mapx, mapy, flags);
}

A good idea would be to have a separate optimization for remap on android (now it has only SSE acceleration)

Back