- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# /usr/ports/pobj/OpenCV-2.2.0/OpenCV-2.2.0/modules/calib3d/include/opencv2/calib3d/calib3d.hpp

Go to the documentation of this file.

    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_CALIB3D_HPP__
    00044 #define __OPENCV_CALIB3D_HPP__
    00045
    00046 #include "opencv2/core/core.hpp"
    00047
    00048 #ifdef __cplusplus
    00049 extern "C" {
    00050 #endif
    00051
    00052 /****************************************************************************************\
    00053 *                      Camera Calibration, Pose Estimation and Stereo                    *
    00054 \****************************************************************************************/
    00055
    00056 typedef struct CvPOSITObject CvPOSITObject;
    00057
    00058 /* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
    00059 CVAPI(CvPOSITObject*)  cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
    00060
    00061
    00062 /* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
    00063    an object given its model and projection in a weak-perspective case */
    00064 CVAPI(void)  cvPOSIT(  CvPOSITObject* posit_object, CvPoint2D32f* image_points,
    00065                        double focal_length, CvTermCriteria criteria,
    00066                        float* rotation_matrix, float* translation_vector);
    00067
    00068 /* Releases CvPOSITObject structure */
    00069 CVAPI(void)  cvReleasePOSITObject( CvPOSITObject**  posit_object );
    00070
    00071 /* updates the number of RANSAC iterations */
    00072 CVAPI(int) cvRANSACUpdateNumIters( double p, double err_prob,
    00073                                    int model_points, int max_iters );
    00074
    00075 CVAPI(void) cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
    00076
    00077 /* Calculates fundamental matrix given a set of corresponding points */
    00078 #define CV_FM_7POINT 1
    00079 #define CV_FM_8POINT 2
    00080
    00081 #define CV_LMEDS 4
    00082 #define CV_RANSAC 8
    00083
    00084 #define CV_FM_LMEDS_ONLY  CV_LMEDS
    00085 #define CV_FM_RANSAC_ONLY CV_RANSAC
    00086 #define CV_FM_LMEDS CV_LMEDS
    00087 #define CV_FM_RANSAC CV_RANSAC
    00088
    00089 CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
    00090                                  CvMat* fundamental_matrix,
    00091                                  int method CV_DEFAULT(CV_FM_RANSAC),
    00092                                  double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
    00093                                  CvMat* status CV_DEFAULT(NULL) );
    00094
    00095 /* For each input point on one of images
    00096    computes parameters of the corresponding
    00097    epipolar line on the other image */
    00098 CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
    00099                                          int which_image,
    00100                                          const CvMat* fundamental_matrix,
    00101                                          CvMat* correspondent_lines );
    00102
    00103 /* Triangulation functions */
    00104
    00105 CVAPI(void) cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
    00106                                 CvMat* projPoints1, CvMat* projPoints2,
    00107                                 CvMat* points4D);
    00108
    00109 CVAPI(void) cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2,
    00110                              CvMat* new_points1, CvMat* new_points2);
    00111
    00112
    00113 /* Computes the optimal new camera matrix according to the free scaling parameter alpha:
    00114    alpha=0 - only valid pixels will be retained in the undistorted image
    00115    alpha=1 - all the source image pixels will be retained in the undistorted image
    00116 */
    00117 CVAPI(void) cvGetOptimalNewCameraMatrix( const CvMat* camera_matrix,
    00118                                          const CvMat* dist_coeffs,
    00119                                          CvSize image_size, double alpha,
    00120                                          CvMat* new_camera_matrix,
    00121                                          CvSize new_imag_size CV_DEFAULT(cvSize(0,0)),
    00122                                          CvRect* valid_pixel_ROI CV_DEFAULT(0) );
    00123
    00124 /* Converts rotation vector to rotation matrix or vice versa */
    00125 CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
    00126                          CvMat* jacobian CV_DEFAULT(0) );
    00127
    00128 /* Finds perspective transformation between the object plane and image (view) plane */
    00129 CVAPI(int) cvFindHomography( const CvMat* src_points,
    00130                              const CvMat* dst_points,
    00131                              CvMat* homography,
    00132                              int method CV_DEFAULT(0),
    00133                              double ransacReprojThreshold CV_DEFAULT(3),
    00134                              CvMat* mask CV_DEFAULT(0));
    00135
    00136 /* Computes RQ decomposition for 3x3 matrices */
    00137 CVAPI(void) cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
    00138                            CvMat *matrixQx CV_DEFAULT(NULL),
    00139                            CvMat *matrixQy CV_DEFAULT(NULL),
    00140                            CvMat *matrixQz CV_DEFAULT(NULL),
    00141                            CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
    00142
    00143 /* Computes projection matrix decomposition */
    00144 CVAPI(void) cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
    00145                                          CvMat *rotMatr, CvMat *posVect,
    00146                                          CvMat *rotMatrX CV_DEFAULT(NULL),
    00147                                          CvMat *rotMatrY CV_DEFAULT(NULL),
    00148                                          CvMat *rotMatrZ CV_DEFAULT(NULL),
    00149                                          CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
    00150
    00151 /* Computes d(AB)/dA and d(AB)/dB */
    00152 CVAPI(void) cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, CvMat* dABdB );
    00153
    00154 /* Computes r3 = rodrigues(rodrigues(r2)*rodrigues(r1)),
    00155    t3 = rodrigues(r2)*t1 + t2 and the respective derivatives */
    00156 CVAPI(void) cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
    00157                          const CvMat* _rvec2, const CvMat* _tvec2,
    00158                          CvMat* _rvec3, CvMat* _tvec3,
    00159                          CvMat* dr3dr1 CV_DEFAULT(0), CvMat* dr3dt1 CV_DEFAULT(0),
    00160                          CvMat* dr3dr2 CV_DEFAULT(0), CvMat* dr3dt2 CV_DEFAULT(0),
    00161                          CvMat* dt3dr1 CV_DEFAULT(0), CvMat* dt3dt1 CV_DEFAULT(0),
    00162                          CvMat* dt3dr2 CV_DEFAULT(0), CvMat* dt3dt2 CV_DEFAULT(0) );
    00163
    00164 /* Projects object points to the view plane using
    00165    the specified extrinsic and intrinsic camera parameters */
    00166 CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
    00167                               const CvMat* translation_vector, const CvMat* camera_matrix,
    00168                               const CvMat* distortion_coeffs, CvMat* image_points,
    00169                               CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
    00170                               CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
    00171                               CvMat* dpddist CV_DEFAULT(NULL),
    00172                               double aspect_ratio CV_DEFAULT(0));
    00173
    00174 /* Finds extrinsic camera parameters from
    00175    a few known corresponding point pairs and intrinsic parameters */
    00176 CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points,
    00177                                           const CvMat* image_points,
    00178                                           const CvMat* camera_matrix,
    00179                                           const CvMat* distortion_coeffs,
    00180                                           CvMat* rotation_vector,
    00181                                           CvMat* translation_vector,
    00182                                           int use_extrinsic_guess CV_DEFAULT(0) );
    00183
    00184 /* Computes initial estimate of the intrinsic camera parameters
    00185    in case of planar calibration target (e.g. chessboard) */
    00186 CVAPI(void) cvInitIntrinsicParams2D( const CvMat* object_points,
    00187                                      const CvMat* image_points,
    00188                                      const CvMat* npoints, CvSize image_size,
    00189                                      CvMat* camera_matrix,
    00190                                      double aspect_ratio CV_DEFAULT(1.) );
    00191
    00192 #define CV_CALIB_CB_ADAPTIVE_THRESH  1
    00193 #define CV_CALIB_CB_NORMALIZE_IMAGE  2
    00194 #define CV_CALIB_CB_FILTER_QUADS     4
    00195 #define CV_CALIB_CB_FAST_CHECK       8
    00196
    00197 // Performs a fast check if a chessboard is in the input image. This is a workaround to
    00198 // a problem of cvFindChessboardCorners being slow on images with no chessboard
    00199 // - src: input image
    00200 // - size: chessboard size
    00201 // Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
    00202 // 0 if there is no chessboard, -1 in case of error
    00203 CVAPI(int) cvCheckChessboard(IplImage* src, CvSize size);
    00204
    00205     /* Detects corners on a chessboard calibration pattern */
    00206 CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size,
    00207                                     CvPoint2D32f* corners,
    00208                                     int* corner_count CV_DEFAULT(NULL),
    00209                                     int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+
    00210                                         CV_CALIB_CB_NORMALIZE_IMAGE) );
    00211
    00212 /* Draws individual chessboard corners or the whole chessboard detected */
    00213 CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
    00214                                      CvPoint2D32f* corners,
    00215                                      int count, int pattern_was_found );
    00216
    00217 #define CV_CALIB_USE_INTRINSIC_GUESS  1
    00218 #define CV_CALIB_FIX_ASPECT_RATIO     2
    00219 #define CV_CALIB_FIX_PRINCIPAL_POINT  4
    00220 #define CV_CALIB_ZERO_TANGENT_DIST    8
    00221 #define CV_CALIB_FIX_FOCAL_LENGTH 16
    00222 #define CV_CALIB_FIX_K1  32
    00223 #define CV_CALIB_FIX_K2  64
    00224 #define CV_CALIB_FIX_K3  128
    00225 #define CV_CALIB_FIX_K4  2048
    00226 #define CV_CALIB_FIX_K5  4096
    00227 #define CV_CALIB_FIX_K6  8192
    00228 #define CV_CALIB_RATIONAL_MODEL 16384
    00229
    00230 /* Finds intrinsic and extrinsic camera parameters
    00231    from a few views of known calibration pattern */
    00232 CVAPI(double) cvCalibrateCamera2( const CvMat* object_points,
    00233                                 const CvMat* image_points,
    00234                                 const CvMat* point_counts,
    00235                                 CvSize image_size,
    00236                                 CvMat* camera_matrix,
    00237                                 CvMat* distortion_coeffs,
    00238                                 CvMat* rotation_vectors CV_DEFAULT(NULL),
    00239                                 CvMat* translation_vectors CV_DEFAULT(NULL),
    00240                                 int flags CV_DEFAULT(0) );
    00241
    00242 /* Computes various useful characteristics of the camera from the data computed by
    00243    cvCalibrateCamera2 */
    00244 CVAPI(void) cvCalibrationMatrixValues( const CvMat *camera_matrix,
    00245                                 CvSize image_size,
    00246                                 double aperture_width CV_DEFAULT(0),
    00247                                 double aperture_height CV_DEFAULT(0),
    00248                                 double *fovx CV_DEFAULT(NULL),
    00249                                 double *fovy CV_DEFAULT(NULL),
    00250                                 double *focal_length CV_DEFAULT(NULL),
    00251                                 CvPoint2D64f *principal_point CV_DEFAULT(NULL),
    00252                                 double *pixel_aspect_ratio CV_DEFAULT(NULL));
    00253
    00254 #define CV_CALIB_FIX_INTRINSIC  256
    00255 #define CV_CALIB_SAME_FOCAL_LENGTH 512
    00256
    00257 /* Computes the transformation from one camera coordinate system to another one
    00258    from a few correspondent views of the same calibration target. Optionally, calibrates
    00259    both cameras */
    00260 CVAPI(double) cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
    00261                                const CvMat* image_points2, const CvMat* npoints,
    00262                                CvMat* camera_matrix1, CvMat* dist_coeffs1,
    00263                                CvMat* camera_matrix2, CvMat* dist_coeffs2,
    00264                                CvSize image_size, CvMat* R, CvMat* T,
    00265                                CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
    00266                                CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
    00267                                    CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)),
    00268                                int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC));
    00269
    00270 #define CV_CALIB_ZERO_DISPARITY 1024
    00271
    00272 /* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
    00273    views parallel (=> to make all the epipolar lines horizontal or vertical) */
    00274 CVAPI(void) cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
    00275                              const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
    00276                              CvSize image_size, const CvMat* R, const CvMat* T,
    00277                              CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
    00278                              CvMat* Q CV_DEFAULT(0),
    00279                              int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY),
    00280                              double alpha CV_DEFAULT(-1),
    00281                              CvSize new_image_size CV_DEFAULT(cvSize(0,0)),
    00282                              CvRect* valid_pix_ROI1 CV_DEFAULT(0),
    00283                              CvRect* valid_pix_ROI2 CV_DEFAULT(0));
    00284
    00285 /* Computes rectification transformations for uncalibrated pair of images using a set
    00286    of point correspondences */
    00287 CVAPI(int) cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
    00288                                         const CvMat* F, CvSize img_size,
    00289                                         CvMat* H1, CvMat* H2,
    00290                                         double threshold CV_DEFAULT(5));
    00291
    00292
    00293
    00294 /* stereo correspondence parameters and functions */
    00295
    00296 #define CV_STEREO_BM_NORMALIZED_RESPONSE  0
    00297 #define CV_STEREO_BM_XSOBEL               1
    00298
    00299 /* Block matching algorithm structure */
    00300 typedef struct CvStereoBMState
    00301 {
    00302     // pre-filtering (normalization of input images)
    00303     int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
    00304     int preFilterSize; // averaging window size: ~5x5..21x21
    00305     int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
    00306
    00307     // correspondence using Sum of Absolute Difference (SAD)
    00308     int SADWindowSize; // ~5x5..21x21
    00309     int minDisparity;  // minimum disparity (can be negative)
    00310     int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
    00311
    00312     // post-filtering
    00313     int textureThreshold;  // the disparity is only computed for pixels
    00314                            // with textured enough neighborhood
    00315     int uniquenessRatio;   // accept the computed disparity d* only if
    00316                            // SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
    00317                            // for any d != d*+/-1 within the search range.
    00318     int speckleWindowSize; // disparity variation window
    00319     int speckleRange; // acceptable range of variation in window
    00320
    00321     int trySmallerWindows; // if 1, the results may be more accurate,
    00322                            // at the expense of slower processing
    00323     CvRect roi1, roi2;
    00324     int disp12MaxDiff;
    00325
    00326     // temporary buffers
    00327     CvMat* preFilteredImg0;
    00328     CvMat* preFilteredImg1;
    00329     CvMat* slidingSumBuf;
    00330     CvMat* cost;
    00331     CvMat* disp;
    00332 } CvStereoBMState;
    00333
    00334 #define CV_STEREO_BM_BASIC 0
    00335 #define CV_STEREO_BM_FISH_EYE 1
    00336 #define CV_STEREO_BM_NARROW 2
    00337
    00338 CVAPI(CvStereoBMState*) cvCreateStereoBMState(int preset CV_DEFAULT(CV_STEREO_BM_BASIC),
    00339                                               int numberOfDisparities CV_DEFAULT(0));
    00340
    00341 CVAPI(void) cvReleaseStereoBMState( CvStereoBMState** state );
    00342
    00343 CVAPI(void) cvFindStereoCorrespondenceBM( const CvArr* left, const CvArr* right,
    00344                                           CvArr* disparity, CvStereoBMState* state );
    00345
    00346 CVAPI(CvRect) cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
    00347                                       int numberOfDisparities, int SADWindowSize );
    00348
    00349 CVAPI(void) cvValidateDisparity( CvArr* disparity, const CvArr* cost,
    00350                                  int minDisparity, int numberOfDisparities,
    00351                                  int disp12MaxDiff CV_DEFAULT(1) );
    00352
    00353 /* Kolmogorov-Zabin stereo-correspondence algorithm (a.k.a. KZ1) */
    00354 #define CV_STEREO_GC_OCCLUDED  SHRT_MAX
    00355
    00356 typedef struct CvStereoGCState
    00357 {
    00358     int Ithreshold;
    00359     int interactionRadius;
    00360     float K, lambda, lambda1, lambda2;
    00361     int occlusionCost;
    00362     int minDisparity;
    00363     int numberOfDisparities;
    00364     int maxIters;
    00365
    00366     CvMat* left;
    00367     CvMat* right;
    00368     CvMat* dispLeft;
    00369     CvMat* dispRight;
    00370     CvMat* ptrLeft;
    00371     CvMat* ptrRight;
    00372     CvMat* vtxBuf;
    00373     CvMat* edgeBuf;
    00374 } CvStereoGCState;
    00375
    00376 CVAPI(CvStereoGCState*) cvCreateStereoGCState( int numberOfDisparities, int maxIters );
    00377 CVAPI(void) cvReleaseStereoGCState( CvStereoGCState** state );
    00378
    00379 CVAPI(void) cvFindStereoCorrespondenceGC( const CvArr* left, const CvArr* right,
    00380                                           CvArr* disparityLeft, CvArr* disparityRight,
    00381                                           CvStereoGCState* state,
    00382                                           int useDisparityGuess CV_DEFAULT(0) );
    00383
    00384 /* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
    00385 CVAPI(void)  cvReprojectImageTo3D( const CvArr* disparityImage,
    00386                                    CvArr* _3dImage, const CvMat* Q,
    00387                                    int handleMissingValues CV_DEFAULT(0) );
    00388
    00389
    00390 #ifdef __cplusplus
    00391 }
    00392
    00394
    00395 class CV_EXPORTS CvLevMarq
    00396 {
    00397 public:
    00398     CvLevMarq();
    00399     CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria=
    00400               cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
    00401               bool completeSymmFlag=false );
    00402     ~CvLevMarq();
    00403     void init( int nparams, int nerrs, CvTermCriteria criteria=
    00404               cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
    00405               bool completeSymmFlag=false );
    00406     bool update( const CvMat*& param, CvMat*& J, CvMat*& err );
    00407     bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm );
    00408
    00409     void clear();
    00410     void step();
    00411     enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 };
    00412
    00413     cv::Ptr<CvMat> mask;
    00414     cv::Ptr<CvMat> prevParam;
    00415     cv::Ptr<CvMat> param;
    00416     cv::Ptr<CvMat> J;
    00417     cv::Ptr<CvMat> err;
    00418     cv::Ptr<CvMat> JtJ;
    00419     cv::Ptr<CvMat> JtJN;
    00420     cv::Ptr<CvMat> JtErr;
    00421     cv::Ptr<CvMat> JtJV;
    00422     cv::Ptr<CvMat> JtJW;
    00423     double prevErrNorm, errNorm;
    00424     int lambdaLg10;
    00425     CvTermCriteria criteria;
    00426     int state;
    00427     int iters;
    00428     bool completeSymmFlag;
    00429 };
    00430
    00431 namespace cv
    00432 {
    00433
    00435 CV_EXPORTS_W void Rodrigues(const Mat& src, CV_OUT Mat& dst);
    00436
    00438 CV_EXPORTS_AS(RodriguesJ) void Rodrigues(const Mat& src, CV_OUT Mat& dst, CV_OUT Mat& jacobian);
    00439
    00441 enum
    00442 {
    00443     LMEDS=CV_LMEDS,
    00444     RANSAC=CV_RANSAC
    00445 };
    00446
    00448 CV_EXPORTS_AS(findHomographyAndOutliers) Mat findHomography( const Mat& srcPoints,
    00449                                const Mat& dstPoints,
    00450                                vector<uchar>& mask, int method=0,
    00451                                double ransacReprojThreshold=3 );
    00452
    00454 CV_EXPORTS_W Mat findHomography( const Mat& srcPoints,
    00455                                const Mat& dstPoints,
    00456                                int method=0, double ransacReprojThreshold=3 );
    00457
    00459 CV_EXPORTS int estimateAffine3D(const Mat& from, const Mat& to, CV_OUT Mat& dst,
    00460                                 CV_OUT vector<uchar>& outliers,
    00461                                 double param1 = 3.0, double param2 = 0.99);
    00462
    00464 CV_EXPORTS void RQDecomp3x3( const Mat& M, Mat& R, Mat& Q );
    00465
    00467 CV_EXPORTS_W Vec3d RQDecomp3x3( const Mat& M, Mat& R, Mat& Q,
    00468                               CV_OUT Mat& Qx, CV_OUT Mat& Qy, CV_OUT Mat& Qz );
    00469
    00471 CV_EXPORTS void decomposeProjectionMatrix( const Mat& projMatrix, Mat& cameraMatrix,
    00472                                            Mat& rotMatrix, Mat& transVect );
    00473
    00475 CV_EXPORTS_W void decomposeProjectionMatrix( const Mat& projMatrix, CV_OUT Mat& cameraMatrix,
    00476                                            CV_OUT Mat& rotMatrix, CV_OUT Mat& transVect,
    00477                                            CV_OUT Mat& rotMatrixX, CV_OUT Mat& rotMatrixY,
    00478                                            CV_OUT Mat& rotMatrixZ, CV_OUT Vec3d& eulerAngles );
    00479
    00481 CV_EXPORTS_W void matMulDeriv( const Mat& A, const Mat& B, CV_OUT Mat& dABdA, CV_OUT Mat& dABdB );
    00482
    00484 CV_EXPORTS_W void composeRT( const Mat& rvec1, const Mat& tvec1,
    00485                            const Mat& rvec2, const Mat& tvec2,
    00486                            CV_OUT Mat& rvec3, CV_OUT Mat& tvec3 );
    00487
    00489 CV_EXPORTS_AS(composeRT_J) void composeRT( const Mat& rvec1, const Mat& tvec1,
    00490                            const Mat& rvec2, const Mat& tvec2,
    00491                            CV_OUT Mat& rvec3, CV_OUT Mat& tvec3,
    00492                            CV_OUT Mat& dr3dr1, CV_OUT Mat& dr3dt1,
    00493                            CV_OUT Mat& dr3dr2, CV_OUT Mat& dr3dt2,
    00494                            CV_OUT Mat& dt3dr1, CV_OUT Mat& dt3dt1,
    00495                            CV_OUT Mat& dt3dr2, CV_OUT Mat& dt3dt2 );
    00496
    00498 CV_EXPORTS_W void projectPoints( const Mat& objectPoints,
    00499                                const Mat& rvec, const Mat& tvec,
    00500                                const Mat& cameraMatrix,
    00501                                const Mat& distCoeffs,
    00502                                CV_OUT vector<Point2f>& imagePoints );
    00503
    00505 CV_EXPORTS_AS(projectPointsJ) void projectPoints( const Mat& objectPoints,
    00506                                const Mat& rvec, const Mat& tvec,
    00507                                const Mat& cameraMatrix,
    00508                                const Mat& distCoeffs,
    00509                                CV_OUT vector<Point2f>& imagePoints,
    00510                                CV_OUT Mat& dpdrot, CV_OUT Mat& dpdt, CV_OUT Mat& dpdf,
    00511                                CV_OUT Mat& dpdc, CV_OUT Mat& dpddist,
    00512                                double aspectRatio=0 );
    00513
    00515 CV_EXPORTS_W void solvePnP( const Mat& objectPoints,
    00516                             const Mat& imagePoints,
    00517                             const Mat& cameraMatrix,
    00518                             const Mat& distCoeffs,
    00519                             CV_OUT Mat& rvec, CV_OUT Mat& tvec,
    00520                             bool useExtrinsicGuess=false );
    00521
    00523 CV_EXPORTS_W Mat initCameraMatrix2D( const vector<vector<Point3f> >& objectPoints,
    00524                                    const vector<vector<Point2f> >& imagePoints,
    00525                                    Size imageSize, double aspectRatio=1. );
    00526
    00527
    00528 enum { CALIB_CB_ADAPTIVE_THRESH = 1, CALIB_CB_NORMALIZE_IMAGE = 2,
    00529        CALIB_CB_FILTER_QUADS = 4, CALIB_CB_FAST_CHECK = 8 };
    00530
    00532 CV_EXPORTS_W bool findChessboardCorners( const Mat& image, Size patternSize,
    00533                                          CV_OUT vector<Point2f>& corners,
    00534                                          int flags=CALIB_CB_ADAPTIVE_THRESH+
    00535                                               CALIB_CB_NORMALIZE_IMAGE );
    00536
    00538 CV_EXPORTS_W void drawChessboardCorners( Mat& image, Size patternSize,
    00539                                          const Mat& corners,
    00540                                          bool patternWasFound );
    00541
    00542 CV_EXPORTS void drawChessboardCorners( Mat& image, Size patternSize,
    00543                                        const vector<Point2f>& corners,
    00544                                        bool patternWasFound );
    00545
    00546 enum
    00547 {
    00548     CALIB_USE_INTRINSIC_GUESS = CV_CALIB_USE_INTRINSIC_GUESS,
    00549     CALIB_FIX_ASPECT_RATIO = CV_CALIB_FIX_ASPECT_RATIO,
    00550     CALIB_FIX_PRINCIPAL_POINT = CV_CALIB_FIX_PRINCIPAL_POINT,
    00551     CALIB_ZERO_TANGENT_DIST = CV_CALIB_ZERO_TANGENT_DIST,
    00552     CALIB_FIX_FOCAL_LENGTH = CV_CALIB_FIX_FOCAL_LENGTH,
    00553     CALIB_FIX_K1 = CV_CALIB_FIX_K1,
    00554     CALIB_FIX_K2 = CV_CALIB_FIX_K2,
    00555     CALIB_FIX_K3 = CV_CALIB_FIX_K3,
    00556     CALIB_FIX_K4 = CV_CALIB_FIX_K4,
    00557     CALIB_FIX_K5 = CV_CALIB_FIX_K5,
    00558     CALIB_FIX_K6 = CV_CALIB_FIX_K6,
    00559     CALIB_RATIONAL_MODEL = CV_CALIB_RATIONAL_MODEL,
    00560     // only for stereo
    00561     CALIB_FIX_INTRINSIC = CV_CALIB_FIX_INTRINSIC,
    00562     CALIB_SAME_FOCAL_LENGTH = CV_CALIB_SAME_FOCAL_LENGTH,
    00563     // for stereo rectification
    00564     CALIB_ZERO_DISPARITY = CV_CALIB_ZERO_DISPARITY
    00565 };
    00566
    00568 CV_EXPORTS_W double calibrateCamera( const vector<vector<Point3f> >& objectPoints,
    00569                                      const vector<vector<Point2f> >& imagePoints,
    00570                                      Size imageSize,
    00571                                      CV_IN_OUT Mat& cameraMatrix,
    00572                                      CV_IN_OUT Mat& distCoeffs,
    00573                                      CV_OUT vector<Mat>& rvecs, CV_OUT vector<Mat>& tvecs,
    00574                                      int flags=0 );
    00575
    00577 CV_EXPORTS_W void calibrationMatrixValues( const Mat& cameraMatrix,
    00578                                 Size imageSize,
    00579                                 double apertureWidth,
    00580                                 double apertureHeight,
    00581                                 CV_OUT double& fovx,
    00582                                 CV_OUT double& fovy,
    00583                                 CV_OUT double& focalLength,
    00584                                 CV_OUT Point2d& principalPoint,
    00585                                 CV_OUT double& aspectRatio );
    00586
    00588 CV_EXPORTS_W double stereoCalibrate( const vector<vector<Point3f> >& objectPoints,
    00589                                      const vector<vector<Point2f> >& imagePoints1,
    00590                                      const vector<vector<Point2f> >& imagePoints2,
    00591                                      CV_IN_OUT Mat& cameraMatrix1, CV_IN_OUT Mat& distCoeffs1,
    00592                                      CV_IN_OUT Mat& cameraMatrix2, CV_IN_OUT Mat& distCoeffs2,
    00593                                      Size imageSize, CV_OUT Mat& R, CV_OUT Mat& T,
    00594                                      CV_OUT Mat& E, CV_OUT Mat& F,
    00595                                      TermCriteria criteria = TermCriteria(TermCriteria::COUNT+
    00596                                          TermCriteria::EPS, 30, 1e-6),
    00597                                      int flags=CALIB_FIX_INTRINSIC );
    00598
    00599
    00601 CV_EXPORTS void stereoRectify( const Mat& cameraMatrix1, const Mat& distCoeffs1,
    00602                                const Mat& cameraMatrix2, const Mat& distCoeffs2,
    00603                                Size imageSize, const Mat& R, const Mat& T,
    00604                                CV_OUT Mat& R1, CV_OUT Mat& R2,
    00605                                CV_OUT Mat& P1, CV_OUT Mat& P2, CV_OUT Mat& Q,
    00606                                int flags=CALIB_ZERO_DISPARITY );
    00607
    00609 CV_EXPORTS_W void stereoRectify( const Mat& cameraMatrix1, const Mat& distCoeffs1,
    00610                                  const Mat& cameraMatrix2, const Mat& distCoeffs2,
    00611                                  Size imageSize, const Mat& R, const Mat& T,
    00612                                  CV_OUT Mat& R1, CV_OUT Mat& R2,
    00613                                  CV_OUT Mat& P1, CV_OUT Mat& P2, CV_OUT Mat& Q,
    00614                                  double alpha, Size newImageSize=Size(),
    00615                                  CV_OUT Rect* validPixROI1=0, CV_OUT Rect* validPixROI2=0,
    00616                                  int flags=CALIB_ZERO_DISPARITY );
    00617
    00619 CV_EXPORTS_W bool stereoRectifyUncalibrated( const Mat& points1, const Mat& points2,
    00620                                              const Mat& F, Size imgSize,
    00621                                              CV_OUT Mat& H1, CV_OUT Mat& H2,
    00622                                              double threshold=5 );
    00623
    00625 CV_EXPORTS_W float rectify3Collinear( const Mat& cameraMatrix1, const Mat& distCoeffs1,
    00626                                       const Mat& cameraMatrix2, const Mat& distCoeffs2,
    00627                                       const Mat& cameraMatrix3, const Mat& distCoeffs3,
    00628                                       const vector<vector<Point2f> >& imgpt1,
    00629                                       const vector<vector<Point2f> >& imgpt3,
    00630                                       Size imageSize, const Mat& R12, const Mat& T12,
    00631                                       const Mat& R13, const Mat& T13,
    00632                                       CV_OUT Mat& R1, CV_OUT Mat& R2, CV_OUT Mat& R3,
    00633                                       CV_OUT Mat& P1, CV_OUT Mat& P2, CV_OUT Mat& P3, CV_OUT Mat& Q,
    00634                                       double alpha, Size newImgSize,
    00635                                       CV_OUT Rect* roi1, CV_OUT Rect* roi2, int flags );
    00636
    00638 CV_EXPORTS_W Mat getOptimalNewCameraMatrix( const Mat& cameraMatrix, const Mat& distCoeffs,
    00639                                             Size imageSize, double alpha, Size newImgSize=Size(),
    00640                                             CV_OUT Rect* validPixROI=0);
    00641
    00643 CV_EXPORTS void convertPointsHomogeneous( const Mat& src, CV_OUT vector<Point3f>& dst );
    00645 CV_EXPORTS void convertPointsHomogeneous( const Mat& src, CV_OUT vector<Point2f>& dst );
    00646
    00648 enum
    00649 {
    00650     FM_7POINT = CV_FM_7POINT,
    00651     FM_8POINT = CV_FM_8POINT,
    00652     FM_LMEDS = CV_FM_LMEDS,
    00653     FM_RANSAC = CV_FM_RANSAC
    00654 };
    00655
    00657 CV_EXPORTS Mat findFundamentalMat( const Mat& points1, const Mat& points2,
    00658                                      CV_OUT vector<uchar>& mask, int method=FM_RANSAC,
    00659                                      double param1=3., double param2=0.99 );
    00660
    00662 CV_EXPORTS_W Mat findFundamentalMat( const Mat& points1, const Mat& points2,
    00663                                      int method=FM_RANSAC,
    00664                                      double param1=3., double param2=0.99 );
    00665
    00667 CV_EXPORTS void computeCorrespondEpilines( const Mat& points1,
    00668                                              int whichImage, const Mat& F,
    00669                                              CV_OUT vector<Vec3f>& lines );
    00670
    00671 template<> CV_EXPORTS void Ptr<CvStereoBMState>::delete_obj();
    00672
    00678 class CV_EXPORTS_W StereoBM
    00679 {
    00680 public:
    00681     enum { PREFILTER_NORMALIZED_RESPONSE = 0, PREFILTER_XSOBEL = 1,
    00682         BASIC_PRESET=0, FISH_EYE_PRESET=1, NARROW_PRESET=2 };
    00683
    00685     CV_WRAP StereoBM();
    00687     CV_WRAP StereoBM(int preset, int ndisparities=0, int SADWindowSize=21);
    00689     void init(int preset, int ndisparities=0, int SADWindowSize=21);
    00691     CV_WRAP_AS(compute) void operator()( const Mat& left, const Mat& right, Mat& disparity, int disptype=CV_16S );
    00692
    00694     Ptr<CvStereoBMState> state;
    00695 };
    00696
    00697
    00703 class CV_EXPORTS_W StereoSGBM
    00704 {
    00705 public:
    00706     enum { DISP_SHIFT=4, DISP_SCALE = (1<<DISP_SHIFT) };
    00707
    00709     CV_WRAP StereoSGBM();
    00710
    00712     CV_WRAP StereoSGBM(int minDisparity, int numDisparities, int SADWindowSize,
    00713                int P1=0, int P2=0, int disp12MaxDiff=0,
    00714                int preFilterCap=0, int uniquenessRatio=0,
    00715                int speckleWindowSize=0, int speckleRange=0,
    00716                bool fullDP=false);
    00718     virtual ~StereoSGBM();
    00719
    00721     CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, Mat& disp);
    00722
    00723     CV_PROP_RW int minDisparity;
    00724     CV_PROP_RW int numberOfDisparities;
    00725     CV_PROP_RW int SADWindowSize;
    00726     CV_PROP_RW int preFilterCap;
    00727     CV_PROP_RW int uniquenessRatio;
    00728     CV_PROP_RW int P1;
    00729     CV_PROP_RW int P2;
    00730     CV_PROP_RW int speckleWindowSize;
    00731     CV_PROP_RW int speckleRange;
    00732     CV_PROP_RW int disp12MaxDiff;
    00733     CV_PROP_RW bool fullDP;
    00734
    00735 protected:
    00736     Mat buffer;
    00737 };
    00738
    00740 CV_EXPORTS_W void filterSpeckles( Mat& img, double newVal, int maxSpeckleSize, double maxDiff, Mat& buf );
    00741
    00743 CV_EXPORTS_W Rect getValidDisparityROI( Rect roi1, Rect roi2,
    00744                                         int minDisparity, int numberOfDisparities,
    00745                                         int SADWindowSize );
    00746
    00748 CV_EXPORTS_W void validateDisparity( Mat& disparity, const Mat& cost,
    00749                                      int minDisparity, int numberOfDisparities,
    00750                                      int disp12MaxDisp=1 );
    00751
    00753 CV_EXPORTS_W void reprojectImageTo3D( const Mat& disparity,
    00754                                       CV_OUT Mat& _3dImage, const Mat& Q,
    00755                                       bool handleMissingValues=false );
    00756
    00757 }
    00758
    00759 #endif
    00760
    00761 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines