Ask Your Question

Revision history [back]

You should first check if the images have been properly opened:

Mat img = imread("img1.png, IMREAD_COLOR);
if(img.empty()) throw std::runtime_error("unable to open the image");

The same apply for the logo. Feel free to replace the exception by whatever you want.

You should always check the boundaries of your images:

if( logo.rows <= mat.rows and logo.cols <= mat.cols)
    logo.copyTo(mat(Rect(0,0,logo.cols,logo.rows)

That should solve your issues.