src/qvmath/qvprojective.h

00001 /*
00002  *      Copyright (C) 2007, 2008. 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 
00021 #ifndef PROJECTIVE_H
00022 #define PROJECTIVE_H
00023 
00024 #include <QPair>
00025 #include <qvmath.h>
00026 #include <qvdta.h>
00027 #include <QVMatrix>
00028 
00032 
00035 
00047 QVMatrix ComputeHomography(const QList<QPointF> &sourcePoints, const QList<QPointF> &destPoints);
00048 
00058 QVMatrix ComputeProjectiveHomography(const QList< QPair<QPointF, QPointF> > &matchings);
00059 
00064 QVMatrix ComputeEuclideanHomography(const QPair<QPointF, QPointF> &firstMatching, const QPair<QPointF, QPointF> &secondMatching);
00065 
00070 QVMatrix ComputeEuclideanHomography(const QList< QPair<QPointF, QPointF> > &matchings);
00071 
00076 QPointF ApplyHomography(const QVMatrix &homography, const QPointF &point);
00077 
00082 QList<QPointF> ApplyHomography(const QVMatrix &homography, const QList<QPointF> &sourcePoints);
00083 
00105 double HomographyTestError(const QVMatrix &homography);
00106 
00107 
00110 
00111 /*
00112 @brief Obtains intrinsic and extrinsic camera matrix decomposition from a planar <a href="http://en.wikipedia.org/wiki/Homography">homography</a>.
00113 @ingroup qvproyective
00114 
00115 @todo explain how focal value is needed for intrinsic matrix, and how it is searched.
00116 This is a direct version of the function @ref GetIntrinsicCameraMatrixFromHomography, which doesn't 
00117 
00118 @param H homography matrix
00119 @param K matrix to store resulting intrinsic camera matrix.
00120 @param M matrix to store resulting extrinsic camera matrix.
00121 */
00122 //bool DecomposeCameraMatricesFromPlanarHomography(const QVMatrix &H, QVMatrix &K, QVMatrix &M);
00123 
00128 void GetExtrinsicCameraMatrixFromHomography(const QVMatrix &K, const QVMatrix &H, QVMatrix &M4x4);
00129 
00134 void GetDirectIntrinsicCameraMatrixFromHomography(const QVMatrix &H, QVMatrix &K);
00135 
00140 void GetIntrinsicCameraMatrixFromHomography(const QVMatrix &H, QVMatrix &K,
00141         double focal = 3, const double maxFocal = 50, const int maxIterations = 100, const double maxError = 0.00001);
00142 
00143 #endif