So, I am writing some OpenCV C++ code and I am having trouble porting my code from OpenCV 2.2 to 2.3.1. The main problem right now is the Mat::copyTo function. In the documentation or the release notes, they have mentioned that while the new version of this function takes OutputArray, the old code should still work (i.e., Mat::copyTo(Mat &m)). The thing is that it does not work.
Here’s my code
void copyMatRows(Mat &src,Mat &dest,int start_pos)
{
for(int i=0; i < src.rows;i++)
{
int dest_y = start_pos;
if(start_pos < 1)
{
dest_y = dest_y+i;
}
src.row(i).copyTo(dest.row(dest_y));
}
}
So in the above code the line
src.row(i).copyTo(dest.row(dest_y));
fails with the error
no matching function for call to cv::Mat::copyTo(cv::Mat) candidates
are: void cv::Mat::copyTo(const cv::_OutputArray&) const
Any help would be appreciated? any way in which i can fix this?
What I am trying to do is to get N number of matrices and combine them all in one big matrix.
This should fix your function, but I’m not sure it’s doing exactly what you want:
EDIT :
This should do pretty much what you’re looking for:
The main caveat with the
push_backmember function is that the number of columns must be the same, but I don’t think you’re too worried about that.Hope that helps!