/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : ICLGeom/src/ICLGeom/SoftPosit.h ** ** Module : ICLGeom ** ** Authors: Christian Groszewski ** ** ** ** ** ** GNU LESSER GENERAL PUBLIC LICENSE ** ** This file may be used under the terms of the GNU Lesser General ** ** Public License version 3.0 as published by the ** ** ** ** Free Software Foundation and appearing in the file LICENSE.LGPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the license requirements will ** ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** ********************************************************************/ #pragma once #include #include #include #include #include #include #include #ifdef ICL_HAVE_QT #include #endif #ifdef WIN32 #undef max #endif namespace icl{ namespace geom{ class ICLGeom_API SoftPosit{ private: //M unsigned int nbWorldPts; //N unsigned int nbImagePts; math::DynMatrix centeredImage; math::DynMatrix distMat; math::DynMatrix assignMat; double beta; double betaFinal; static const double betaUpdate;// not allowed in clang = 1.05; static const double betaZero;;// not allowed in clang = 0.0004; #ifdef ICL_HAVE_QT qt::ICLDrawWidget *dw; #endif math::DynMatrix iAdj; math::DynMatrix wAdj; //expected or random pose //math::DynMatrix Q1; //expected or random pose //math::DynMatrix Q2; //squared distances math::DynMatrix d; math::DynMatrix w; //object points std::vector > P; //image points std::vector > p; math::DynMatrix L; math::DynMatrix invL; math::DynMatrix U; math::DynMatrix s; math::DynMatrix V; math::DynMatrix svdResult; math::DynMatrix eye2_2; math::DynMatrix r1T; math::DynMatrix r2T; math::DynMatrix r3T; math::DynMatrix projectedU; math::DynMatrix projectedV; math::DynMatrix replicatedProjectedU; math::DynMatrix replicatedProjectedV; math::DynMatrix col1; math::DynMatrix wkxj; math::DynMatrix col2; math::DynMatrix wkyj; math::DynMatrix pts2d; math::DynMatrix summedByColAssign; math::DynMatrix weightedUi; math::DynMatrix weightedVi; math::DynMatrix R1; math::DynMatrix R2; math::DynMatrix R3; math::DynMatrix ROT; math::DynMatrix T; double Tz; double Tx; double Ty; double sumNonslack; double sum; double alpha; bool draw; math::DynMatrix& cross(math::DynMatrix &x, math::DynMatrix &y, math::DynMatrix &r); void maxPosRatio(math::DynMatrix &assignMat, math::DynMatrix &pos, math::DynMatrix &ratios); math::DynMatrix &sinkhornImp(math::DynMatrix &M); double cond(math::DynMatrix &A); double max(math::DynMatrix s); public: SoftPosit(); ~SoftPosit(); void init(); math::DynMatrix getRotationMat(){ return ROT; } math::DynMatrix getTranslation(){ return T; } //unused int numMatches(math::DynMatrix &assignMat); void softPosit(math::DynMatrix imagePts, math::DynMatrix worldPts, double beta0, int noiseStd, math::DynMatrix initRot, math::DynMatrix initTrans, double focalLength, math::DynMatrix center = math::DynMatrix(2,0), bool draw = true); #ifdef ICL_HAVE_QT void softPosit(math::DynMatrix imagePts, math::DynMatrix imageAdj, math::DynMatrix worldPts, math::DynMatrix worldAdj, double beta0, int noiseStd, math::DynMatrix initRot, math::DynMatrix initTrans, double focalLength, qt::ICLDrawWidget &w, math::DynMatrix center = math::DynMatrix(2,0), bool draw = true); #endif void softPosit(std::vector imagePts, std::vector > worldPts, double beta0, int noiseStd, math::DynMatrix initRot, math::DynMatrix initTrans, double focalLength, math::DynMatrix center = math::DynMatrix(2,0)); #ifdef ICL_HAVE_QT void softPosit(std::vector imagePts, math::DynMatrix imageAdj, std::vector > worldPts, math::DynMatrix worldAdj, double beta0, int noiseStd, math::DynMatrix initRot, math::DynMatrix initTrans, double focalLength, qt::ICLDrawWidget &w, math::DynMatrix center = math::DynMatrix(2,0), bool draw=true); #endif void proj3dto2d(math::DynMatrix pts3d, math::DynMatrix &rot, math::DynMatrix &trans, double flength, int objdim, math::DynMatrix ¢er, math::DynMatrix &pts2d); bool isNullMatrix(const math::DynMatrix &M){ bool isNull = true; for(unsigned int i=0;i & imagePts, const math::DynMatrix &projWorldPts, unsigned int delay=200); void visualize(qt::ICLDrawWidget &w,const math::DynMatrix & imagePts, const math::DynMatrix &imageAdj, const math::DynMatrix &projWorldPts, const math::DynMatrix &worldAdj, unsigned int delay=200); #endif }; } // namespace geom }