Ask Your Question

Revision history [back]

click to hide/show revision 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));
}

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));
}

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));
}

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.