GSoC2011SfM
0.1
Google Summer of Code 2011: Structure from motion
|
00001 #ifndef _GSOC_SFM_POINTS_BUNDLE_RELATED_H 00002 #define _GSOC_SFM_POINTS_BUNDLE_RELATED_H 1 00003 00004 #include <vector> 00005 #include <sba.h> 00006 #include "libmv/numeric/numeric.h" 00007 #include "libmv/base/vector.h" 00008 00009 //A lot of these functions are extracted from Lourakis' SBA: 00010 //http://www.ics.forth.gr/~lourakis/sba/ 00011 00012 #include "macro.h" //SFM_EXPORTS 00013 00014 namespace OpencvSfM{ 00015 class SFM_EXPORTS SequenceAnalyzer; 00016 class SFM_EXPORTS PointOfView; 00017 00021 struct bundle_datas 00022 { 00023 libmv::vector< int >& idx; 00024 libmv::vector< libmv::Mat3 >& intraParams; 00025 libmv::vector< Eigen::Quaterniond >& rotations; 00026 libmv::vector< libmv::Vec3 >& translations; 00027 double* points3D; 00028 int cnp; 00029 int pnp; 00030 int mnp; 00031 int ncon; 00032 int mcon; 00033 00046 bundle_datas(libmv::vector< int >& index, 00047 libmv::vector< libmv::Mat3 >& i, 00048 libmv::vector< Eigen::Quaterniond >& r, 00049 libmv::vector< libmv::Vec3 >& t, 00050 int c, int p, int mp, int n, int m) 00051 :idx(index),intraParams(i),rotations(r),translations(t), 00052 cnp(c), pnp(p),mnp(mp), mcon(m),ncon(n) 00053 { 00054 points3D = NULL; 00055 } 00056 }; 00057 00058 void SFM_EXPORTS full_bundle( SequenceAnalyzer &sequence, 00059 std::vector<PointOfView>& cameras); 00060 00061 void calcImgProjFullR(double a[5],double qr0[4],double t[3],double M[3], 00062 double n[2]); 00063 00064 00065 inline static void quatMultFast(double q1[4], double q2[4], double p[4]) 00066 { 00067 double t1, t2, t3, t4, t5, t6, t7, t8, t9; 00068 //double t10, t11, t12; 00069 00070 t1=(q1[0]+q1[1])*(q2[0]+q2[1]); 00071 t2=(q1[3]-q1[2])*(q2[2]-q2[3]); 00072 t3=(q1[1]-q1[0])*(q2[2]+q2[3]); 00073 t4=(q1[2]+q1[3])*(q2[1]-q2[0]); 00074 t5=(q1[1]+q1[3])*(q2[1]+q2[2]); 00075 t6=(q1[1]-q1[3])*(q2[1]-q2[2]); 00076 t7=(q1[0]+q1[2])*(q2[0]-q2[3]); 00077 t8=(q1[0]-q1[2])*(q2[0]+q2[3]); 00078 00079 00080 t9=0.5*(t5-t6+t7+t8); 00081 p[0]= t2 + t9-t5; 00082 p[1]= t1 - t9-t6; 00083 p[2]=-t3 + t9-t8; 00084 p[3]=-t4 + t9-t7; 00085 } 00086 00087 void img_projsRTS_x(/*cameras and points*/ double *p, 00088 /*sparse matrix of 2D points*/ struct sba_crsm *idxij, 00089 /*tmp vector*/int *rcidxs, /*tmp vector*/int *rcsubs, 00090 /*out vect*/double *hx, 00091 void *adata); 00092 00093 void img_projsKRTS_x(/*cameras and points*/ double *p, 00094 /*sparse matrix of 2D points*/ struct sba_crsm *idxij, 00095 /*tmp vector*/int *rcidxs, /*tmp vector*/int *rcsubs, 00096 /*out vect*/double *hx, 00097 void *adata); 00098 00099 void img_projsRT_x(/*cameras and points*/ double *p, 00100 /*sparse matrix of 2D points*/ struct sba_crsm *idxij, 00101 /*tmp vector*/int *rcidxs, /*tmp vector*/int *rcsubs, 00102 /*out vect*/double *hx, 00103 void *adata); 00104 void calcImgProjJacRTS(double a[5],double qr0[4],double v[3],double t[3], 00105 double M[3],double jacmRT[2][6],double jacmS[2][3]); 00106 00107 void img_projsRTS_jac_x(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *jac, void *adata); 00108 } 00109 00110 #endif