Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Pass by reference errors

Hi, I'm new to openCV and I've written the following code:

 void add_image(Mat &mat);

 int main() 
  {
        Mat mat = imread("img1.png", 1);
        add_image(mat); 
        imshow("Result", mat);
        waitKey(0);
        return 0;
  }

  void add_image(Mat &mat)
  {
        Mat logo = imread("img2.png", 1);
        logo.copyTo(mat(cv::Rect(0,0, logo.cols, logo.rows))); //Exception here
  }

On compilation I get the following error:

OpenCV Error: Assertion failed (!fixedSize()) in release, file /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/matrix.cpp, line 1619 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/matrix.cpp:1619: error: (-215) !fixedSize() in function release

Aborted (core dumped)

How can I resolve this?

Regards,

A.