backport C++ 3d/calibration_base.cpp:5.x to calib3d/calibration_base.cpp:4.x (#26414)

* Add vanilla calibration_base from 5.x

This is from 55105719dd

* Have the C implementation use the new C++ one.
pull/26435/head
Vincent Rabaud 3 weeks ago committed by GitHub
parent 5817b562b3
commit 6873bdee70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 65
      modules/calib3d/src/calib3d_c_api.h
  2. 1922
      modules/calib3d/src/calibration.cpp
  3. 1644
      modules/calib3d/src/calibration_base.cpp
  4. 1
      modules/calib3d/src/checkchessboard.cpp
  5. 13
      modules/calib3d/src/precomp.hpp
  6. 8
      modules/calib3d/src/solvepnp.cpp

@ -111,23 +111,6 @@ void cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
void cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2,
CvMat* new_points1, CvMat* new_points2);
/* Computes the optimal new camera matrix according to the free scaling parameter alpha:
alpha=0 - only valid pixels will be retained in the undistorted image
alpha=1 - all the source image pixels will be retained in the undistorted image
*/
void cvGetOptimalNewCameraMatrix( const CvMat* camera_matrix,
const CvMat* dist_coeffs,
CvSize image_size, double alpha,
CvMat* new_camera_matrix,
CvSize new_imag_size CV_DEFAULT(cvSize(0,0)),
CvRect* valid_pixel_ROI CV_DEFAULT(0),
int center_principal_point CV_DEFAULT(0));
/* Converts rotation vector to rotation matrix or vice versa */
int cvRodrigues2( const CvMat* src, CvMat* dst,
CvMat* jacobian CV_DEFAULT(0) );
/* Finds perspective transformation between the object plane and image (view) plane */
int cvFindHomography( const CvMat* src_points,
const CvMat* dst_points,
@ -138,54 +121,6 @@ int cvFindHomography( const CvMat* src_points,
int maxIters CV_DEFAULT(2000),
double confidence CV_DEFAULT(0.995));
/* Computes RQ decomposition for 3x3 matrices */
void cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
CvMat *matrixQx CV_DEFAULT(NULL),
CvMat *matrixQy CV_DEFAULT(NULL),
CvMat *matrixQz CV_DEFAULT(NULL),
CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
/* Computes projection matrix decomposition */
void cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
CvMat *rotMatr, CvMat *posVect,
CvMat *rotMatrX CV_DEFAULT(NULL),
CvMat *rotMatrY CV_DEFAULT(NULL),
CvMat *rotMatrZ CV_DEFAULT(NULL),
CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
/* Computes d(AB)/dA and d(AB)/dB */
void cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, CvMat* dABdB );
/* Computes r3 = rodrigues(rodrigues(r2)*rodrigues(r1)),
t3 = rodrigues(r2)*t1 + t2 and the respective derivatives */
void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
const CvMat* _rvec2, const CvMat* _tvec2,
CvMat* _rvec3, CvMat* _tvec3,
CvMat* dr3dr1 CV_DEFAULT(0), CvMat* dr3dt1 CV_DEFAULT(0),
CvMat* dr3dr2 CV_DEFAULT(0), CvMat* dr3dt2 CV_DEFAULT(0),
CvMat* dt3dr1 CV_DEFAULT(0), CvMat* dt3dt1 CV_DEFAULT(0),
CvMat* dt3dr2 CV_DEFAULT(0), CvMat* dt3dt2 CV_DEFAULT(0) );
/* Projects object points to the view plane using
the specified extrinsic and intrinsic camera parameters */
void cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
const CvMat* translation_vector, const CvMat* camera_matrix,
const CvMat* distortion_coeffs, CvMat* image_points,
CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
CvMat* dpddist CV_DEFAULT(NULL),
double aspect_ratio CV_DEFAULT(0));
/* Finds extrinsic camera parameters from
a few known corresponding point pairs and intrinsic parameters */
void cvFindExtrinsicCameraParams2( const CvMat* object_points,
const CvMat* image_points,
const CvMat* camera_matrix,
const CvMat* distortion_coeffs,
CvMat* rotation_vector,
CvMat* translation_vector,
int use_extrinsic_guess CV_DEFAULT(0) );
/* Computes initial estimate of the intrinsic camera parameters
in case of planar calibration target (e.g. chessboard) */
void cvInitIntrinsicParams2D( const CvMat* object_points,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -40,7 +40,6 @@
//M*/
#include "precomp.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "calib3d_c_api.h"
#include <vector>

@ -137,6 +137,19 @@ static inline bool haveCollinearPoints( const Mat& m, int count )
return false;
}
void findExtrinsicCameraParams2( const Mat& objectPoints,
const Mat& imagePoints, const Mat& A,
const Mat& distCoeffs, Mat& rvec, Mat& tvec,
int useExtrinsicGuess );
void projectPoints( InputArray objectPoints,
InputArray rvec, InputArray tvec,
InputArray cameraMatrix, InputArray distCoeffs,
OutputArray imagePoints, OutputArray dpdr,
OutputArray dpdt, OutputArray dpdf=noArray(),
OutputArray dpdc=noArray(), OutputArray dpdk=noArray(),
OutputArray dpdo=noArray(), double aspectRatio=0.);
} // namespace cv
int checkChessboardBinary(const cv::Mat & img, const cv::Size & size);

@ -48,7 +48,6 @@
#include "ap3p.h"
#include "ippe.hpp"
#include "sqpnp.hpp"
#include "calib3d_c_api.h"
#include "usac.hpp"
@ -892,12 +891,7 @@ int solvePnPGeneric( InputArray _opoints, InputArray _ipoints,
tvec.create(3, 1, CV_64FC1);
}
CvMat c_objectPoints = cvMat(opoints), c_imagePoints = cvMat(ipoints);
CvMat c_cameraMatrix = cvMat(cameraMatrix), c_distCoeffs = cvMat(distCoeffs);
CvMat c_rvec = cvMat(rvec), c_tvec = cvMat(tvec);
cvFindExtrinsicCameraParams2(&c_objectPoints, &c_imagePoints, &c_cameraMatrix,
(c_distCoeffs.rows && c_distCoeffs.cols) ? &c_distCoeffs : 0,
&c_rvec, &c_tvec, useExtrinsicGuess );
findExtrinsicCameraParams2(opoints, ipoints, cameraMatrix, distCoeffs, rvec, tvec, useExtrinsicGuess);
vec_rvecs.push_back(rvec);
vec_tvecs.push_back(tvec);

Loading…
Cancel
Save