opencv on mbed

Dependencies:   mbed

Committer:
joeverbout
Date:
Thu Mar 31 21:16:38 2016 +0000
Revision:
0:ea44dc9ed014
OpenCV on mbed attempt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeverbout 0:ea44dc9ed014 1 /*M///////////////////////////////////////////////////////////////////////////////////////
joeverbout 0:ea44dc9ed014 2 //
joeverbout 0:ea44dc9ed014 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
joeverbout 0:ea44dc9ed014 4 //
joeverbout 0:ea44dc9ed014 5 // By downloading, copying, installing or using the software you agree to this license.
joeverbout 0:ea44dc9ed014 6 // If you do not agree to this license, do not download, install,
joeverbout 0:ea44dc9ed014 7 // copy or use the software.
joeverbout 0:ea44dc9ed014 8 //
joeverbout 0:ea44dc9ed014 9 //
joeverbout 0:ea44dc9ed014 10 // License Agreement
joeverbout 0:ea44dc9ed014 11 // For Open Source Computer Vision Library
joeverbout 0:ea44dc9ed014 12 //
joeverbout 0:ea44dc9ed014 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
joeverbout 0:ea44dc9ed014 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
joeverbout 0:ea44dc9ed014 15 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
joeverbout 0:ea44dc9ed014 16 // Third party copyrights are property of their respective owners.
joeverbout 0:ea44dc9ed014 17 //
joeverbout 0:ea44dc9ed014 18 // Redistribution and use in source and binary forms, with or without modification,
joeverbout 0:ea44dc9ed014 19 // are permitted provided that the following conditions are met:
joeverbout 0:ea44dc9ed014 20 //
joeverbout 0:ea44dc9ed014 21 // * Redistribution's of source code must retain the above copyright notice,
joeverbout 0:ea44dc9ed014 22 // this list of conditions and the following disclaimer.
joeverbout 0:ea44dc9ed014 23 //
joeverbout 0:ea44dc9ed014 24 // * Redistribution's in binary form must reproduce the above copyright notice,
joeverbout 0:ea44dc9ed014 25 // this list of conditions and the following disclaimer in the documentation
joeverbout 0:ea44dc9ed014 26 // and/or other materials provided with the distribution.
joeverbout 0:ea44dc9ed014 27 //
joeverbout 0:ea44dc9ed014 28 // * The name of the copyright holders may not be used to endorse or promote products
joeverbout 0:ea44dc9ed014 29 // derived from this software without specific prior written permission.
joeverbout 0:ea44dc9ed014 30 //
joeverbout 0:ea44dc9ed014 31 // This software is provided by the copyright holders and contributors "as is" and
joeverbout 0:ea44dc9ed014 32 // any express or implied warranties, including, but not limited to, the implied
joeverbout 0:ea44dc9ed014 33 // warranties of merchantability and fitness for a particular purpose are disclaimed.
joeverbout 0:ea44dc9ed014 34 // In no event shall the Intel Corporation or contributors be liable for any direct,
joeverbout 0:ea44dc9ed014 35 // indirect, incidental, special, exemplary, or consequential damages
joeverbout 0:ea44dc9ed014 36 // (including, but not limited to, procurement of substitute goods or services;
joeverbout 0:ea44dc9ed014 37 // loss of use, data, or profits; or business interruption) however caused
joeverbout 0:ea44dc9ed014 38 // and on any theory of liability, whether in contract, strict liability,
joeverbout 0:ea44dc9ed014 39 // or tort (including negligence or otherwise) arising in any way out of
joeverbout 0:ea44dc9ed014 40 // the use of this software, even if advised of the possibility of such damage.
joeverbout 0:ea44dc9ed014 41 //
joeverbout 0:ea44dc9ed014 42 //M*/
joeverbout 0:ea44dc9ed014 43
joeverbout 0:ea44dc9ed014 44 #ifndef __OPENCV_CALIB3D_C_H__
joeverbout 0:ea44dc9ed014 45 #define __OPENCV_CALIB3D_C_H__
joeverbout 0:ea44dc9ed014 46
joeverbout 0:ea44dc9ed014 47 #include "opencv2/core/core_c.h"
joeverbout 0:ea44dc9ed014 48
joeverbout 0:ea44dc9ed014 49 #ifdef __cplusplus
joeverbout 0:ea44dc9ed014 50 extern "C" {
joeverbout 0:ea44dc9ed014 51 #endif
joeverbout 0:ea44dc9ed014 52
joeverbout 0:ea44dc9ed014 53 /** @addtogroup calib3d_c
joeverbout 0:ea44dc9ed014 54 @{
joeverbout 0:ea44dc9ed014 55 */
joeverbout 0:ea44dc9ed014 56
joeverbout 0:ea44dc9ed014 57 /****************************************************************************************\
joeverbout 0:ea44dc9ed014 58 * Camera Calibration, Pose Estimation and Stereo *
joeverbout 0:ea44dc9ed014 59 \****************************************************************************************/
joeverbout 0:ea44dc9ed014 60
joeverbout 0:ea44dc9ed014 61 typedef struct CvPOSITObject CvPOSITObject;
joeverbout 0:ea44dc9ed014 62
joeverbout 0:ea44dc9ed014 63 /* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
joeverbout 0:ea44dc9ed014 64 CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
joeverbout 0:ea44dc9ed014 65
joeverbout 0:ea44dc9ed014 66
joeverbout 0:ea44dc9ed014 67 /* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
joeverbout 0:ea44dc9ed014 68 an object given its model and projection in a weak-perspective case */
joeverbout 0:ea44dc9ed014 69 CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
joeverbout 0:ea44dc9ed014 70 double focal_length, CvTermCriteria criteria,
joeverbout 0:ea44dc9ed014 71 float* rotation_matrix, float* translation_vector);
joeverbout 0:ea44dc9ed014 72
joeverbout 0:ea44dc9ed014 73 /* Releases CvPOSITObject structure */
joeverbout 0:ea44dc9ed014 74 CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object );
joeverbout 0:ea44dc9ed014 75
joeverbout 0:ea44dc9ed014 76 /* updates the number of RANSAC iterations */
joeverbout 0:ea44dc9ed014 77 CVAPI(int) cvRANSACUpdateNumIters( double p, double err_prob,
joeverbout 0:ea44dc9ed014 78 int model_points, int max_iters );
joeverbout 0:ea44dc9ed014 79
joeverbout 0:ea44dc9ed014 80 CVAPI(void) cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
joeverbout 0:ea44dc9ed014 81
joeverbout 0:ea44dc9ed014 82 /* Calculates fundamental matrix given a set of corresponding points */
joeverbout 0:ea44dc9ed014 83 #define CV_FM_7POINT 1
joeverbout 0:ea44dc9ed014 84 #define CV_FM_8POINT 2
joeverbout 0:ea44dc9ed014 85
joeverbout 0:ea44dc9ed014 86 #define CV_LMEDS 4
joeverbout 0:ea44dc9ed014 87 #define CV_RANSAC 8
joeverbout 0:ea44dc9ed014 88
joeverbout 0:ea44dc9ed014 89 #define CV_FM_LMEDS_ONLY CV_LMEDS
joeverbout 0:ea44dc9ed014 90 #define CV_FM_RANSAC_ONLY CV_RANSAC
joeverbout 0:ea44dc9ed014 91 #define CV_FM_LMEDS CV_LMEDS
joeverbout 0:ea44dc9ed014 92 #define CV_FM_RANSAC CV_RANSAC
joeverbout 0:ea44dc9ed014 93
joeverbout 0:ea44dc9ed014 94 enum
joeverbout 0:ea44dc9ed014 95 {
joeverbout 0:ea44dc9ed014 96 CV_ITERATIVE = 0,
joeverbout 0:ea44dc9ed014 97 CV_EPNP = 1, // F.Moreno-Noguer, V.Lepetit and P.Fua "EPnP: Efficient Perspective-n-Point Camera Pose Estimation"
joeverbout 0:ea44dc9ed014 98 CV_P3P = 2, // X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang; "Complete Solution Classification for the Perspective-Three-Point Problem"
joeverbout 0:ea44dc9ed014 99 CV_DLS = 3 // Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP"
joeverbout 0:ea44dc9ed014 100 };
joeverbout 0:ea44dc9ed014 101
joeverbout 0:ea44dc9ed014 102 CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
joeverbout 0:ea44dc9ed014 103 CvMat* fundamental_matrix,
joeverbout 0:ea44dc9ed014 104 int method CV_DEFAULT(CV_FM_RANSAC),
joeverbout 0:ea44dc9ed014 105 double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
joeverbout 0:ea44dc9ed014 106 CvMat* status CV_DEFAULT(NULL) );
joeverbout 0:ea44dc9ed014 107
joeverbout 0:ea44dc9ed014 108 /* For each input point on one of images
joeverbout 0:ea44dc9ed014 109 computes parameters of the corresponding
joeverbout 0:ea44dc9ed014 110 epipolar line on the other image */
joeverbout 0:ea44dc9ed014 111 CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
joeverbout 0:ea44dc9ed014 112 int which_image,
joeverbout 0:ea44dc9ed014 113 const CvMat* fundamental_matrix,
joeverbout 0:ea44dc9ed014 114 CvMat* correspondent_lines );
joeverbout 0:ea44dc9ed014 115
joeverbout 0:ea44dc9ed014 116 /* Triangulation functions */
joeverbout 0:ea44dc9ed014 117
joeverbout 0:ea44dc9ed014 118 CVAPI(void) cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
joeverbout 0:ea44dc9ed014 119 CvMat* projPoints1, CvMat* projPoints2,
joeverbout 0:ea44dc9ed014 120 CvMat* points4D);
joeverbout 0:ea44dc9ed014 121
joeverbout 0:ea44dc9ed014 122 CVAPI(void) cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2,
joeverbout 0:ea44dc9ed014 123 CvMat* new_points1, CvMat* new_points2);
joeverbout 0:ea44dc9ed014 124
joeverbout 0:ea44dc9ed014 125
joeverbout 0:ea44dc9ed014 126 /* Computes the optimal new camera matrix according to the free scaling parameter alpha:
joeverbout 0:ea44dc9ed014 127 alpha=0 - only valid pixels will be retained in the undistorted image
joeverbout 0:ea44dc9ed014 128 alpha=1 - all the source image pixels will be retained in the undistorted image
joeverbout 0:ea44dc9ed014 129 */
joeverbout 0:ea44dc9ed014 130 CVAPI(void) cvGetOptimalNewCameraMatrix( const CvMat* camera_matrix,
joeverbout 0:ea44dc9ed014 131 const CvMat* dist_coeffs,
joeverbout 0:ea44dc9ed014 132 CvSize image_size, double alpha,
joeverbout 0:ea44dc9ed014 133 CvMat* new_camera_matrix,
joeverbout 0:ea44dc9ed014 134 CvSize new_imag_size CV_DEFAULT(cvSize(0,0)),
joeverbout 0:ea44dc9ed014 135 CvRect* valid_pixel_ROI CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 136 int center_principal_point CV_DEFAULT(0));
joeverbout 0:ea44dc9ed014 137
joeverbout 0:ea44dc9ed014 138 /* Converts rotation vector to rotation matrix or vice versa */
joeverbout 0:ea44dc9ed014 139 CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
joeverbout 0:ea44dc9ed014 140 CvMat* jacobian CV_DEFAULT(0) );
joeverbout 0:ea44dc9ed014 141
joeverbout 0:ea44dc9ed014 142 /* Finds perspective transformation between the object plane and image (view) plane */
joeverbout 0:ea44dc9ed014 143 CVAPI(int) cvFindHomography( const CvMat* src_points,
joeverbout 0:ea44dc9ed014 144 const CvMat* dst_points,
joeverbout 0:ea44dc9ed014 145 CvMat* homography,
joeverbout 0:ea44dc9ed014 146 int method CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 147 double ransacReprojThreshold CV_DEFAULT(3),
joeverbout 0:ea44dc9ed014 148 CvMat* mask CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 149 int maxIters CV_DEFAULT(2000),
joeverbout 0:ea44dc9ed014 150 double confidence CV_DEFAULT(0.995));
joeverbout 0:ea44dc9ed014 151
joeverbout 0:ea44dc9ed014 152 /* Computes RQ decomposition for 3x3 matrices */
joeverbout 0:ea44dc9ed014 153 CVAPI(void) cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
joeverbout 0:ea44dc9ed014 154 CvMat *matrixQx CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 155 CvMat *matrixQy CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 156 CvMat *matrixQz CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 157 CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
joeverbout 0:ea44dc9ed014 158
joeverbout 0:ea44dc9ed014 159 /* Computes projection matrix decomposition */
joeverbout 0:ea44dc9ed014 160 CVAPI(void) cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
joeverbout 0:ea44dc9ed014 161 CvMat *rotMatr, CvMat *posVect,
joeverbout 0:ea44dc9ed014 162 CvMat *rotMatrX CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 163 CvMat *rotMatrY CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 164 CvMat *rotMatrZ CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 165 CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
joeverbout 0:ea44dc9ed014 166
joeverbout 0:ea44dc9ed014 167 /* Computes d(AB)/dA and d(AB)/dB */
joeverbout 0:ea44dc9ed014 168 CVAPI(void) cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, CvMat* dABdB );
joeverbout 0:ea44dc9ed014 169
joeverbout 0:ea44dc9ed014 170 /* Computes r3 = rodrigues(rodrigues(r2)*rodrigues(r1)),
joeverbout 0:ea44dc9ed014 171 t3 = rodrigues(r2)*t1 + t2 and the respective derivatives */
joeverbout 0:ea44dc9ed014 172 CVAPI(void) cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
joeverbout 0:ea44dc9ed014 173 const CvMat* _rvec2, const CvMat* _tvec2,
joeverbout 0:ea44dc9ed014 174 CvMat* _rvec3, CvMat* _tvec3,
joeverbout 0:ea44dc9ed014 175 CvMat* dr3dr1 CV_DEFAULT(0), CvMat* dr3dt1 CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 176 CvMat* dr3dr2 CV_DEFAULT(0), CvMat* dr3dt2 CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 177 CvMat* dt3dr1 CV_DEFAULT(0), CvMat* dt3dt1 CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 178 CvMat* dt3dr2 CV_DEFAULT(0), CvMat* dt3dt2 CV_DEFAULT(0) );
joeverbout 0:ea44dc9ed014 179
joeverbout 0:ea44dc9ed014 180 /* Projects object points to the view plane using
joeverbout 0:ea44dc9ed014 181 the specified extrinsic and intrinsic camera parameters */
joeverbout 0:ea44dc9ed014 182 CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
joeverbout 0:ea44dc9ed014 183 const CvMat* translation_vector, const CvMat* camera_matrix,
joeverbout 0:ea44dc9ed014 184 const CvMat* distortion_coeffs, CvMat* image_points,
joeverbout 0:ea44dc9ed014 185 CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 186 CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 187 CvMat* dpddist CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 188 double aspect_ratio CV_DEFAULT(0));
joeverbout 0:ea44dc9ed014 189
joeverbout 0:ea44dc9ed014 190 /* Finds extrinsic camera parameters from
joeverbout 0:ea44dc9ed014 191 a few known corresponding point pairs and intrinsic parameters */
joeverbout 0:ea44dc9ed014 192 CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points,
joeverbout 0:ea44dc9ed014 193 const CvMat* image_points,
joeverbout 0:ea44dc9ed014 194 const CvMat* camera_matrix,
joeverbout 0:ea44dc9ed014 195 const CvMat* distortion_coeffs,
joeverbout 0:ea44dc9ed014 196 CvMat* rotation_vector,
joeverbout 0:ea44dc9ed014 197 CvMat* translation_vector,
joeverbout 0:ea44dc9ed014 198 int use_extrinsic_guess CV_DEFAULT(0) );
joeverbout 0:ea44dc9ed014 199
joeverbout 0:ea44dc9ed014 200 /* Computes initial estimate of the intrinsic camera parameters
joeverbout 0:ea44dc9ed014 201 in case of planar calibration target (e.g. chessboard) */
joeverbout 0:ea44dc9ed014 202 CVAPI(void) cvInitIntrinsicParams2D( const CvMat* object_points,
joeverbout 0:ea44dc9ed014 203 const CvMat* image_points,
joeverbout 0:ea44dc9ed014 204 const CvMat* npoints, CvSize image_size,
joeverbout 0:ea44dc9ed014 205 CvMat* camera_matrix,
joeverbout 0:ea44dc9ed014 206 double aspect_ratio CV_DEFAULT(1.) );
joeverbout 0:ea44dc9ed014 207
joeverbout 0:ea44dc9ed014 208 #define CV_CALIB_CB_ADAPTIVE_THRESH 1
joeverbout 0:ea44dc9ed014 209 #define CV_CALIB_CB_NORMALIZE_IMAGE 2
joeverbout 0:ea44dc9ed014 210 #define CV_CALIB_CB_FILTER_QUADS 4
joeverbout 0:ea44dc9ed014 211 #define CV_CALIB_CB_FAST_CHECK 8
joeverbout 0:ea44dc9ed014 212
joeverbout 0:ea44dc9ed014 213 // Performs a fast check if a chessboard is in the input image. This is a workaround to
joeverbout 0:ea44dc9ed014 214 // a problem of cvFindChessboardCorners being slow on images with no chessboard
joeverbout 0:ea44dc9ed014 215 // - src: input image
joeverbout 0:ea44dc9ed014 216 // - size: chessboard size
joeverbout 0:ea44dc9ed014 217 // Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
joeverbout 0:ea44dc9ed014 218 // 0 if there is no chessboard, -1 in case of error
joeverbout 0:ea44dc9ed014 219 CVAPI(int) cvCheckChessboard(IplImage* src, CvSize size);
joeverbout 0:ea44dc9ed014 220
joeverbout 0:ea44dc9ed014 221 /* Detects corners on a chessboard calibration pattern */
joeverbout 0:ea44dc9ed014 222 CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size,
joeverbout 0:ea44dc9ed014 223 CvPoint2D32f* corners,
joeverbout 0:ea44dc9ed014 224 int* corner_count CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 225 int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE) );
joeverbout 0:ea44dc9ed014 226
joeverbout 0:ea44dc9ed014 227 /* Draws individual chessboard corners or the whole chessboard detected */
joeverbout 0:ea44dc9ed014 228 CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
joeverbout 0:ea44dc9ed014 229 CvPoint2D32f* corners,
joeverbout 0:ea44dc9ed014 230 int count, int pattern_was_found );
joeverbout 0:ea44dc9ed014 231
joeverbout 0:ea44dc9ed014 232 #define CV_CALIB_USE_INTRINSIC_GUESS 1
joeverbout 0:ea44dc9ed014 233 #define CV_CALIB_FIX_ASPECT_RATIO 2
joeverbout 0:ea44dc9ed014 234 #define CV_CALIB_FIX_PRINCIPAL_POINT 4
joeverbout 0:ea44dc9ed014 235 #define CV_CALIB_ZERO_TANGENT_DIST 8
joeverbout 0:ea44dc9ed014 236 #define CV_CALIB_FIX_FOCAL_LENGTH 16
joeverbout 0:ea44dc9ed014 237 #define CV_CALIB_FIX_K1 32
joeverbout 0:ea44dc9ed014 238 #define CV_CALIB_FIX_K2 64
joeverbout 0:ea44dc9ed014 239 #define CV_CALIB_FIX_K3 128
joeverbout 0:ea44dc9ed014 240 #define CV_CALIB_FIX_K4 2048
joeverbout 0:ea44dc9ed014 241 #define CV_CALIB_FIX_K5 4096
joeverbout 0:ea44dc9ed014 242 #define CV_CALIB_FIX_K6 8192
joeverbout 0:ea44dc9ed014 243 #define CV_CALIB_RATIONAL_MODEL 16384
joeverbout 0:ea44dc9ed014 244 #define CV_CALIB_THIN_PRISM_MODEL 32768
joeverbout 0:ea44dc9ed014 245 #define CV_CALIB_FIX_S1_S2_S3_S4 65536
joeverbout 0:ea44dc9ed014 246 #define CV_CALIB_TILTED_MODEL 262144
joeverbout 0:ea44dc9ed014 247 #define CV_CALIB_FIX_TAUX_TAUY 524288
joeverbout 0:ea44dc9ed014 248
joeverbout 0:ea44dc9ed014 249
joeverbout 0:ea44dc9ed014 250 /* Finds intrinsic and extrinsic camera parameters
joeverbout 0:ea44dc9ed014 251 from a few views of known calibration pattern */
joeverbout 0:ea44dc9ed014 252 CVAPI(double) cvCalibrateCamera2( const CvMat* object_points,
joeverbout 0:ea44dc9ed014 253 const CvMat* image_points,
joeverbout 0:ea44dc9ed014 254 const CvMat* point_counts,
joeverbout 0:ea44dc9ed014 255 CvSize image_size,
joeverbout 0:ea44dc9ed014 256 CvMat* camera_matrix,
joeverbout 0:ea44dc9ed014 257 CvMat* distortion_coeffs,
joeverbout 0:ea44dc9ed014 258 CvMat* rotation_vectors CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 259 CvMat* translation_vectors CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 260 int flags CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 261 CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
joeverbout 0:ea44dc9ed014 262 CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
joeverbout 0:ea44dc9ed014 263
joeverbout 0:ea44dc9ed014 264 /* Computes various useful characteristics of the camera from the data computed by
joeverbout 0:ea44dc9ed014 265 cvCalibrateCamera2 */
joeverbout 0:ea44dc9ed014 266 CVAPI(void) cvCalibrationMatrixValues( const CvMat *camera_matrix,
joeverbout 0:ea44dc9ed014 267 CvSize image_size,
joeverbout 0:ea44dc9ed014 268 double aperture_width CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 269 double aperture_height CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 270 double *fovx CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 271 double *fovy CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 272 double *focal_length CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 273 CvPoint2D64f *principal_point CV_DEFAULT(NULL),
joeverbout 0:ea44dc9ed014 274 double *pixel_aspect_ratio CV_DEFAULT(NULL));
joeverbout 0:ea44dc9ed014 275
joeverbout 0:ea44dc9ed014 276 #define CV_CALIB_FIX_INTRINSIC 256
joeverbout 0:ea44dc9ed014 277 #define CV_CALIB_SAME_FOCAL_LENGTH 512
joeverbout 0:ea44dc9ed014 278
joeverbout 0:ea44dc9ed014 279 /* Computes the transformation from one camera coordinate system to another one
joeverbout 0:ea44dc9ed014 280 from a few correspondent views of the same calibration target. Optionally, calibrates
joeverbout 0:ea44dc9ed014 281 both cameras */
joeverbout 0:ea44dc9ed014 282 CVAPI(double) cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
joeverbout 0:ea44dc9ed014 283 const CvMat* image_points2, const CvMat* npoints,
joeverbout 0:ea44dc9ed014 284 CvMat* camera_matrix1, CvMat* dist_coeffs1,
joeverbout 0:ea44dc9ed014 285 CvMat* camera_matrix2, CvMat* dist_coeffs2,
joeverbout 0:ea44dc9ed014 286 CvSize image_size, CvMat* R, CvMat* T,
joeverbout 0:ea44dc9ed014 287 CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 288 int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC),
joeverbout 0:ea44dc9ed014 289 CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
joeverbout 0:ea44dc9ed014 290 CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)) );
joeverbout 0:ea44dc9ed014 291
joeverbout 0:ea44dc9ed014 292 #define CV_CALIB_ZERO_DISPARITY 1024
joeverbout 0:ea44dc9ed014 293
joeverbout 0:ea44dc9ed014 294 /* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
joeverbout 0:ea44dc9ed014 295 views parallel (=> to make all the epipolar lines horizontal or vertical) */
joeverbout 0:ea44dc9ed014 296 CVAPI(void) cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
joeverbout 0:ea44dc9ed014 297 const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
joeverbout 0:ea44dc9ed014 298 CvSize image_size, const CvMat* R, const CvMat* T,
joeverbout 0:ea44dc9ed014 299 CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
joeverbout 0:ea44dc9ed014 300 CvMat* Q CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 301 int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY),
joeverbout 0:ea44dc9ed014 302 double alpha CV_DEFAULT(-1),
joeverbout 0:ea44dc9ed014 303 CvSize new_image_size CV_DEFAULT(cvSize(0,0)),
joeverbout 0:ea44dc9ed014 304 CvRect* valid_pix_ROI1 CV_DEFAULT(0),
joeverbout 0:ea44dc9ed014 305 CvRect* valid_pix_ROI2 CV_DEFAULT(0));
joeverbout 0:ea44dc9ed014 306
joeverbout 0:ea44dc9ed014 307 /* Computes rectification transformations for uncalibrated pair of images using a set
joeverbout 0:ea44dc9ed014 308 of point correspondences */
joeverbout 0:ea44dc9ed014 309 CVAPI(int) cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
joeverbout 0:ea44dc9ed014 310 const CvMat* F, CvSize img_size,
joeverbout 0:ea44dc9ed014 311 CvMat* H1, CvMat* H2,
joeverbout 0:ea44dc9ed014 312 double threshold CV_DEFAULT(5));
joeverbout 0:ea44dc9ed014 313
joeverbout 0:ea44dc9ed014 314
joeverbout 0:ea44dc9ed014 315
joeverbout 0:ea44dc9ed014 316 /* stereo correspondence parameters and functions */
joeverbout 0:ea44dc9ed014 317
joeverbout 0:ea44dc9ed014 318 #define CV_STEREO_BM_NORMALIZED_RESPONSE 0
joeverbout 0:ea44dc9ed014 319 #define CV_STEREO_BM_XSOBEL 1
joeverbout 0:ea44dc9ed014 320
joeverbout 0:ea44dc9ed014 321 /* Block matching algorithm structure */
joeverbout 0:ea44dc9ed014 322 typedef struct CvStereoBMState
joeverbout 0:ea44dc9ed014 323 {
joeverbout 0:ea44dc9ed014 324 // pre-filtering (normalization of input images)
joeverbout 0:ea44dc9ed014 325 int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
joeverbout 0:ea44dc9ed014 326 int preFilterSize; // averaging window size: ~5x5..21x21
joeverbout 0:ea44dc9ed014 327 int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
joeverbout 0:ea44dc9ed014 328
joeverbout 0:ea44dc9ed014 329 // correspondence using Sum of Absolute Difference (SAD)
joeverbout 0:ea44dc9ed014 330 int SADWindowSize; // ~5x5..21x21
joeverbout 0:ea44dc9ed014 331 int minDisparity; // minimum disparity (can be negative)
joeverbout 0:ea44dc9ed014 332 int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
joeverbout 0:ea44dc9ed014 333
joeverbout 0:ea44dc9ed014 334 // post-filtering
joeverbout 0:ea44dc9ed014 335 int textureThreshold; // the disparity is only computed for pixels
joeverbout 0:ea44dc9ed014 336 // with textured enough neighborhood
joeverbout 0:ea44dc9ed014 337 int uniquenessRatio; // accept the computed disparity d* only if
joeverbout 0:ea44dc9ed014 338 // SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
joeverbout 0:ea44dc9ed014 339 // for any d != d*+/-1 within the search range.
joeverbout 0:ea44dc9ed014 340 int speckleWindowSize; // disparity variation window
joeverbout 0:ea44dc9ed014 341 int speckleRange; // acceptable range of variation in window
joeverbout 0:ea44dc9ed014 342
joeverbout 0:ea44dc9ed014 343 int trySmallerWindows; // if 1, the results may be more accurate,
joeverbout 0:ea44dc9ed014 344 // at the expense of slower processing
joeverbout 0:ea44dc9ed014 345 CvRect roi1, roi2;
joeverbout 0:ea44dc9ed014 346 int disp12MaxDiff;
joeverbout 0:ea44dc9ed014 347
joeverbout 0:ea44dc9ed014 348 // temporary buffers
joeverbout 0:ea44dc9ed014 349 CvMat* preFilteredImg0;
joeverbout 0:ea44dc9ed014 350 CvMat* preFilteredImg1;
joeverbout 0:ea44dc9ed014 351 CvMat* slidingSumBuf;
joeverbout 0:ea44dc9ed014 352 CvMat* cost;
joeverbout 0:ea44dc9ed014 353 CvMat* disp;
joeverbout 0:ea44dc9ed014 354 } CvStereoBMState;
joeverbout 0:ea44dc9ed014 355
joeverbout 0:ea44dc9ed014 356 #define CV_STEREO_BM_BASIC 0
joeverbout 0:ea44dc9ed014 357 #define CV_STEREO_BM_FISH_EYE 1
joeverbout 0:ea44dc9ed014 358 #define CV_STEREO_BM_NARROW 2
joeverbout 0:ea44dc9ed014 359
joeverbout 0:ea44dc9ed014 360 CVAPI(CvStereoBMState*) cvCreateStereoBMState(int preset CV_DEFAULT(CV_STEREO_BM_BASIC),
joeverbout 0:ea44dc9ed014 361 int numberOfDisparities CV_DEFAULT(0));
joeverbout 0:ea44dc9ed014 362
joeverbout 0:ea44dc9ed014 363 CVAPI(void) cvReleaseStereoBMState( CvStereoBMState** state );
joeverbout 0:ea44dc9ed014 364
joeverbout 0:ea44dc9ed014 365 CVAPI(void) cvFindStereoCorrespondenceBM( const CvArr* left, const CvArr* right,
joeverbout 0:ea44dc9ed014 366 CvArr* disparity, CvStereoBMState* state );
joeverbout 0:ea44dc9ed014 367
joeverbout 0:ea44dc9ed014 368 CVAPI(CvRect) cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
joeverbout 0:ea44dc9ed014 369 int numberOfDisparities, int SADWindowSize );
joeverbout 0:ea44dc9ed014 370
joeverbout 0:ea44dc9ed014 371 CVAPI(void) cvValidateDisparity( CvArr* disparity, const CvArr* cost,
joeverbout 0:ea44dc9ed014 372 int minDisparity, int numberOfDisparities,
joeverbout 0:ea44dc9ed014 373 int disp12MaxDiff CV_DEFAULT(1) );
joeverbout 0:ea44dc9ed014 374
joeverbout 0:ea44dc9ed014 375 /* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
joeverbout 0:ea44dc9ed014 376 CVAPI(void) cvReprojectImageTo3D( const CvArr* disparityImage,
joeverbout 0:ea44dc9ed014 377 CvArr* _3dImage, const CvMat* Q,
joeverbout 0:ea44dc9ed014 378 int handleMissingValues CV_DEFAULT(0) );
joeverbout 0:ea44dc9ed014 379
joeverbout 0:ea44dc9ed014 380 /** @} calib3d_c */
joeverbout 0:ea44dc9ed014 381
joeverbout 0:ea44dc9ed014 382 #ifdef __cplusplus
joeverbout 0:ea44dc9ed014 383 } // extern "C"
joeverbout 0:ea44dc9ed014 384
joeverbout 0:ea44dc9ed014 385 //////////////////////////////////////////////////////////////////////////////////////////
joeverbout 0:ea44dc9ed014 386 class CV_EXPORTS CvLevMarq
joeverbout 0:ea44dc9ed014 387 {
joeverbout 0:ea44dc9ed014 388 public:
joeverbout 0:ea44dc9ed014 389 CvLevMarq();
joeverbout 0:ea44dc9ed014 390 CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria=
joeverbout 0:ea44dc9ed014 391 cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
joeverbout 0:ea44dc9ed014 392 bool completeSymmFlag=false );
joeverbout 0:ea44dc9ed014 393 ~CvLevMarq();
joeverbout 0:ea44dc9ed014 394 void init( int nparams, int nerrs, CvTermCriteria criteria=
joeverbout 0:ea44dc9ed014 395 cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
joeverbout 0:ea44dc9ed014 396 bool completeSymmFlag=false );
joeverbout 0:ea44dc9ed014 397 bool update( const CvMat*& param, CvMat*& J, CvMat*& err );
joeverbout 0:ea44dc9ed014 398 bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm );
joeverbout 0:ea44dc9ed014 399
joeverbout 0:ea44dc9ed014 400 void clear();
joeverbout 0:ea44dc9ed014 401 void step();
joeverbout 0:ea44dc9ed014 402 enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 };
joeverbout 0:ea44dc9ed014 403
joeverbout 0:ea44dc9ed014 404 cv::Ptr<CvMat> mask;
joeverbout 0:ea44dc9ed014 405 cv::Ptr<CvMat> prevParam;
joeverbout 0:ea44dc9ed014 406 cv::Ptr<CvMat> param;
joeverbout 0:ea44dc9ed014 407 cv::Ptr<CvMat> J;
joeverbout 0:ea44dc9ed014 408 cv::Ptr<CvMat> err;
joeverbout 0:ea44dc9ed014 409 cv::Ptr<CvMat> JtJ;
joeverbout 0:ea44dc9ed014 410 cv::Ptr<CvMat> JtJN;
joeverbout 0:ea44dc9ed014 411 cv::Ptr<CvMat> JtErr;
joeverbout 0:ea44dc9ed014 412 cv::Ptr<CvMat> JtJV;
joeverbout 0:ea44dc9ed014 413 cv::Ptr<CvMat> JtJW;
joeverbout 0:ea44dc9ed014 414 double prevErrNorm, errNorm;
joeverbout 0:ea44dc9ed014 415 int lambdaLg10;
joeverbout 0:ea44dc9ed014 416 CvTermCriteria criteria;
joeverbout 0:ea44dc9ed014 417 int state;
joeverbout 0:ea44dc9ed014 418 int iters;
joeverbout 0:ea44dc9ed014 419 bool completeSymmFlag;
joeverbout 0:ea44dc9ed014 420 int solveMethod;
joeverbout 0:ea44dc9ed014 421 };
joeverbout 0:ea44dc9ed014 422
joeverbout 0:ea44dc9ed014 423 #endif
joeverbout 0:ea44dc9ed014 424
joeverbout 0:ea44dc9ed014 425 #endif /* __OPENCV_CALIB3D_C_H__ */
joeverbout 0:ea44dc9ed014 426