Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of gr-peach-opencv-project-sd-card by
distortion_model.hpp
00001 /*M/////////////////////////////////////////////////////////////////////////////////////// 00002 // 00003 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 00004 // 00005 // By downloading, copying, installing or using the software you agree to this license. 00006 // If you do not agree to this license, do not download, install, 00007 // copy or use the software. 00008 // 00009 // 00010 // License Agreement 00011 // For Open Source Computer Vision Library 00012 // 00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 00015 // Third party copyrights are property of their respective owners. 00016 // 00017 // Redistribution and use in source and binary forms, with or without modification, 00018 // are permitted provided that the following conditions are met: 00019 // 00020 // * Redistribution's of source code must retain the above copyright notice, 00021 // this list of conditions and the following disclaimer. 00022 // 00023 // * Redistribution's in binary form must reproduce the above copyright notice, 00024 // this list of conditions and the following disclaimer in the documentation 00025 // and/or other materials provided with the distribution. 00026 // 00027 // * The name of the copyright holders may not be used to endorse or promote products 00028 // derived from this software without specific prior written permission. 00029 // 00030 // This software is provided by the copyright holders and contributors "as is" and 00031 // any express or implied warranties, including, but not limited to, the implied 00032 // warranties of merchantability and fitness for a particular purpose are disclaimed. 00033 // In no event shall the Intel Corporation or contributors be liable for any direct, 00034 // indirect, incidental, special, exemplary, or consequential damages 00035 // (including, but not limited to, procurement of substitute goods or services; 00036 // loss of use, data, or profits; or business interruption) however caused 00037 // and on any theory of liability, whether in contract, strict liability, 00038 // or tort (including negligence or otherwise) arising in any way out of 00039 // the use of this software, even if advised of the possibility of such damage. 00040 // 00041 //M*/ 00042 00043 #ifndef __OPENCV_IMGPROC_DETAIL_DISTORTION_MODEL_HPP__ 00044 #define __OPENCV_IMGPROC_DETAIL_DISTORTION_MODEL_HPP__ 00045 00046 //! @cond IGNORED 00047 00048 namespace cv { namespace detail { 00049 /** 00050 Computes the matrix for the projection onto a tilted image sensor 00051 \param tauX angular parameter rotation around x-axis 00052 \param tauY angular parameter rotation around y-axis 00053 \param matTilt if not NULL returns the matrix 00054 \f[ 00055 \vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}((\tau_x, \tau_y)} 00056 {0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)} 00057 {0}{0}{1} R(\tau_x, \tau_y) 00058 \f] 00059 where 00060 \f[ 00061 R(\tau_x, \tau_y) = 00062 \vecthreethree{\cos(\tau_y)}{0}{-\sin(\tau_y)}{0}{1}{0}{\sin(\tau_y)}{0}{\cos(\tau_y)} 00063 \vecthreethree{1}{0}{0}{0}{\cos(\tau_x)}{\sin(\tau_x)}{0}{-\sin(\tau_x)}{\cos(\tau_x)} = 00064 \vecthreethree{\cos(\tau_y)}{\sin(\tau_y)\sin(\tau_x)}{-\sin(\tau_y)\cos(\tau_x)} 00065 {0}{\cos(\tau_x)}{\sin(\tau_x)} 00066 {\sin(\tau_y)}{-\cos(\tau_y)\sin(\tau_x)}{\cos(\tau_y)\cos(\tau_x)}. 00067 \f] 00068 \param dMatTiltdTauX if not NULL it returns the derivative of matTilt with 00069 respect to \f$\tau_x\f$. 00070 \param dMatTiltdTauY if not NULL it returns the derivative of matTilt with 00071 respect to \f$\tau_y\f$. 00072 \param invMatTilt if not NULL it returns the inverse of matTilt 00073 **/ 00074 template <typename FLOAT> 00075 void computeTiltProjectionMatrix(FLOAT tauX, 00076 FLOAT tauY, 00077 Matx<FLOAT, 3, 3>* matTilt = 0, 00078 Matx<FLOAT, 3, 3>* dMatTiltdTauX = 0, 00079 Matx<FLOAT, 3, 3>* dMatTiltdTauY = 0, 00080 Matx<FLOAT, 3, 3>* invMatTilt = 0) 00081 { 00082 FLOAT cTauX = cos(tauX); 00083 FLOAT sTauX = sin(tauX); 00084 FLOAT cTauY = cos(tauY); 00085 FLOAT sTauY = sin(tauY); 00086 Matx<FLOAT, 3, 3> matRotX = Matx<FLOAT, 3, 3>(1,0,0,0,cTauX,sTauX,0,-sTauX,cTauX); 00087 Matx<FLOAT, 3, 3> matRotY = Matx<FLOAT, 3, 3>(cTauY,0,-sTauY,0,1,0,sTauY,0,cTauY); 00088 Matx<FLOAT, 3, 3> matRotXY = matRotY * matRotX; 00089 Matx<FLOAT, 3, 3> matProjZ = Matx<FLOAT, 3, 3>(matRotXY(2,2),0,-matRotXY(0,2),0,matRotXY(2,2),-matRotXY(1,2),0,0,1); 00090 if (matTilt) 00091 { 00092 // Matrix for trapezoidal distortion of tilted image sensor 00093 *matTilt = matProjZ * matRotXY; 00094 } 00095 if (dMatTiltdTauX) 00096 { 00097 // Derivative with respect to tauX 00098 Matx<FLOAT, 3, 3> dMatRotXYdTauX = matRotY * Matx<FLOAT, 3, 3>(0,0,0,0,-sTauX,cTauX,0,-cTauX,-sTauX); 00099 Matx<FLOAT, 3, 3> dMatProjZdTauX = Matx<FLOAT, 3, 3>(dMatRotXYdTauX(2,2),0,-dMatRotXYdTauX(0,2), 00100 0,dMatRotXYdTauX(2,2),-dMatRotXYdTauX(1,2),0,0,0); 00101 *dMatTiltdTauX = (matProjZ * dMatRotXYdTauX) + (dMatProjZdTauX * matRotXY); 00102 } 00103 if (dMatTiltdTauY) 00104 { 00105 // Derivative with respect to tauY 00106 Matx<FLOAT, 3, 3> dMatRotXYdTauY = Matx<FLOAT, 3, 3>(-sTauY,0,-cTauY,0,0,0,cTauY,0,-sTauY) * matRotX; 00107 Matx<FLOAT, 3, 3> dMatProjZdTauY = Matx<FLOAT, 3, 3>(dMatRotXYdTauY(2,2),0,-dMatRotXYdTauY(0,2), 00108 0,dMatRotXYdTauY(2,2),-dMatRotXYdTauY(1,2),0,0,0); 00109 *dMatTiltdTauY = (matProjZ * dMatRotXYdTauY) + (dMatProjZdTauY * matRotXY); 00110 } 00111 if (invMatTilt) 00112 { 00113 FLOAT inv = 1./matRotXY(2,2); 00114 Matx<FLOAT, 3, 3> invMatProjZ = Matx<FLOAT, 3, 3>(inv,0,inv*matRotXY(0,2),0,inv,inv*matRotXY(1,2),0,0,1); 00115 *invMatTilt = matRotXY.t()*invMatProjZ; 00116 } 00117 } 00118 }} // namespace detail, cv 00119 00120 00121 //! @endcond 00122 00123 #endif // __OPENCV_IMGPROC_DETAIL_DISTORTION_MODEL_HPP__ 00124
Generated on Tue Jul 12 2022 14:46:33 by
1.7.2
