openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

Committer:
RyoheiHagimoto
Date:
Fri Jan 29 04:53:38 2021 +0000
Revision:
0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.

Who changed what in which revision?

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