1 | initial version |
you could still preallocate it, and copy rows, which would shave off the cost for subsequential allocations triggered from the push_back():
Mat final(mat.size(), mat[0].cols, CV_32F);
for(int i=0; i<mat.rows; i++){
mat[i].copyTo(final.row(i));
}
2 | No.2 Revision |
you could still preallocate it, and copy rows, which would shave off the cost for subsequential allocations triggered from the push_back():
Mat final(mat.size(), mat[0].cols, CV_32F);
for(int for(size_t i=0; i<mat.rows; i<mat.size(); i++){
mat[i].copyTo(final.row(i));
}
3 | No.3 Revision |
you could still preallocate it, and copy rows, which would shave off the cost for subsequential allocations triggered from the push_back():
Mat final(mat.size(), mat[0].cols, CV_32F);
for(size_t i=0; i<mat.size(); i++){
mat[i].copyTo(final.row(i));
}
4 | No.4 Revision |
you could still preallocate it, and copy rows, which would shave off the cost for subsequential allocations triggered from the push_back():
Mat final(mat.size(), mat[0].cols, CV_32F);
for(size_t i=0; i<mat.size(); i++){
mat[i].copyTo(final.row(i));
}
final.reshape(1,1);
also look at hconcat() / vconcat(), though i doubt, that they are cheaper.