| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 | 
							
- #ifndef __OPENCV_MULTICAMERACALIBRATION_HPP__
 
- #define __OPENCV_MULTICAMERACALIBRATION_HPP__
 
- #include "opencv2/ccalib/randpattern.hpp"
 
- #include "opencv2/ccalib/omnidir.hpp"
 
- #include <string>
 
- #include <iostream>
 
- namespace cv { namespace multicalib {
 
- #define HEAD -1
 
- #define INVALID -2
 
- class CV_EXPORTS MultiCameraCalibration
 
- {
 
- public:
 
-     enum {
 
-         PINHOLE,
 
-         OMNIDIRECTIONAL
 
-         
 
-     };
 
-     
 
-     struct edge
 
-     {
 
-         int cameraVertex;   
 
-         int photoVertex;    
 
-         int photoIndex;     
 
-         Mat transform;      
 
-         edge(int cv, int pv, int pi, Mat trans)
 
-         {
 
-             cameraVertex = cv;
 
-             photoVertex = pv;
 
-             photoIndex = pi;
 
-             transform = trans;
 
-         }
 
-     };
 
-     struct vertex
 
-     {
 
-         Mat pose;   
 
-                     
 
-                     
 
-         int timestamp;  
 
-         vertex(Mat po, int ts)
 
-         {
 
-             pose = po;
 
-             timestamp = ts;
 
-         }
 
-         vertex()
 
-         {
 
-             pose = Mat::eye(4, 4, CV_32F);
 
-             timestamp = -1;
 
-         }
 
-     };
 
-     
 
-     MultiCameraCalibration(int cameraType, int nCameras, const std::string& fileName, float patternWidth,
 
-         float patternHeight, int verbose = 0, int showExtration = 0, int nMiniMatches = 20, int flags = 0,
 
-         TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 200, 1e-7),
 
-         Ptr<FeatureDetector> detector = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.006f),
 
-         Ptr<DescriptorExtractor> descriptor = AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0, 3, 0.006f),
 
-         Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-L1"));
 
-     
 
-     void loadImages();
 
-     
 
-     void initialize();
 
-     
 
-     double optimizeExtrinsics();
 
-     
 
-     double run();
 
-     
 
-     void writeParameters(const std::string& filename);
 
- private:
 
-     std::vector<std::string> readStringList();
 
-     int getPhotoVertex(int timestamp);
 
-     void graphTraverse(const Mat& G, int begin, std::vector<int>& order, std::vector<int>& pre);
 
-     void findRowNonZero(const Mat& row, Mat& idx);
 
-     void computeJacobianExtrinsic(const Mat& extrinsicParams, Mat& JTJ_inv, Mat& JTE);
 
-     void computePhotoCameraJacobian(const Mat& rvecPhoto, const Mat& tvecPhoto, const Mat& rvecCamera,
 
-         const Mat& tvecCamera, Mat& rvecTran, Mat& tvecTran, const Mat& objectPoints, const Mat& imagePoints, const Mat& K,
 
-         const Mat& distort, const Mat& xi, Mat& jacobianPhoto, Mat& jacobianCamera, Mat& E);
 
-     void compose_motion(InputArray _om1, InputArray _T1, InputArray _om2, InputArray _T2, Mat& om3, Mat& T3, Mat& dom3dom1,
 
-         Mat& dom3dT1, Mat& dom3dom2, Mat& dom3dT2, Mat& dT3dom1, Mat& dT3dT1, Mat& dT3dom2, Mat& dT3dT2);
 
-     void JRodriguesMatlab(const Mat& src, Mat& dst);
 
-     void dAB(InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB);
 
-     double computeProjectError(Mat& parameters);
 
-     void vector2parameters(const Mat& parameters, std::vector<Vec3f>& rvecVertex, std::vector<Vec3f>& tvecVertexs);
 
-     void parameters2vector(const std::vector<Vec3f>& rvecVertex, const std::vector<Vec3f>& tvecVertex, Mat& parameters);
 
-     int _camType; 
 
-     int _nCamera;
 
-     int _nMiniMatches;
 
-     int _flags;
 
- 	int _verbose;
 
-     double _error;
 
-     float _patternWidth, _patternHeight;
 
-     TermCriteria _criteria;
 
-     std::string _filename;
 
-     int _showExtraction;
 
-     Ptr<FeatureDetector> _detector;
 
-     Ptr<DescriptorExtractor> _descriptor;
 
-     Ptr<DescriptorMatcher> _matcher;
 
-     std::vector<edge> _edgeList;
 
-     std::vector<vertex> _vertexList;
 
-     std::vector<std::vector<cv::Mat> > _objectPointsForEachCamera;
 
-     std::vector<std::vector<cv::Mat> > _imagePointsForEachCamera;
 
-     std::vector<cv::Mat> _cameraMatrix;
 
-     std::vector<cv::Mat> _distortCoeffs;
 
-     std::vector<cv::Mat> _xi;
 
-     std::vector<std::vector<Mat> > _omEachCamera, _tEachCamera;
 
- };
 
- }} 
 
- #endif
 
 
  |