diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index 256ec6c0ed..ba5c210b21 100644 --- a/samples/cpp/calibration.cpp +++ b/samples/cpp/calibration.cpp @@ -213,13 +213,18 @@ void saveCameraParams( const string& filename, if( !rvecs.empty() && !tvecs.empty() ) { - Mat bigmat((int)rvecs.size(), 6, CV_32F); + CV_Assert(rvecs[0].type() == tvecs[0].type()); + Mat bigmat((int)rvecs.size(), 6, rvecs[0].type()); for( int i = 0; i < (int)rvecs.size(); i++ ) { Mat r = bigmat(Range(i, i+1), Range(0,3)); Mat t = bigmat(Range(i, i+1), Range(3,6)); - rvecs[i].copyTo(r); - tvecs[i].copyTo(t); + + CV_Assert(rvecs[i].rows == 3 && rvecs[i].cols == 1); + CV_Assert(tvecs[i].rows == 3 && tvecs[i].cols == 1); + //*.t() is MatExpr (not Mat) so we can use assignment operator + r = rvecs[i].t(); + t = tvecs[i].t(); } cvWriteComment( *fs, "a set of 6-tuples (rotation vector + translation vector) for each view", 0 ); fs << "extrinsic_parameters" << bigmat;