while trying to compile the following code in OpenCV2 in linux,
cv::Mat image1, image2;
cv::Rect rect1, rect开发者_JS百科2;
...
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?
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.
精彩评论