tags:

views:

69

answers:

1

Hi,

while trying to compile the following code in OpenCV2 in linux,

cv::Mat image1, image2;
cv::Rect rect1, rect2;
...
image1(rect1).copyTo(image2(rect2));

I get the following error:

x.cpp: In member function ‘cv::Mat Process(cv::Mat)’:
x.cpp:241: error: no matching function for call to ‘cv::Mat::copyTo(cv::Mat)’
cxcore.hpp:794: note: candidates are: void cv::Mat::copyTo(cv::Mat&) const
cxcore.hpp:796: note: void cv::Mat::copyTo(cv::Mat&, const cv::Mat&) const

Note: this code compiles and runs flawlessly in windows.

any help?

+1  A: 

From what i see here, operator() for Mat needs an argument of type Mat and not Mat&. That seems to be the issue here.

Try adding a temporary objet of type Mat. See below.

cv::Mat image1, image2;
cv::Rect rect1, rect2;
...
cv::Mat extractedImage2 = image1(rect2);
image1(rect1).copyTo(extractedImage2);

But i must say i am no openCV expert, so that is just an answer based on my c++ knowledge.

Benoît
thanks, I didn't get the description well but your code compiles quite well :)
MBZ