00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Luca Baronti * 00003 * lbaronti@gmail.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 /*************************************************************************** 00022 History 00023 Modified by sottile on July 2009 00024 ****************************************************************************/ 00025 00026 00039 /****************************************************************************\ 00040 * * 00041 * Camera parameters are usually the fixed parameters of the given camera * 00042 * system, typically obtained from manufacturers specifications. * 00043 * * 00044 * Cy and Cy (the center of radial lens distortion), may be calibrated * 00045 * separately or as part of the coplanar/noncoplanar calibration. * 00046 * The same with sx (x scale uncertainty factor). * 00047 * * 00048 \*******************************************************************************/ 00049 00050 #ifndef _TSAI_METHODS_ 00051 #define _TSAI_METHODS_ 00052 00053 #include <vcg/math/matrix44.h> 00054 #include <vcg/space/point3.h> 00055 #include <vcg/space/point2.h> 00056 #include <vcg/math/shot.h> 00057 00058 #include <list> 00059 00060 // minimum points that need tsai for a proper calibration 00061 static const int MIN_POINTS_FOR_CALIBRATE = 13; 00062 00063 struct TsaiCorrelation { 00064 vcg::Point3d point3d; 00065 vcg::Point2d point2d; 00066 }; 00067 00068 class TsaiMethods 00069 { 00070 public: 00071 //Calibration of the shot according to the 2D and 3D points 00072 static bool calibrate( vcg::Shot<double>* shot,std::list<TsaiCorrelation>* corr, bool p_foc); 00073 00075 static void Shot2Tsai(vcg::Shot<double>*); 00077 static void Tsai2Shot(vcg::Shot<double>*, bool p_foc=true); 00078 00079 private: 00080 static void Cam2Tsai(vcg::Shot<double>*); 00081 static bool createDataSet(std::list<TsaiCorrelation>* corr,vcg::Shot<double>* s); 00082 00083 }; 00084 00085 #endif //_TSAI_METHODS_