Updated by Andrey Kamaev about 13 years ago

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

If you precalculate the maps for @remap()@, 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()@ buildMaps() and @remap()@. remap(). (The latter is already separate)

Example:

<pre><code class="cpp">
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);
}
</code></pre>


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

Back