From 686063689c90a97f2897c78c0db1c78c2439c201 Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Mon, 30 May 2011 08:01:09 +0000 Subject: [PATCH] Fixed #886 --- samples/cpp/calibration.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index 256ec6c..ba5c210 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; -- 2.7.4