PARP Research Group | Universidad de Murcia |
src/qvmath/qveuclideanmapping3.cppGo to the documentation of this file.00001 /* 00002 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012. PARP Research Group. 00003 * <http://perception.inf.um.es> 00004 * University of Murcia, Spain. 00005 * 00006 * This file is part of the QVision library. 00007 * 00008 * QVision is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as 00010 * published by the Free Software Foundation, version 3 of the License. 00011 * 00012 * QVision is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with QVision. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00024 00025 #include <QVEuclideanMapping3> 00026 00027 #include <qvprojective.h> 00028 QVEuclideanMapping3::QVEuclideanMapping3(const QVMatrix &Rt) 00029 { 00030 // 1. Ensure that the rotation matrix is an orthogonal basis. This is: det(R) = 1. 00031 // 1.1. Ensure that Rt^t*Rt = I 00032 QVMatrix refinedRt = refineExtrinsicCameraMatrixWithPolarDecomposition(Rt); 00033 00034 // 1.2. Still, det(R) can be <= 0. Warn the user and try to fix it up in that case. 00035 const double determinantR = determinant(refinedRt.getSubmatrix(0,2,0,2)); 00036 if (determinantR == 0.0) 00037 std::cout << "[QVEuclideanMapping3::QVEuclideanMapping3] Warning: determinant of the rotation matrix in the provided camera matrix is equal to zero." << std::endl; 00038 else if (determinantR < 0.0) 00039 //{ 00040 //std::cout << "[QVEuclideanMapping3::QVEuclideanMapping3] Warning: determinant of the rotation matrix in the provided camera matrix is lesser than zero." << std::endl; 00041 refinedRt = refinedRt * (-1); 00042 //} 00043 00044 // 2. Get Quaterion and translation vector from the refined Rt. 00045 q = refinedRt.getSubmatrix(0,2,0,2); 00046 t = QV3DPointF(refinedRt(0,3), refinedRt(1,3), refinedRt(2,3)); 00047 } 00048 |