Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to speed up seamlessClone? (incredibly slow)

Hi,

I am using seamlessClone to integrate a logo into a video and it is incredibly slow. Actually creating a video with 1000 frames with a resolution of 1280 x 800 takes 30 seconds. While using seamlessClone it takes round about 15 seconds to write one single frame!

I am not sure whether I use this function in a wrong way or whether seamlessClone is really that heavy.

This is basically what I do:

int main() {
cv::Mat logo= imread("logo.png", CV_LOAD_IMAGE_COLOR);

Size size(100,120);
Mat LogoResized;
resize(logo,LogoResized,size);
Point center(300,300);

Mat mask_forCloning = 255 * Mat::ones(LogoResized.rows, LogoResized.cols, LogoResized.depth());
Mat normal_clone;
Mat image;

for (int i=0; i<1000; i++)
{
    image = imread(pictureName, CV_LOAD_IMAGE_COLOR);  //Of course the name is changing with every frame ;-)

seamlessClone(LogoResized, image, mask_forCloning, center, normal_clone, NORMAL_CLONE);

writeCurrentFrameToVideo(normal_clone);
}

}

Is there a possibility to speed this up?

Thank you very much :-)