Cinder

  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

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