mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
mostly removed obsolete C API from calib3d (at least at the interface level) (#13081)
This commit is contained in:
parent
8cdf7bb84b
commit
8f15a609af
@ -255,7 +255,8 @@ enum { CALIB_CB_SYMMETRIC_GRID = 1,
|
||||
CALIB_CB_CLUSTERING = 4
|
||||
};
|
||||
|
||||
enum { CALIB_USE_INTRINSIC_GUESS = 0x00001,
|
||||
enum { CALIB_NINTRINSIC = 18,
|
||||
CALIB_USE_INTRINSIC_GUESS = 0x00001,
|
||||
CALIB_FIX_ASPECT_RATIO = 0x00002,
|
||||
CALIB_FIX_PRINCIPAL_POINT = 0x00004,
|
||||
CALIB_ZERO_TANGENT_DIST = 0x00008,
|
||||
@ -316,6 +317,68 @@ An example program about pose estimation from coplanar points
|
||||
Check @ref tutorial_homography "the corresponding tutorial" for more details
|
||||
*/
|
||||
|
||||
/** Levenberg-Marquardt solver. Starting with the specified vector of parameters it
|
||||
optimizes the target vector criteria "err"
|
||||
(finds local minima of each target vector component absolute value).
|
||||
|
||||
When needed, it calls user-provided callback.
|
||||
*/
|
||||
class CV_EXPORTS LMSolver : public Algorithm
|
||||
{
|
||||
public:
|
||||
class CV_EXPORTS Callback
|
||||
{
|
||||
public:
|
||||
virtual ~Callback() {}
|
||||
/**
|
||||
computes error and Jacobian for the specified vector of parameters
|
||||
|
||||
@param param the current vector of parameters
|
||||
@param err output vector of errors: err_i = actual_f_i - ideal_f_i
|
||||
@param J output Jacobian: J_ij = d(err_i)/d(param_j)
|
||||
|
||||
when J=noArray(), it means that it does not need to be computed.
|
||||
Dimensionality of error vector and param vector can be different.
|
||||
The callback should explicitly allocate (with "create" method) each output array
|
||||
(unless it's noArray()).
|
||||
*/
|
||||
virtual bool compute(InputArray param, OutputArray err, OutputArray J) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
Runs Levenberg-Marquardt algorithm using the passed vector of parameters as the start point.
|
||||
The final vector of parameters (whether the algorithm converged or not) is stored at the same
|
||||
vector. The method returns the number of iterations used. If it's equal to the previously specified
|
||||
maxIters, there is a big chance the algorithm did not converge.
|
||||
|
||||
@param param initial/final vector of parameters.
|
||||
|
||||
Note that the dimensionality of parameter space is defined by the size of param vector,
|
||||
and the dimensionality of optimized criteria is defined by the size of err vector
|
||||
computed by the callback.
|
||||
*/
|
||||
virtual int run(InputOutputArray param) const = 0;
|
||||
|
||||
/**
|
||||
Sets the maximum number of iterations
|
||||
@param maxIters the number of iterations
|
||||
*/
|
||||
virtual void setMaxIters(int maxIters) = 0;
|
||||
/**
|
||||
Retrieves the current maximum number of iterations
|
||||
*/
|
||||
virtual int getMaxIters() const = 0;
|
||||
|
||||
/**
|
||||
Creates Levenberg-Marquard solver
|
||||
|
||||
@param cb callback
|
||||
@param maxIters maximum number of iterations that can be further
|
||||
modified using setMaxIters() method.
|
||||
*/
|
||||
static Ptr<LMSolver> create(const Ptr<LMSolver::Callback>& cb, int maxIters);
|
||||
};
|
||||
|
||||
/** @brief Finds a perspective transformation between two planes.
|
||||
|
||||
@param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
|
||||
@ -2779,4 +2842,44 @@ optimization. It stays at the center or at a different location specified when C
|
||||
|
||||
} //end namespace cv
|
||||
|
||||
#if 0 //def __cplusplus
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
class CV_EXPORTS CvLevMarq
|
||||
{
|
||||
public:
|
||||
CvLevMarq();
|
||||
CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria=
|
||||
cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
|
||||
bool completeSymmFlag=false );
|
||||
~CvLevMarq();
|
||||
void init( int nparams, int nerrs, CvTermCriteria criteria=
|
||||
cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
|
||||
bool completeSymmFlag=false );
|
||||
bool update( const CvMat*& param, CvMat*& J, CvMat*& err );
|
||||
bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm );
|
||||
|
||||
void clear();
|
||||
void step();
|
||||
enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 };
|
||||
|
||||
cv::Ptr<CvMat> mask;
|
||||
cv::Ptr<CvMat> prevParam;
|
||||
cv::Ptr<CvMat> param;
|
||||
cv::Ptr<CvMat> J;
|
||||
cv::Ptr<CvMat> err;
|
||||
cv::Ptr<CvMat> JtJ;
|
||||
cv::Ptr<CvMat> JtJN;
|
||||
cv::Ptr<CvMat> JtErr;
|
||||
cv::Ptr<CvMat> JtJV;
|
||||
cv::Ptr<CvMat> JtJW;
|
||||
double prevErrNorm, errNorm;
|
||||
int lambdaLg10;
|
||||
CvTermCriteria criteria;
|
||||
int state;
|
||||
int iters;
|
||||
bool completeSymmFlag;
|
||||
int solveMethod;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -44,41 +44,12 @@
|
||||
#ifndef OPENCV_CALIB3D_C_H
|
||||
#define OPENCV_CALIB3D_C_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/core/types_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup calib3d_c
|
||||
@{
|
||||
*/
|
||||
|
||||
/****************************************************************************************\
|
||||
* Camera Calibration, Pose Estimation and Stereo *
|
||||
\****************************************************************************************/
|
||||
|
||||
typedef struct CvPOSITObject CvPOSITObject;
|
||||
|
||||
/* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
|
||||
CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
|
||||
|
||||
|
||||
/* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
|
||||
an object given its model and projection in a weak-perspective case */
|
||||
CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
|
||||
double focal_length, CvTermCriteria criteria,
|
||||
float* rotation_matrix, float* translation_vector);
|
||||
|
||||
/* Releases CvPOSITObject structure */
|
||||
CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object );
|
||||
|
||||
/* updates the number of RANSAC iterations */
|
||||
CVAPI(int) cvRANSACUpdateNumIters( double p, double err_prob,
|
||||
int model_points, int max_iters );
|
||||
|
||||
CVAPI(void) cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
|
||||
|
||||
/* Calculates fundamental matrix given a set of corresponding points */
|
||||
#define CV_FM_7POINT 1
|
||||
#define CV_FM_8POINT 2
|
||||
@ -99,136 +70,11 @@ enum
|
||||
CV_DLS = 3 // Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP"
|
||||
};
|
||||
|
||||
CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
|
||||
CvMat* fundamental_matrix,
|
||||
int method CV_DEFAULT(CV_FM_RANSAC),
|
||||
double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
|
||||
CvMat* status CV_DEFAULT(NULL) );
|
||||
|
||||
/* For each input point on one of images
|
||||
computes parameters of the corresponding
|
||||
epipolar line on the other image */
|
||||
CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
|
||||
int which_image,
|
||||
const CvMat* fundamental_matrix,
|
||||
CvMat* correspondent_lines );
|
||||
|
||||
/* Triangulation functions */
|
||||
|
||||
CVAPI(void) cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
|
||||
CvMat* projPoints1, CvMat* projPoints2,
|
||||
CvMat* points4D);
|
||||
|
||||
CVAPI(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
|
||||
*/
|
||||
CVAPI(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 */
|
||||
CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
|
||||
CvMat* jacobian CV_DEFAULT(0) );
|
||||
|
||||
/* Finds perspective transformation between the object plane and image (view) plane */
|
||||
CVAPI(int) cvFindHomography( const CvMat* src_points,
|
||||
const CvMat* dst_points,
|
||||
CvMat* homography,
|
||||
int method CV_DEFAULT(0),
|
||||
double ransacReprojThreshold CV_DEFAULT(3),
|
||||
CvMat* mask CV_DEFAULT(0),
|
||||
int maxIters CV_DEFAULT(2000),
|
||||
double confidence CV_DEFAULT(0.995));
|
||||
|
||||
/* Computes RQ decomposition for 3x3 matrices */
|
||||
CVAPI(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 */
|
||||
CVAPI(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 */
|
||||
CVAPI(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 */
|
||||
CVAPI(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 */
|
||||
CVAPI(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 */
|
||||
CVAPI(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) */
|
||||
CVAPI(void) cvInitIntrinsicParams2D( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* npoints, CvSize image_size,
|
||||
CvMat* camera_matrix,
|
||||
double aspect_ratio CV_DEFAULT(1.) );
|
||||
|
||||
#define CV_CALIB_CB_ADAPTIVE_THRESH 1
|
||||
#define CV_CALIB_CB_NORMALIZE_IMAGE 2
|
||||
#define CV_CALIB_CB_FILTER_QUADS 4
|
||||
#define CV_CALIB_CB_FAST_CHECK 8
|
||||
|
||||
// Performs a fast check if a chessboard is in the input image. This is a workaround to
|
||||
// a problem of cvFindChessboardCorners being slow on images with no chessboard
|
||||
// - src: input image
|
||||
// - size: chessboard size
|
||||
// Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
|
||||
// 0 if there is no chessboard, -1 in case of error
|
||||
CVAPI(int) cvCheckChessboard(IplImage* src, CvSize size);
|
||||
|
||||
/* Detects corners on a chessboard calibration pattern */
|
||||
CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size,
|
||||
CvPoint2D32f* corners,
|
||||
int* corner_count CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE) );
|
||||
|
||||
/* Draws individual chessboard corners or the whole chessboard detected */
|
||||
CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
|
||||
CvPoint2D32f* corners,
|
||||
int count, int pattern_was_found );
|
||||
|
||||
#define CV_CALIB_USE_INTRINSIC_GUESS 1
|
||||
#define CV_CALIB_FIX_ASPECT_RATIO 2
|
||||
#define CV_CALIB_FIX_PRINCIPAL_POINT 4
|
||||
@ -249,187 +95,15 @@ CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
|
||||
|
||||
#define CV_CALIB_NINTRINSIC 18
|
||||
|
||||
/* Finds intrinsic and extrinsic camera parameters
|
||||
from a few views of known calibration pattern */
|
||||
CVAPI(double) cvCalibrateCamera2( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* point_counts,
|
||||
CvSize image_size,
|
||||
CvMat* camera_matrix,
|
||||
CvMat* distortion_coeffs,
|
||||
CvMat* rotation_vectors CV_DEFAULT(NULL),
|
||||
CvMat* translation_vectors CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(0),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
|
||||
|
||||
/* Finds intrinsic and extrinsic camera parameters
|
||||
from a few views of known calibration pattern */
|
||||
CVAPI(double) cvCalibrateCamera4( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* point_counts,
|
||||
CvSize image_size,
|
||||
int iFixedPoint,
|
||||
CvMat* camera_matrix,
|
||||
CvMat* distortion_coeffs,
|
||||
CvMat* rotation_vectors CV_DEFAULT(NULL),
|
||||
CvMat* translation_vectors CV_DEFAULT(NULL),
|
||||
CvMat* newObjPoints CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(0),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
|
||||
|
||||
/* Computes various useful characteristics of the camera from the data computed by
|
||||
cvCalibrateCamera2 */
|
||||
CVAPI(void) cvCalibrationMatrixValues( const CvMat *camera_matrix,
|
||||
CvSize image_size,
|
||||
double aperture_width CV_DEFAULT(0),
|
||||
double aperture_height CV_DEFAULT(0),
|
||||
double *fovx CV_DEFAULT(NULL),
|
||||
double *fovy CV_DEFAULT(NULL),
|
||||
double *focal_length CV_DEFAULT(NULL),
|
||||
CvPoint2D64f *principal_point CV_DEFAULT(NULL),
|
||||
double *pixel_aspect_ratio CV_DEFAULT(NULL));
|
||||
|
||||
#define CV_CALIB_FIX_INTRINSIC 256
|
||||
#define CV_CALIB_SAME_FOCAL_LENGTH 512
|
||||
|
||||
/* Computes the transformation from one camera coordinate system to another one
|
||||
from a few correspondent views of the same calibration target. Optionally, calibrates
|
||||
both cameras */
|
||||
CVAPI(double) cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
|
||||
const CvMat* image_points2, const CvMat* npoints,
|
||||
CvMat* camera_matrix1, CvMat* dist_coeffs1,
|
||||
CvMat* camera_matrix2, CvMat* dist_coeffs2,
|
||||
CvSize image_size, CvMat* R, CvMat* T,
|
||||
CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
|
||||
int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)) );
|
||||
|
||||
#define CV_CALIB_ZERO_DISPARITY 1024
|
||||
|
||||
/* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
|
||||
views parallel (=> to make all the epipolar lines horizontal or vertical) */
|
||||
CVAPI(void) cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
|
||||
const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
|
||||
CvSize image_size, const CvMat* R, const CvMat* T,
|
||||
CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
|
||||
CvMat* Q CV_DEFAULT(0),
|
||||
int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY),
|
||||
double alpha CV_DEFAULT(-1),
|
||||
CvSize new_image_size CV_DEFAULT(cvSize(0,0)),
|
||||
CvRect* valid_pix_ROI1 CV_DEFAULT(0),
|
||||
CvRect* valid_pix_ROI2 CV_DEFAULT(0));
|
||||
|
||||
/* Computes rectification transformations for uncalibrated pair of images using a set
|
||||
of point correspondences */
|
||||
CVAPI(int) cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
|
||||
const CvMat* F, CvSize img_size,
|
||||
CvMat* H1, CvMat* H2,
|
||||
double threshold CV_DEFAULT(5));
|
||||
|
||||
|
||||
|
||||
/* stereo correspondence parameters and functions */
|
||||
|
||||
#define CV_STEREO_BM_NORMALIZED_RESPONSE 0
|
||||
#define CV_STEREO_BM_XSOBEL 1
|
||||
|
||||
/* Block matching algorithm structure */
|
||||
typedef struct CvStereoBMState
|
||||
{
|
||||
// pre-filtering (normalization of input images)
|
||||
int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
|
||||
int preFilterSize; // averaging window size: ~5x5..21x21
|
||||
int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
|
||||
|
||||
// correspondence using Sum of Absolute Difference (SAD)
|
||||
int SADWindowSize; // ~5x5..21x21
|
||||
int minDisparity; // minimum disparity (can be negative)
|
||||
int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
|
||||
|
||||
// post-filtering
|
||||
int textureThreshold; // the disparity is only computed for pixels
|
||||
// with textured enough neighborhood
|
||||
int uniquenessRatio; // accept the computed disparity d* only if
|
||||
// SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
|
||||
// for any d != d*+/-1 within the search range.
|
||||
int speckleWindowSize; // disparity variation window
|
||||
int speckleRange; // acceptable range of variation in window
|
||||
|
||||
int trySmallerWindows; // if 1, the results may be more accurate,
|
||||
// at the expense of slower processing
|
||||
CvRect roi1, roi2;
|
||||
int disp12MaxDiff;
|
||||
|
||||
// temporary buffers
|
||||
CvMat* preFilteredImg0;
|
||||
CvMat* preFilteredImg1;
|
||||
CvMat* slidingSumBuf;
|
||||
CvMat* cost;
|
||||
CvMat* disp;
|
||||
} CvStereoBMState;
|
||||
|
||||
#define CV_STEREO_BM_BASIC 0
|
||||
#define CV_STEREO_BM_FISH_EYE 1
|
||||
#define CV_STEREO_BM_NARROW 2
|
||||
|
||||
CVAPI(CvStereoBMState*) cvCreateStereoBMState(int preset CV_DEFAULT(CV_STEREO_BM_BASIC),
|
||||
int numberOfDisparities CV_DEFAULT(0));
|
||||
|
||||
CVAPI(void) cvReleaseStereoBMState( CvStereoBMState** state );
|
||||
|
||||
CVAPI(void) cvFindStereoCorrespondenceBM( const CvArr* left, const CvArr* right,
|
||||
CvArr* disparity, CvStereoBMState* state );
|
||||
|
||||
CVAPI(CvRect) cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
|
||||
int numberOfDisparities, int SADWindowSize );
|
||||
|
||||
CVAPI(void) cvValidateDisparity( CvArr* disparity, const CvArr* cost,
|
||||
int minDisparity, int numberOfDisparities,
|
||||
int disp12MaxDiff CV_DEFAULT(1) );
|
||||
|
||||
/* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
|
||||
CVAPI(void) cvReprojectImageTo3D( const CvArr* disparityImage,
|
||||
CvArr* _3dImage, const CvMat* Q,
|
||||
int handleMissingValues CV_DEFAULT(0) );
|
||||
|
||||
/** @brief Transforms the input image to compensate lens distortion
|
||||
@see cv::undistort
|
||||
*/
|
||||
CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
|
||||
const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs,
|
||||
const CvMat* new_camera_matrix CV_DEFAULT(0) );
|
||||
|
||||
/** @brief Computes transformation map from intrinsic camera parameters
|
||||
that can used by cvRemap
|
||||
*/
|
||||
CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs,
|
||||
CvArr* mapx, CvArr* mapy );
|
||||
|
||||
/** @brief Computes undistortion+rectification map for a head of stereo camera
|
||||
@see cv::initUndistortRectifyMap
|
||||
*/
|
||||
CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix,
|
||||
const CvMat* dist_coeffs,
|
||||
const CvMat *R, const CvMat* new_camera_matrix,
|
||||
CvArr* mapx, CvArr* mapy );
|
||||
|
||||
/** @brief Computes the original (undistorted) feature coordinates
|
||||
from the observed (distorted) coordinates
|
||||
@see cv::undistortPoints
|
||||
*/
|
||||
CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst,
|
||||
const CvMat* camera_matrix,
|
||||
const CvMat* dist_coeffs,
|
||||
const CvMat* R CV_DEFAULT(0),
|
||||
const CvMat* P CV_DEFAULT(0));
|
||||
|
||||
/** @} calib3d_c */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
|
@ -1,47 +0,0 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
// This file contains wrappers for legacy OpenCV C API
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
CV_IMPL void
|
||||
cvDrawChessboardCorners(CvArr* _image, CvSize pattern_size,
|
||||
CvPoint2D32f* corners, int count, int found)
|
||||
{
|
||||
CV_Assert(corners != NULL); //CV_CheckNULL(corners, "NULL is not allowed for 'corners' parameter");
|
||||
Mat image = cvarrToMat(_image);
|
||||
CV_StaticAssert(sizeof(CvPoint2D32f) == sizeof(Point2f), "");
|
||||
drawChessboardCorners(image, pattern_size, Mat(1, count, traits::Type<Point2f>::value, corners), found != 0);
|
||||
}
|
||||
|
||||
CV_IMPL int
|
||||
cvFindChessboardCorners(const void* arr, CvSize pattern_size,
|
||||
CvPoint2D32f* out_corners_, int* out_corner_count,
|
||||
int flags)
|
||||
{
|
||||
if (!out_corners_)
|
||||
CV_Error( CV_StsNullPtr, "Null pointer to corners" );
|
||||
|
||||
Mat image = cvarrToMat(arr);
|
||||
std::vector<Point2f> out_corners;
|
||||
|
||||
if (out_corner_count)
|
||||
*out_corner_count = 0;
|
||||
|
||||
bool res = cv::findChessboardCorners(image, pattern_size, out_corners, flags);
|
||||
|
||||
int corner_count = (int)out_corners.size();
|
||||
if (out_corner_count)
|
||||
*out_corner_count = corner_count;
|
||||
CV_CheckLE(corner_count, Size(pattern_size).area(), "Unexpected number of corners");
|
||||
for (int i = 0; i < corner_count; ++i)
|
||||
{
|
||||
out_corners_[i] = cvPoint2D32f(out_corners[i]);
|
||||
}
|
||||
return res ? 1 : 0;
|
||||
}
|
425
modules/calib3d/src/calib3d_c_api.h
Normal file
425
modules/calib3d/src/calib3d_c_api.h
Normal file
@ -0,0 +1,425 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CALIB3D_C_API_H
|
||||
#define OPENCV_CALIB3D_C_API_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup calib3d_c
|
||||
@{
|
||||
*/
|
||||
|
||||
/****************************************************************************************\
|
||||
* Camera Calibration, Pose Estimation and Stereo *
|
||||
\****************************************************************************************/
|
||||
|
||||
typedef struct CvPOSITObject CvPOSITObject;
|
||||
|
||||
/* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
|
||||
CvPOSITObject* cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
|
||||
|
||||
|
||||
/* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
|
||||
an object given its model and projection in a weak-perspective case */
|
||||
void cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
|
||||
double focal_length, CvTermCriteria criteria,
|
||||
float* rotation_matrix, float* translation_vector);
|
||||
|
||||
/* Releases CvPOSITObject structure */
|
||||
void cvReleasePOSITObject( CvPOSITObject** posit_object );
|
||||
|
||||
/* updates the number of RANSAC iterations */
|
||||
int cvRANSACUpdateNumIters( double p, double err_prob,
|
||||
int model_points, int max_iters );
|
||||
|
||||
void cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
|
||||
|
||||
/* Calculates fundamental matrix given a set of corresponding points */
|
||||
/*#define CV_FM_7POINT 1
|
||||
#define CV_FM_8POINT 2
|
||||
|
||||
#define CV_LMEDS 4
|
||||
#define CV_RANSAC 8
|
||||
|
||||
#define CV_FM_LMEDS_ONLY CV_LMEDS
|
||||
#define CV_FM_RANSAC_ONLY CV_RANSAC
|
||||
#define CV_FM_LMEDS CV_LMEDS
|
||||
#define CV_FM_RANSAC CV_RANSAC*/
|
||||
|
||||
int cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
|
||||
CvMat* fundamental_matrix,
|
||||
int method CV_DEFAULT(CV_FM_RANSAC),
|
||||
double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
|
||||
CvMat* status CV_DEFAULT(NULL) );
|
||||
|
||||
/* For each input point on one of images
|
||||
computes parameters of the corresponding
|
||||
epipolar line on the other image */
|
||||
void cvComputeCorrespondEpilines( const CvMat* points,
|
||||
int which_image,
|
||||
const CvMat* fundamental_matrix,
|
||||
CvMat* correspondent_lines );
|
||||
|
||||
/* Triangulation functions */
|
||||
|
||||
void cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
|
||||
CvMat* projPoints1, CvMat* projPoints2,
|
||||
CvMat* points4D);
|
||||
|
||||
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,
|
||||
CvMat* homography,
|
||||
int method CV_DEFAULT(0),
|
||||
double ransacReprojThreshold CV_DEFAULT(3),
|
||||
CvMat* mask CV_DEFAULT(0),
|
||||
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,
|
||||
const CvMat* image_points,
|
||||
const CvMat* npoints, CvSize image_size,
|
||||
CvMat* camera_matrix,
|
||||
double aspect_ratio CV_DEFAULT(1.) );
|
||||
|
||||
// Performs a fast check if a chessboard is in the input image. This is a workaround to
|
||||
// a problem of cvFindChessboardCorners being slow on images with no chessboard
|
||||
// - src: input image
|
||||
// - size: chessboard size
|
||||
// Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
|
||||
// 0 if there is no chessboard, -1 in case of error
|
||||
int cvCheckChessboard(IplImage* src, CvSize size);
|
||||
|
||||
/* Detects corners on a chessboard calibration pattern */
|
||||
/*int cvFindChessboardCorners( const void* image, CvSize pattern_size,
|
||||
CvPoint2D32f* corners,
|
||||
int* corner_count CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE) );*/
|
||||
|
||||
/* Draws individual chessboard corners or the whole chessboard detected */
|
||||
/*void cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
|
||||
CvPoint2D32f* corners,
|
||||
int count, int pattern_was_found );*/
|
||||
|
||||
/*#define CV_CALIB_USE_INTRINSIC_GUESS 1
|
||||
#define CV_CALIB_FIX_ASPECT_RATIO 2
|
||||
#define CV_CALIB_FIX_PRINCIPAL_POINT 4
|
||||
#define CV_CALIB_ZERO_TANGENT_DIST 8
|
||||
#define CV_CALIB_FIX_FOCAL_LENGTH 16
|
||||
#define CV_CALIB_FIX_K1 32
|
||||
#define CV_CALIB_FIX_K2 64
|
||||
#define CV_CALIB_FIX_K3 128
|
||||
#define CV_CALIB_FIX_K4 2048
|
||||
#define CV_CALIB_FIX_K5 4096
|
||||
#define CV_CALIB_FIX_K6 8192
|
||||
#define CV_CALIB_RATIONAL_MODEL 16384
|
||||
#define CV_CALIB_THIN_PRISM_MODEL 32768
|
||||
#define CV_CALIB_FIX_S1_S2_S3_S4 65536
|
||||
#define CV_CALIB_TILTED_MODEL 262144
|
||||
#define CV_CALIB_FIX_TAUX_TAUY 524288
|
||||
#define CV_CALIB_FIX_TANGENT_DIST 2097152
|
||||
|
||||
#define CV_CALIB_NINTRINSIC 18*/
|
||||
|
||||
/* Finds intrinsic and extrinsic camera parameters
|
||||
from a few views of known calibration pattern */
|
||||
double cvCalibrateCamera2( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* point_counts,
|
||||
CvSize image_size,
|
||||
CvMat* camera_matrix,
|
||||
CvMat* distortion_coeffs,
|
||||
CvMat* rotation_vectors CV_DEFAULT(NULL),
|
||||
CvMat* translation_vectors CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(0),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
|
||||
|
||||
/* Finds intrinsic and extrinsic camera parameters
|
||||
from a few views of known calibration pattern */
|
||||
double cvCalibrateCamera4( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* point_counts,
|
||||
CvSize image_size,
|
||||
int iFixedPoint,
|
||||
CvMat* camera_matrix,
|
||||
CvMat* distortion_coeffs,
|
||||
CvMat* rotation_vectors CV_DEFAULT(NULL),
|
||||
CvMat* translation_vectors CV_DEFAULT(NULL),
|
||||
CvMat* newObjPoints CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(0),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
|
||||
|
||||
/* Computes various useful characteristics of the camera from the data computed by
|
||||
cvCalibrateCamera2 */
|
||||
void cvCalibrationMatrixValues( const CvMat *camera_matrix,
|
||||
CvSize image_size,
|
||||
double aperture_width CV_DEFAULT(0),
|
||||
double aperture_height CV_DEFAULT(0),
|
||||
double *fovx CV_DEFAULT(NULL),
|
||||
double *fovy CV_DEFAULT(NULL),
|
||||
double *focal_length CV_DEFAULT(NULL),
|
||||
CvPoint2D64f *principal_point CV_DEFAULT(NULL),
|
||||
double *pixel_aspect_ratio CV_DEFAULT(NULL));
|
||||
|
||||
/*#define CV_CALIB_FIX_INTRINSIC 256
|
||||
#define CV_CALIB_SAME_FOCAL_LENGTH 512*/
|
||||
|
||||
/* Computes the transformation from one camera coordinate system to another one
|
||||
from a few correspondent views of the same calibration target. Optionally, calibrates
|
||||
both cameras */
|
||||
double cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
|
||||
const CvMat* image_points2, const CvMat* npoints,
|
||||
CvMat* camera_matrix1, CvMat* dist_coeffs1,
|
||||
CvMat* camera_matrix2, CvMat* dist_coeffs2,
|
||||
CvSize image_size, CvMat* R, CvMat* T,
|
||||
CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
|
||||
int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)) );
|
||||
|
||||
#define CV_CALIB_ZERO_DISPARITY 1024
|
||||
|
||||
/* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
|
||||
views parallel (=> to make all the epipolar lines horizontal or vertical) */
|
||||
void cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
|
||||
const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
|
||||
CvSize image_size, const CvMat* R, const CvMat* T,
|
||||
CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
|
||||
CvMat* Q CV_DEFAULT(0),
|
||||
int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY),
|
||||
double alpha CV_DEFAULT(-1),
|
||||
CvSize new_image_size CV_DEFAULT(cvSize(0,0)),
|
||||
CvRect* valid_pix_ROI1 CV_DEFAULT(0),
|
||||
CvRect* valid_pix_ROI2 CV_DEFAULT(0));
|
||||
|
||||
/* Computes rectification transformations for uncalibrated pair of images using a set
|
||||
of point correspondences */
|
||||
int cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
|
||||
const CvMat* F, CvSize img_size,
|
||||
CvMat* H1, CvMat* H2,
|
||||
double threshold CV_DEFAULT(5));
|
||||
|
||||
|
||||
|
||||
/* stereo correspondence parameters and functions */
|
||||
|
||||
#define CV_STEREO_BM_NORMALIZED_RESPONSE 0
|
||||
#define CV_STEREO_BM_XSOBEL 1
|
||||
|
||||
/* Block matching algorithm structure */
|
||||
typedef struct CvStereoBMState
|
||||
{
|
||||
// pre-filtering (normalization of input images)
|
||||
int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
|
||||
int preFilterSize; // averaging window size: ~5x5..21x21
|
||||
int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
|
||||
|
||||
// correspondence using Sum of Absolute Difference (SAD)
|
||||
int SADWindowSize; // ~5x5..21x21
|
||||
int minDisparity; // minimum disparity (can be negative)
|
||||
int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
|
||||
|
||||
// post-filtering
|
||||
int textureThreshold; // the disparity is only computed for pixels
|
||||
// with textured enough neighborhood
|
||||
int uniquenessRatio; // accept the computed disparity d* only if
|
||||
// SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
|
||||
// for any d != d*+/-1 within the search range.
|
||||
int speckleWindowSize; // disparity variation window
|
||||
int speckleRange; // acceptable range of variation in window
|
||||
|
||||
int trySmallerWindows; // if 1, the results may be more accurate,
|
||||
// at the expense of slower processing
|
||||
CvRect roi1, roi2;
|
||||
int disp12MaxDiff;
|
||||
|
||||
// temporary buffers
|
||||
CvMat* preFilteredImg0;
|
||||
CvMat* preFilteredImg1;
|
||||
CvMat* slidingSumBuf;
|
||||
CvMat* cost;
|
||||
CvMat* disp;
|
||||
} CvStereoBMState;
|
||||
|
||||
#define CV_STEREO_BM_BASIC 0
|
||||
#define CV_STEREO_BM_FISH_EYE 1
|
||||
#define CV_STEREO_BM_NARROW 2
|
||||
|
||||
CvStereoBMState* cvCreateStereoBMState(int preset CV_DEFAULT(CV_STEREO_BM_BASIC),
|
||||
int numberOfDisparities CV_DEFAULT(0));
|
||||
|
||||
void cvReleaseStereoBMState( CvStereoBMState** state );
|
||||
|
||||
void cvFindStereoCorrespondenceBM( const CvArr* left, const CvArr* right,
|
||||
CvArr* disparity, CvStereoBMState* state );
|
||||
|
||||
CvRect cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
|
||||
int numberOfDisparities, int SADWindowSize );
|
||||
|
||||
void cvValidateDisparity( CvArr* disparity, const CvArr* cost,
|
||||
int minDisparity, int numberOfDisparities,
|
||||
int disp12MaxDiff CV_DEFAULT(1) );
|
||||
|
||||
/* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
|
||||
void cvReprojectImageTo3D( const CvArr* disparityImage,
|
||||
CvArr* _3dImage, const CvMat* Q,
|
||||
int handleMissingValues CV_DEFAULT(0) );
|
||||
|
||||
/** @brief Transforms the input image to compensate lens distortion
|
||||
@see cv::undistort
|
||||
*/
|
||||
void cvUndistort2( const CvArr* src, CvArr* dst,
|
||||
const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs,
|
||||
const CvMat* new_camera_matrix CV_DEFAULT(0) );
|
||||
|
||||
/** @brief Computes transformation map from intrinsic camera parameters
|
||||
that can used by cvRemap
|
||||
*/
|
||||
void cvInitUndistortMap( const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs,
|
||||
CvArr* mapx, CvArr* mapy );
|
||||
|
||||
/** @brief Computes undistortion+rectification map for a head of stereo camera
|
||||
@see cv::initUndistortRectifyMap
|
||||
*/
|
||||
void cvInitUndistortRectifyMap( const CvMat* camera_matrix,
|
||||
const CvMat* dist_coeffs,
|
||||
const CvMat *R, const CvMat* new_camera_matrix,
|
||||
CvArr* mapx, CvArr* mapy );
|
||||
|
||||
/** @brief Computes the original (undistorted) feature coordinates
|
||||
from the observed (distorted) coordinates
|
||||
@see cv::undistortPoints
|
||||
*/
|
||||
void cvUndistortPoints( const CvMat* src, CvMat* dst,
|
||||
const CvMat* camera_matrix,
|
||||
const CvMat* dist_coeffs,
|
||||
const CvMat* R CV_DEFAULT(0),
|
||||
const CvMat* P CV_DEFAULT(0));
|
||||
|
||||
/** @} calib3d_c */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* OPENCV_CALIB3D_C_API_H */
|
@ -43,7 +43,7 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "distortion_model.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "calib3d_c_api.h"
|
||||
#include <stdio.h>
|
||||
#include <iterator>
|
||||
|
||||
@ -3003,15 +3003,22 @@ void cv::reprojectImageTo3D( InputArray _disparity,
|
||||
stype == CV_32SC1 || stype == CV_32FC1 );
|
||||
CV_Assert( Q.size() == Size(4,4) );
|
||||
|
||||
if( dtype >= 0 )
|
||||
dtype = CV_MAKETYPE(CV_MAT_DEPTH(dtype), 3);
|
||||
|
||||
if( __3dImage.fixedType() )
|
||||
{
|
||||
int dtype_ = __3dImage.type();
|
||||
CV_Assert( dtype == -1 || dtype == dtype_ );
|
||||
dtype = dtype_;
|
||||
}
|
||||
|
||||
if( dtype < 0 )
|
||||
dtype = CV_32FC3;
|
||||
else
|
||||
{
|
||||
dtype = CV_MAKETYPE(CV_MAT_DEPTH(dtype), 3);
|
||||
CV_Assert( dtype == CV_16SC3 || dtype == CV_32SC3 || dtype == CV_32FC3 );
|
||||
}
|
||||
|
||||
__3dImage.create(disparity.size(), CV_MAKETYPE(dtype, 3));
|
||||
__3dImage.create(disparity.size(), dtype);
|
||||
Mat _3dImage = __3dImage.getMat();
|
||||
|
||||
const float bigZ = 10000.f;
|
||||
@ -3423,11 +3430,13 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints,
|
||||
imgPtMat2, npoints );
|
||||
}
|
||||
|
||||
static Mat prepareCameraMatrix(Mat& cameraMatrix0, int rtype)
|
||||
static Mat prepareCameraMatrix(Mat& cameraMatrix0, int rtype, int flags)
|
||||
{
|
||||
Mat cameraMatrix = Mat::eye(3, 3, rtype);
|
||||
if( cameraMatrix0.size() == cameraMatrix.size() )
|
||||
cameraMatrix0.convertTo(cameraMatrix, rtype);
|
||||
else if( flags & CALIB_USE_INTRINSIC_GUESS )
|
||||
CV_Error(Error::StsBadArg, "CALIB_USE_INTRINSIC_GUESS flag is set, but the camera matrix is not 3x3");
|
||||
return cameraMatrix;
|
||||
}
|
||||
|
||||
@ -3544,6 +3553,8 @@ void cv::projectPoints( InputArray _opoints,
|
||||
CvMat dpdrot, dpdt, dpdf, dpdc, dpddist;
|
||||
CvMat *pdpdrot=0, *pdpdt=0, *pdpdf=0, *pdpdc=0, *pdpddist=0;
|
||||
|
||||
CV_Assert( _ipoints.needed() );
|
||||
|
||||
_ipoints.create(npoints, 1, CV_MAKETYPE(depth, 2), -1, true);
|
||||
Mat imagePoints = _ipoints.getMat();
|
||||
CvMat c_imagePoints = cvMat(imagePoints);
|
||||
@ -3650,8 +3661,12 @@ double cv::calibrateCameraRO(InputArrayOfArrays _objectPoints,
|
||||
CV_INSTRUMENT_REGION();
|
||||
|
||||
int rtype = CV_64F;
|
||||
|
||||
CV_Assert( _cameraMatrix.needed() );
|
||||
CV_Assert( _distCoeffs.needed() );
|
||||
|
||||
Mat cameraMatrix = _cameraMatrix.getMat();
|
||||
cameraMatrix = prepareCameraMatrix(cameraMatrix, rtype);
|
||||
cameraMatrix = prepareCameraMatrix(cameraMatrix, rtype, flags);
|
||||
Mat distCoeffs = _distCoeffs.getMat();
|
||||
distCoeffs = (flags & CALIB_THIN_PRISM_MODEL) && !(flags & CALIB_TILTED_MODEL) ? prepareDistCoeffs(distCoeffs, rtype, 12) :
|
||||
prepareDistCoeffs(distCoeffs, rtype);
|
||||
@ -3864,8 +3879,8 @@ double cv::stereoCalibrate( InputArrayOfArrays _objectPoints,
|
||||
Mat cameraMatrix2 = _cameraMatrix2.getMat();
|
||||
Mat distCoeffs1 = _distCoeffs1.getMat();
|
||||
Mat distCoeffs2 = _distCoeffs2.getMat();
|
||||
cameraMatrix1 = prepareCameraMatrix(cameraMatrix1, rtype);
|
||||
cameraMatrix2 = prepareCameraMatrix(cameraMatrix2, rtype);
|
||||
cameraMatrix1 = prepareCameraMatrix(cameraMatrix1, rtype, flags);
|
||||
cameraMatrix2 = prepareCameraMatrix(cameraMatrix2, rtype, flags);
|
||||
distCoeffs1 = prepareDistCoeffs(distCoeffs1, rtype);
|
||||
distCoeffs2 = prepareDistCoeffs(distCoeffs2, rtype);
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "calib3d_c_api.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
@ -41,7 +41,8 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "calib3d_c_api.h"
|
||||
|
||||
/************************************************************************************\
|
||||
Some backward compatibility stuff, to be moved to legacy or compat module
|
||||
@ -321,7 +322,6 @@ void CvLevMarq::step()
|
||||
param->data.db[i] = prevParam->data.db[i] - (mask->data.ptr[i] ? nonzero_param(j++) : 0);
|
||||
}
|
||||
|
||||
|
||||
CV_IMPL int cvRANSACUpdateNumIters( double p, double ep, int modelPoints, int maxIters )
|
||||
{
|
||||
return cv::RANSACUpdateNumIters(p, ep, modelPoints, maxIters);
|
||||
|
@ -1,123 +0,0 @@
|
||||
//M*//////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
CvStereoBMState* cvCreateStereoBMState( int /*preset*/, int numberOfDisparities )
|
||||
{
|
||||
CvStereoBMState* state = (CvStereoBMState*)cvAlloc( sizeof(*state) );
|
||||
if( !state )
|
||||
return 0;
|
||||
|
||||
state->preFilterType = CV_STEREO_BM_XSOBEL; //CV_STEREO_BM_NORMALIZED_RESPONSE;
|
||||
state->preFilterSize = 9;
|
||||
state->preFilterCap = 31;
|
||||
state->SADWindowSize = 15;
|
||||
state->minDisparity = 0;
|
||||
state->numberOfDisparities = numberOfDisparities > 0 ? numberOfDisparities : 64;
|
||||
state->textureThreshold = 10;
|
||||
state->uniquenessRatio = 15;
|
||||
state->speckleRange = state->speckleWindowSize = 0;
|
||||
state->trySmallerWindows = 0;
|
||||
state->roi1 = state->roi2 = cvRect(0,0,0,0);
|
||||
state->disp12MaxDiff = -1;
|
||||
|
||||
state->preFilteredImg0 = state->preFilteredImg1 = state->slidingSumBuf =
|
||||
state->disp = state->cost = 0;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void cvReleaseStereoBMState( CvStereoBMState** state )
|
||||
{
|
||||
if( !state )
|
||||
CV_Error( CV_StsNullPtr, "" );
|
||||
|
||||
if( !*state )
|
||||
return;
|
||||
|
||||
cvReleaseMat( &(*state)->preFilteredImg0 );
|
||||
cvReleaseMat( &(*state)->preFilteredImg1 );
|
||||
cvReleaseMat( &(*state)->slidingSumBuf );
|
||||
cvReleaseMat( &(*state)->disp );
|
||||
cvReleaseMat( &(*state)->cost );
|
||||
cvFree( state );
|
||||
}
|
||||
|
||||
void cvFindStereoCorrespondenceBM( const CvArr* leftarr, const CvArr* rightarr,
|
||||
CvArr* disparr, CvStereoBMState* state )
|
||||
{
|
||||
cv::Mat left = cv::cvarrToMat(leftarr), right = cv::cvarrToMat(rightarr);
|
||||
const cv::Mat disp = cv::cvarrToMat(disparr);
|
||||
|
||||
CV_Assert( state != 0 );
|
||||
|
||||
cv::Ptr<cv::StereoBM> sm = cv::StereoBM::create(state->numberOfDisparities,
|
||||
state->SADWindowSize);
|
||||
sm->setPreFilterType(state->preFilterType);
|
||||
sm->setPreFilterSize(state->preFilterSize);
|
||||
sm->setPreFilterCap(state->preFilterCap);
|
||||
sm->setBlockSize(state->SADWindowSize);
|
||||
sm->setNumDisparities(state->numberOfDisparities > 0 ? state->numberOfDisparities : 64);
|
||||
sm->setTextureThreshold(state->textureThreshold);
|
||||
sm->setUniquenessRatio(state->uniquenessRatio);
|
||||
sm->setSpeckleRange(state->speckleRange);
|
||||
sm->setSpeckleWindowSize(state->speckleWindowSize);
|
||||
sm->setDisp12MaxDiff(state->disp12MaxDiff);
|
||||
|
||||
sm->compute(left, right, disp);
|
||||
}
|
||||
|
||||
CvRect cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
|
||||
int numberOfDisparities, int SADWindowSize )
|
||||
{
|
||||
return cvRect(cv::getValidDisparityROI( roi1, roi2, minDisparity,
|
||||
numberOfDisparities, SADWindowSize));
|
||||
}
|
||||
|
||||
void cvValidateDisparity( CvArr* _disp, const CvArr* _cost, int minDisparity,
|
||||
int numberOfDisparities, int disp12MaxDiff )
|
||||
{
|
||||
cv::Mat disp = cv::cvarrToMat(_disp), cost = cv::cvarrToMat(_cost);
|
||||
cv::validateDisparity( disp, cost, minDisparity, numberOfDisparities, disp12MaxDiff );
|
||||
}
|
@ -411,7 +411,7 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
|
||||
if( method == RANSAC || method == LMEDS )
|
||||
cb->runKernel( src, dst, H );
|
||||
Mat H8(8, 1, CV_64F, H.ptr<double>());
|
||||
createLMSolver(makePtr<HomographyRefineCallback>(src, dst), 10)->run(H8);
|
||||
LMSolver::create(makePtr<HomographyRefineCallback>(src, dst), 10)->run(H8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,8 @@ public:
|
||||
return iter;
|
||||
}
|
||||
|
||||
void setCallback(const Ptr<LMSolver::Callback>& _cb) CV_OVERRIDE { cb = _cb; }
|
||||
void setMaxIters(int iters) CV_OVERRIDE { CV_Assert(iters > 0); maxIters = iters; }
|
||||
int getMaxIters() const CV_OVERRIDE { return maxIters; }
|
||||
|
||||
Ptr<LMSolver::Callback> cb;
|
||||
|
||||
@ -209,7 +210,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
Ptr<LMSolver> createLMSolver(const Ptr<LMSolver::Callback>& cb, int maxIters)
|
||||
Ptr<LMSolver> LMSolver::create(const Ptr<LMSolver::Callback>& cb, int maxIters)
|
||||
{
|
||||
return makePtr<LMSolverImpl>(cb, maxIters);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
//
|
||||
//M*/
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "calib3d_c_api.h"
|
||||
|
||||
/* POSIT structure */
|
||||
struct CvPOSITObject
|
||||
|
@ -76,22 +76,6 @@ namespace cv
|
||||
*/
|
||||
int RANSACUpdateNumIters( double p, double ep, int modelPoints, int maxIters );
|
||||
|
||||
class CV_EXPORTS LMSolver : public Algorithm
|
||||
{
|
||||
public:
|
||||
class CV_EXPORTS Callback
|
||||
{
|
||||
public:
|
||||
virtual ~Callback() {}
|
||||
virtual bool compute(InputArray param, OutputArray err, OutputArray J) const = 0;
|
||||
};
|
||||
|
||||
virtual void setCallback(const Ptr<LMSolver::Callback>& cb) = 0;
|
||||
virtual int run(InputOutputArray _param0) const = 0;
|
||||
};
|
||||
|
||||
CV_EXPORTS Ptr<LMSolver> createLMSolver(const Ptr<LMSolver::Callback>& cb, int maxIters);
|
||||
|
||||
class CV_EXPORTS PointSetRegistrator : public Algorithm
|
||||
{
|
||||
public:
|
||||
|
@ -863,7 +863,7 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers,
|
||||
Mat src = from.rowRange(0, inliers_count);
|
||||
Mat dst = to.rowRange(0, inliers_count);
|
||||
Mat Hvec = H.reshape(1, 6);
|
||||
createLMSolver(makePtr<Affine2DRefineCallback>(src, dst), static_cast<int>(refineIters))->run(Hvec);
|
||||
LMSolver::create(makePtr<Affine2DRefineCallback>(src, dst), static_cast<int>(refineIters))->run(Hvec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -937,7 +937,7 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie
|
||||
double *Hptr = H.ptr<double>();
|
||||
double Hvec_buf[4] = {Hptr[0], Hptr[3], Hptr[2], Hptr[5]};
|
||||
Mat Hvec (4, 1, CV_64F, Hvec_buf);
|
||||
createLMSolver(makePtr<AffinePartial2DRefineCallback>(src, dst), static_cast<int>(refineIters))->run(Hvec);
|
||||
LMSolver::create(makePtr<AffinePartial2DRefineCallback>(src, dst), static_cast<int>(refineIters))->run(Hvec);
|
||||
// update H with refined parameters
|
||||
Hptr[0] = Hptr[4] = Hvec_buf[0];
|
||||
Hptr[1] = -Hvec_buf[1];
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "epnp.h"
|
||||
#include "p3p.h"
|
||||
#include "ap3p.h"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "calib3d_c_api.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
// cvCorrectMatches function is Copyright (C) 2009, Jostein Austvik Jacobsen.
|
||||
// cvTriangulatePoints function is derived from icvReconstructPointsFor3View, originally by Valery Mosyagin.
|
||||
@ -50,8 +50,8 @@
|
||||
|
||||
|
||||
// This method is the same as icvReconstructPointsFor3View, with only a few numbers adjusted for two-view geometry
|
||||
CV_IMPL void
|
||||
cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMat* projPoints2, CvMat* points4D)
|
||||
static void
|
||||
icvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMat* projPoints2, CvMat* points4D)
|
||||
{
|
||||
if( projMatr1 == 0 || projMatr2 == 0 ||
|
||||
projPoints1 == 0 || projPoints2 == 0 ||
|
||||
@ -131,8 +131,8 @@ cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMa
|
||||
* new_points1 : the optimized points1_. if this is NULL, the corrected points are placed back in points1_
|
||||
* new_points2 : the optimized points2_. if this is NULL, the corrected points are placed back in points2_
|
||||
*/
|
||||
CV_IMPL void
|
||||
cvCorrectMatches(CvMat *F_, CvMat *points1_, CvMat *points2_, CvMat *new_points1, CvMat *new_points2)
|
||||
static void
|
||||
icvCorrectMatches(CvMat *F_, CvMat *points1_, CvMat *points2_, CvMat *new_points1, CvMat *new_points2)
|
||||
{
|
||||
cv::Ptr<CvMat> tmp33;
|
||||
cv::Ptr<CvMat> tmp31, tmp31_2;
|
||||
@ -365,7 +365,7 @@ void cv::triangulatePoints( InputArray _projMatr1, InputArray _projMatr2,
|
||||
Mat cvPoints4D_ = _points4D.getMat();
|
||||
CvMat cvPoints4D = cvMat(cvPoints4D_);
|
||||
|
||||
cvTriangulatePoints(&cvMatr1, &cvMatr2, &cvPoints1, &cvPoints2, &cvPoints4D);
|
||||
icvTriangulatePoints(&cvMatr1, &cvMatr2, &cvPoints1, &cvPoints2, &cvPoints4D);
|
||||
}
|
||||
|
||||
void cv::correctMatches( InputArray _F, InputArray _points1, InputArray _points2,
|
||||
@ -384,5 +384,5 @@ void cv::correctMatches( InputArray _F, InputArray _points1, InputArray _points2
|
||||
Mat cvNewPoints1_ = _newPoints1.getMat(), cvNewPoints2_ = _newPoints2.getMat();
|
||||
CvMat cvNewPoints1 = cvMat(cvNewPoints1_), cvNewPoints2 = cvMat(cvNewPoints2_);
|
||||
|
||||
cvCorrectMatches(&cvF, &cvPoints1, &cvPoints2, &cvNewPoints1, &cvNewPoints2);
|
||||
icvCorrectMatches(&cvF, &cvPoints1, &cvPoints2, &cvNewPoints1, &cvNewPoints2);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "distortion_model.hpp"
|
||||
#include "undistort.hpp"
|
||||
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "calib3d_c_api.h"
|
||||
|
||||
cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
|
||||
bool centerPrincipalPoint )
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,44 +41,60 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_chessboardgenerator.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "opencv2/core/types_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
class CV_CameraCalibrationBadArgTest : public cvtest::BadArgTest
|
||||
{
|
||||
public:
|
||||
CV_CameraCalibrationBadArgTest() : imgSize(800, 600) {}
|
||||
CV_CameraCalibrationBadArgTest() {}
|
||||
~CV_CameraCalibrationBadArgTest() {}
|
||||
protected:
|
||||
void run(int);
|
||||
void run_func(void) {}
|
||||
|
||||
const static int M = 2;
|
||||
|
||||
Size imgSize;
|
||||
Size corSize;
|
||||
Mat chessBoard;
|
||||
Mat corners;
|
||||
|
||||
struct C_Caller
|
||||
{
|
||||
CvMat* objPts;
|
||||
CvMat* imgPts;
|
||||
CvMat* npoints;
|
||||
Size imageSize;
|
||||
int iFixedPoint;
|
||||
CvMat *cameraMatrix;
|
||||
CvMat *distCoeffs;
|
||||
CvMat *rvecs;
|
||||
CvMat *tvecs;
|
||||
CvMat *newObjPts;
|
||||
int flags;
|
||||
_InputArray imgPts_arg;
|
||||
_InputArray objPts_arg;
|
||||
_OutputArray rvecs_arg;
|
||||
_OutputArray tvecs_arg;
|
||||
_OutputArray newObjPts_arg;
|
||||
_InputOutputArray cameraMatrix_arg;
|
||||
_InputOutputArray distCoeffs_arg;
|
||||
|
||||
std::vector<std::vector<Point2f> > imgPts;
|
||||
std::vector<std::vector<Point3f> > objPts;
|
||||
|
||||
Size imageSize0, imageSize;
|
||||
int iFixedPoint0, iFixedPoint;
|
||||
Mat cameraMatrix;
|
||||
Mat distCoeffs;
|
||||
std::vector<Mat> rvecs;
|
||||
std::vector<Mat> tvecs;
|
||||
std::vector<Point3f> newObjPts;
|
||||
int flags0, flags;
|
||||
|
||||
void initArgs()
|
||||
{
|
||||
imgPts_arg = imgPts;
|
||||
objPts_arg = objPts;
|
||||
rvecs_arg = rvecs;
|
||||
tvecs_arg = tvecs;
|
||||
newObjPts_arg = newObjPts;
|
||||
cameraMatrix_arg = cameraMatrix;
|
||||
distCoeffs_arg = distCoeffs;
|
||||
imageSize = imageSize0;
|
||||
flags = flags0;
|
||||
iFixedPoint = iFixedPoint0;
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
cvCalibrateCamera4(objPts, imgPts, npoints, cvSize(imageSize), iFixedPoint,
|
||||
cameraMatrix, distCoeffs, rvecs, tvecs, newObjPts, flags );
|
||||
calibrateCameraRO(objPts_arg, imgPts_arg, imageSize, iFixedPoint,
|
||||
cameraMatrix_arg, distCoeffs_arg, rvecs_arg, tvecs_arg,
|
||||
newObjPts_arg, flags);
|
||||
}
|
||||
};
|
||||
};
|
||||
@ -86,6 +102,8 @@ protected:
|
||||
|
||||
void CV_CameraCalibrationBadArgTest::run( int /* start_from */ )
|
||||
{
|
||||
const int M = 2;
|
||||
Size imgSize(800, 600);
|
||||
Mat_<float> camMat(3, 3);
|
||||
Mat_<float> distCoeffs0(1, 5);
|
||||
|
||||
@ -93,283 +111,92 @@ void CV_CameraCalibrationBadArgTest::run( int /* start_from */ )
|
||||
distCoeffs0 << 1.2f, 0.2f, 0.f, 0.f, 0.f;
|
||||
|
||||
ChessBoardGenerator cbg(Size(8,6));
|
||||
corSize = cbg.cornersSize();
|
||||
vector<Point2f> exp_corn;
|
||||
chessBoard = cbg(Mat(imgSize, CV_8U, Scalar(0)), camMat, distCoeffs0, exp_corn);
|
||||
Mat_<Point2f>(corSize.height, corSize.width, (Point2f*)&exp_corn[0]).copyTo(corners);
|
||||
Size corSize = cbg.cornersSize();
|
||||
vector<Point2f> corners;
|
||||
cbg(Mat(imgSize, CV_8U, Scalar(0)), camMat, distCoeffs0, corners);
|
||||
|
||||
CvMat objPts, imgPts, npoints, cameraMatrix, distCoeffs, rvecs, tvecs;
|
||||
CvMat newObjPts;
|
||||
Mat zeros(1, sizeof(CvMat), CV_8U, Scalar(0));
|
||||
|
||||
C_Caller caller, bad_caller;
|
||||
caller.imageSize = imgSize;
|
||||
caller.objPts = &objPts;
|
||||
caller.imgPts = &imgPts;
|
||||
caller.npoints = &npoints;
|
||||
caller.cameraMatrix = &cameraMatrix;
|
||||
caller.distCoeffs = &distCoeffs;
|
||||
caller.rvecs = &rvecs;
|
||||
caller.tvecs = &tvecs;
|
||||
caller.newObjPts = &newObjPts;
|
||||
C_Caller caller;
|
||||
caller.imageSize0 = imgSize;
|
||||
caller.iFixedPoint0 = -1;
|
||||
caller.flags0 = 0;
|
||||
|
||||
/////////////////////////////
|
||||
Mat objPts_cpp;
|
||||
Mat imgPts_cpp;
|
||||
Mat npoints_cpp;
|
||||
Mat cameraMatrix_cpp;
|
||||
Mat distCoeffs_cpp;
|
||||
Mat rvecs_cpp;
|
||||
Mat tvecs_cpp;
|
||||
Mat newObjPts_cpp;
|
||||
|
||||
objPts_cpp.create(corSize, CV_32FC3);
|
||||
for(int j = 0; j < corSize.height; ++j)
|
||||
for(int i = 0; i < corSize.width; ++i)
|
||||
objPts_cpp.at<Point3f>(j, i) = Point3i(i, j, 0);
|
||||
objPts_cpp = objPts_cpp.reshape(3, 1);
|
||||
Mat objPts_cpp_all(1, objPts_cpp.cols * M, CV_32FC3);
|
||||
std::vector<Point3f> objPts_cpp;
|
||||
for(int y = 0; y < corSize.height; ++y)
|
||||
for(int x = 0; x < corSize.width; ++x)
|
||||
objPts_cpp.push_back(Point3f((float)x, (float)y, 0.f));
|
||||
caller.objPts.resize(M);
|
||||
caller.imgPts.resize(M);
|
||||
for(int i = 0; i < M; i++)
|
||||
objPts_cpp.copyTo(objPts_cpp_all.colRange(objPts_cpp.cols * i, objPts_cpp.cols * (i + 1)));
|
||||
objPts_cpp = objPts_cpp_all;
|
||||
|
||||
caller.iFixedPoint = -1;
|
||||
|
||||
imgPts_cpp = corners.clone().reshape(2, 1);
|
||||
Mat imgPts_cpp_all(1, imgPts_cpp.cols * M, CV_32FC2);
|
||||
for(int i = 0; i < M; i++)
|
||||
imgPts_cpp.copyTo(imgPts_cpp_all.colRange(imgPts_cpp.cols * i, imgPts_cpp.cols * (i + 1)));
|
||||
imgPts_cpp = imgPts_cpp_all;
|
||||
npoints_cpp = Mat_<int>(M, 1, corSize.width * corSize.height);
|
||||
cameraMatrix_cpp.create(3, 3, CV_32F);
|
||||
distCoeffs_cpp.create(5, 1, CV_32F);
|
||||
rvecs_cpp.create(M, 1, CV_32FC3);
|
||||
tvecs_cpp.create(M, 1, CV_32FC3);
|
||||
newObjPts_cpp.create(corSize.width * corSize.height, 1, CV_32FC3);
|
||||
|
||||
caller.flags = 0;
|
||||
//CV_CALIB_USE_INTRINSIC_GUESS; //CV_CALIB_FIX_ASPECT_RATIO
|
||||
//CV_CALIB_USE_INTRINSIC_GUESS //CV_CALIB_FIX_ASPECT_RATIO
|
||||
//CV_CALIB_FIX_PRINCIPAL_POINT //CV_CALIB_ZERO_TANGENT_DIST
|
||||
//CV_CALIB_FIX_FOCAL_LENGTH //CV_CALIB_FIX_K1 //CV_CALIB_FIX_K2 //CV_CALIB_FIX_K3
|
||||
|
||||
objPts = cvMat(objPts_cpp);
|
||||
imgPts = cvMat(imgPts_cpp);
|
||||
npoints = cvMat(npoints_cpp);
|
||||
cameraMatrix = cvMat(cameraMatrix_cpp);
|
||||
distCoeffs = cvMat(distCoeffs_cpp);
|
||||
rvecs = cvMat(rvecs_cpp);
|
||||
tvecs = cvMat(tvecs_cpp);
|
||||
newObjPts = cvMat(newObjPts_cpp);
|
||||
{
|
||||
caller.objPts[i] = objPts_cpp;
|
||||
caller.imgPts[i] = corners;
|
||||
}
|
||||
caller.cameraMatrix.create(3, 3, CV_32F);
|
||||
caller.distCoeffs.create(5, 1, CV_32F);
|
||||
caller.rvecs.clear();
|
||||
caller.tvecs.clear();
|
||||
caller.newObjPts.clear();
|
||||
|
||||
/* /*//*/ */
|
||||
int errors = 0;
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.objPts = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero passed in objPts", bad_caller);
|
||||
caller.initArgs();
|
||||
caller.objPts_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "None passed in objPts", caller);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.imgPts = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero passed in imgPts", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.imgPts_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "None passed in imgPts", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.npoints = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero passed in npoints", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.cameraMatrix_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Zero passed in cameraMatrix", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.cameraMatrix = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero passed in cameraMatrix", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.distCoeffs_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Zero passed in distCoeffs", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero passed in distCoeffs", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.imageSize.width = -1;
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad image width", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.imageSize.width = -1;
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad image width", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.imageSize.height = -1;
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad image height", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.imageSize.height = -1;
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad image height", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.imgPts[0].clear();
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "Bad imgpts[0]", caller );
|
||||
caller.imgPts[0] = caller.imgPts[1];
|
||||
|
||||
Mat bad_nts_cpp1 = Mat_<float>(M, 1, 1.f);
|
||||
Mat bad_nts_cpp2 = Mat_<int>(3, 3, corSize.width * corSize.height);
|
||||
CvMat bad_npts_c1 = cvMat(bad_nts_cpp1);
|
||||
CvMat bad_npts_c2 = cvMat(bad_nts_cpp2);
|
||||
caller.initArgs();
|
||||
caller.objPts[1].clear();
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "Bad objpts[1]", caller );
|
||||
caller.objPts[1] = caller.objPts[0];
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.npoints = &bad_npts_c1;
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "Bad npoints format", bad_caller );
|
||||
caller.initArgs();
|
||||
Mat badCM = Mat::zeros(4, 4, CV_64F);
|
||||
caller.cameraMatrix_arg = badCM;
|
||||
caller.flags = CALIB_USE_INTRINSIC_GUESS;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad camearaMatrix header", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.npoints = &bad_npts_c2;
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "Bad npoints size", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.rvecs = (CvMat*)zeros.ptr();
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvecs header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.tvecs = (CvMat*)zeros.ptr();
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvecs header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.newObjPts = (CvMat*)zeros.ptr();
|
||||
errors += run_test_case( CV_StsBadArg, "Bad newObjPts header", bad_caller );
|
||||
|
||||
Mat bad_rvecs_cpp1(M+1, 1, CV_32FC3); CvMat bad_rvecs_c1 = cvMat(bad_rvecs_cpp1);
|
||||
Mat bad_tvecs_cpp1(M+1, 1, CV_32FC3); CvMat bad_tvecs_c1 = cvMat(bad_tvecs_cpp1);
|
||||
|
||||
|
||||
|
||||
Mat bad_rvecs_cpp2(M, 2, CV_32FC3); CvMat bad_rvecs_c2 = cvMat(bad_rvecs_cpp2);
|
||||
Mat bad_tvecs_cpp2(M, 2, CV_32FC3); CvMat bad_tvecs_c2 = cvMat(bad_tvecs_cpp2);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.rvecs = &bad_rvecs_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvecs header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.rvecs = &bad_rvecs_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvecs header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.tvecs = &bad_tvecs_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvecs header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.tvecs = &bad_tvecs_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvecs header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.newObjPts = &bad_tvecs_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad newObjPts header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.newObjPts = &bad_tvecs_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad newObjPts header", bad_caller );
|
||||
|
||||
Mat bad_cameraMatrix_cpp1(3, 3, CV_32S); CvMat bad_cameraMatrix_c1 = cvMat(bad_cameraMatrix_cpp1);
|
||||
Mat bad_cameraMatrix_cpp2(2, 3, CV_32F); CvMat bad_cameraMatrix_c2 = cvMat(bad_cameraMatrix_cpp2);
|
||||
Mat bad_cameraMatrix_cpp3(3, 2, CV_64F); CvMat bad_cameraMatrix_c3 = cvMat(bad_cameraMatrix_cpp3);
|
||||
|
||||
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.cameraMatrix = &bad_cameraMatrix_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad camearaMatrix header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.cameraMatrix = &bad_cameraMatrix_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad camearaMatrix header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.cameraMatrix = &bad_cameraMatrix_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad camearaMatrix header", bad_caller );
|
||||
|
||||
Mat bad_distCoeffs_cpp1(1, 5, CV_32S); CvMat bad_distCoeffs_c1 = cvMat(bad_distCoeffs_cpp1);
|
||||
Mat bad_distCoeffs_cpp2(2, 2, CV_64F); CvMat bad_distCoeffs_c2 = cvMat(bad_distCoeffs_cpp2);
|
||||
Mat bad_distCoeffs_cpp3(1, 6, CV_64F); CvMat bad_distCoeffs_c3 = cvMat(bad_distCoeffs_cpp3);
|
||||
|
||||
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = &bad_distCoeffs_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs header", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = &bad_distCoeffs_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs header", bad_caller );
|
||||
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = &bad_distCoeffs_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs header", bad_caller );
|
||||
|
||||
double CM[] = {0, 0, 0, /**/0, 0, 0, /**/0, 0, 0};
|
||||
Mat bad_cameraMatrix_cpp4(3, 3, CV_64F, CM); CvMat bad_cameraMatrix_c4 = cvMat(bad_cameraMatrix_cpp4);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.flags |= CV_CALIB_USE_INTRINSIC_GUESS;
|
||||
bad_caller.cameraMatrix = &bad_cameraMatrix_c4;
|
||||
CM[0] = 0; //bad fx
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[0] = 500; CM[4] = 0; //bad fy
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[0] = 500; CM[4] = 500; CM[2] = -1; //bad cx
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[0] = 500; CM[4] = 500; CM[2] = imgSize.width*2; //bad cx
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[0] = 500; CM[4] = 500; CM[2] = imgSize.width/2; CM[5] = -1; //bad cy
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[0] = 500; CM[4] = 500; CM[2] = imgSize.width/2; CM[5] = imgSize.height*2; //bad cy
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[0] = 500; CM[4] = 500; CM[2] = imgSize.width/2; CM[5] = imgSize.height/2;
|
||||
CM[1] = 0.1; //Non-zero skew
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[1] = 0;
|
||||
CM[3] = 0.1; /* mad matrix shape */
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[3] = 0; CM[6] = 0.1; /* mad matrix shape */
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[3] = 0; CM[6] = 0; CM[7] = 0.1; /* mad matrix shape */
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
|
||||
CM[3] = 0; CM[6] = 0; CM[7] = 0; CM[8] = 1.1; /* mad matrix shape */
|
||||
errors += run_test_case( CV_StsOutOfRange, "Bad camearaMatrix data", bad_caller );
|
||||
CM[8] = 1.0;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
bad_caller = caller;
|
||||
Mat bad_objPts_cpp5 = objPts_cpp.clone(); CvMat bad_objPts_c5 = cvMat(bad_objPts_cpp5);
|
||||
bad_caller.objPts = &bad_objPts_c5;
|
||||
|
||||
cv::RNG& rng = theRNG();
|
||||
for(int i = 0; i < bad_objPts_cpp5.cols; ++i)
|
||||
bad_objPts_cpp5.at<Point3f>(0, i).z += ((float)rng - 0.5f);
|
||||
|
||||
errors += run_test_case( CV_StsBadArg, "Bad objPts data", bad_caller );
|
||||
|
||||
bad_objPts_cpp5 = objPts_cpp.clone(); bad_objPts_c5 = cvMat(bad_objPts_cpp5);
|
||||
bad_caller.objPts = &bad_objPts_c5;
|
||||
bad_caller.iFixedPoint = corSize.width - 1;
|
||||
for(int i = 0; i < bad_objPts_cpp5.cols; ++i)
|
||||
{
|
||||
bad_objPts_cpp5.at<Point3f>(0, i).x += (float)rng;
|
||||
bad_objPts_cpp5.at<Point3f>(0, i).y += (float)rng;
|
||||
}
|
||||
errors += run_test_case( CV_StsBadArg, "Bad objPts data", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
Mat bad_npts_cpp3 = npoints_cpp.clone();
|
||||
CvMat bad_npts_c3 = cvMat(bad_npts_cpp3);
|
||||
bad_caller.npoints = &bad_npts_c3;
|
||||
bad_caller.iFixedPoint = corSize.width - 1;
|
||||
for(int i = 0; i < M; i++)
|
||||
bad_npts_cpp3.at<int>(i) += i;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad npoints data", bad_caller );
|
||||
caller.initArgs();
|
||||
Mat badDC = Mat::zeros(10, 10, CV_64F);
|
||||
caller.distCoeffs_arg = badDC;
|
||||
caller.flags = CALIB_USE_INTRINSIC_GUESS;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad camearaMatrix header", caller );
|
||||
|
||||
if (errors)
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
else
|
||||
ts->set_failed_test_info(cvtest::TS::OK);
|
||||
|
||||
//try { caller(); }
|
||||
//catch (...)
|
||||
//{
|
||||
// ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
// printf("+!");
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@ -383,108 +210,49 @@ protected:
|
||||
|
||||
struct C_Caller
|
||||
{
|
||||
CvMat* src;
|
||||
CvMat* dst;
|
||||
CvMat* jacobian;
|
||||
_InputArray src_arg;
|
||||
_OutputArray dst_arg, j_arg;
|
||||
|
||||
void operator()() { cvRodrigues2(src, dst, jacobian); }
|
||||
Mat src;
|
||||
Mat dst;
|
||||
Mat jacobian;
|
||||
|
||||
void initArgs()
|
||||
{
|
||||
src_arg = src;
|
||||
dst_arg = dst;
|
||||
j_arg = jacobian;
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
cv::Rodrigues(src_arg, dst_arg, j_arg);
|
||||
}
|
||||
};
|
||||
|
||||
void run(int /* start_from */ )
|
||||
{
|
||||
Mat zeros(1, sizeof(CvMat), CV_8U, Scalar(0));
|
||||
CvMat src_c, dst_c, jacobian_c;
|
||||
|
||||
Mat src_cpp(3, 1, CV_32F); src_c = cvMat(src_cpp);
|
||||
Mat dst_cpp(3, 3, CV_32F); dst_c = cvMat(dst_cpp);
|
||||
Mat jacobian_cpp(3, 9, CV_32F); jacobian_c = cvMat(jacobian_cpp);
|
||||
Mat src_cpp(3, 1, CV_32F);
|
||||
Mat dst_cpp(3, 3, CV_32F);
|
||||
|
||||
C_Caller caller, bad_caller;
|
||||
caller.src = &src_c;
|
||||
caller.dst = &dst_c;
|
||||
caller.jacobian = &jacobian_c;
|
||||
|
||||
/* try { caller(); }
|
||||
catch (...)
|
||||
{
|
||||
printf("badasfas");
|
||||
}*/
|
||||
C_Caller caller;
|
||||
|
||||
/*/*//*/*/
|
||||
int errors = 0;
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.src = 0;
|
||||
errors += run_test_case( CV_StsNullPtr, "Src is zero pointer", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.src_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Src is empty matrix", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dst = 0;
|
||||
errors += run_test_case( CV_StsNullPtr, "Dst is zero pointer", bad_caller );
|
||||
|
||||
Mat bad_src_cpp1(3, 1, CV_8U); CvMat bad_src_c1 = cvMat(bad_src_cpp1);
|
||||
Mat bad_dst_cpp1(3, 1, CV_8U); CvMat bad_dst_c1 = cvMat(bad_dst_cpp1);
|
||||
Mat bad_jac_cpp1(3, 1, CV_8U); CvMat bad_jac_c1 = cvMat(bad_jac_cpp1);
|
||||
Mat bad_jac_cpp2(3, 1, CV_32FC2); CvMat bad_jac_c2 = cvMat(bad_jac_cpp2);
|
||||
Mat bad_jac_cpp3(3, 1, CV_32F); CvMat bad_jac_c3 = cvMat(bad_jac_cpp3);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.src = &bad_src_c1;
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "Bad src formart", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dst = &bad_dst_c1;
|
||||
errors += run_test_case( CV_StsUnmatchedFormats, "Bad dst formart", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.jacobian = (CvMat*)zeros.ptr();
|
||||
errors += run_test_case( CV_StsBadArg, "Bad jacobian ", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.jacobian = &bad_jac_c1;
|
||||
errors += run_test_case( CV_StsUnmatchedFormats, "Bad jacobian format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.jacobian = &bad_jac_c2;
|
||||
errors += run_test_case( CV_StsUnmatchedFormats, "Bad jacobian format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.jacobian = &bad_jac_c3;
|
||||
errors += run_test_case( CV_StsBadSize, "Bad jacobian format", bad_caller );
|
||||
|
||||
Mat bad_src_cpp2(1, 1, CV_32F); CvMat bad_src_c2 = cvMat(bad_src_cpp2);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.src = &bad_src_c2;
|
||||
errors += run_test_case( CV_StsBadSize, "Bad src format", bad_caller );
|
||||
|
||||
Mat bad_dst_cpp2(2, 1, CV_32F); CvMat bad_dst_c2 = cvMat(bad_dst_cpp2);
|
||||
Mat bad_dst_cpp3(3, 2, CV_32F); CvMat bad_dst_c3 = cvMat(bad_dst_cpp3);
|
||||
Mat bad_dst_cpp4(3, 3, CV_32FC2); CvMat bad_dst_c4 = cvMat(bad_dst_cpp4);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dst = &bad_dst_c2;
|
||||
errors += run_test_case( CV_StsBadSize, "Bad dst format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dst = &bad_dst_c3;
|
||||
errors += run_test_case( CV_StsBadSize, "Bad dst format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dst = &bad_dst_c4;
|
||||
errors += run_test_case( CV_StsBadSize, "Bad dst format", bad_caller );
|
||||
|
||||
|
||||
/********/
|
||||
src_cpp.create(3, 3, CV_32F); src_c = cvMat(src_cpp);
|
||||
dst_cpp.create(3, 1, CV_32F); dst_c = cvMat(dst_cpp);
|
||||
|
||||
|
||||
Mat bad_dst_cpp5(5, 5, CV_32F); CvMat bad_dst_c5 = cvMat(bad_dst_cpp5);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dst = &bad_dst_c5;
|
||||
errors += run_test_case( CV_StsBadSize, "Bad dst format", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.src = Mat::zeros(3, 1, CV_8U);
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "Bad src formart", caller );
|
||||
|
||||
caller.initArgs();
|
||||
caller.src = Mat::zeros(1, 1, CV_32F);
|
||||
errors += run_test_case( CV_StsBadSize, "Bad src size", caller );
|
||||
|
||||
if (errors)
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
@ -514,259 +282,107 @@ protected:
|
||||
|
||||
struct C_Caller
|
||||
{
|
||||
CvMat* objectPoints;
|
||||
CvMat* r_vec;
|
||||
CvMat* t_vec;
|
||||
CvMat* A;
|
||||
CvMat* distCoeffs;
|
||||
CvMat* imagePoints;
|
||||
CvMat* dpdr;
|
||||
CvMat* dpdt;
|
||||
CvMat* dpdf;
|
||||
CvMat* dpdc;
|
||||
CvMat* dpdk;
|
||||
double aspectRatio;
|
||||
_InputArray objectPoints_arg, rvec_arg, tvec_arg, A_arg, DC_arg;
|
||||
_OutputArray imagePoints_arg;
|
||||
Mat objectPoints;
|
||||
Mat r_vec;
|
||||
Mat t_vec;
|
||||
Mat A;
|
||||
Mat distCoeffs;
|
||||
Mat imagePoints;
|
||||
Mat J;
|
||||
double aspectRatio0, aspectRatio;
|
||||
|
||||
void initArgs()
|
||||
{
|
||||
objectPoints_arg = objectPoints;
|
||||
imagePoints_arg = imagePoints;
|
||||
rvec_arg = r_vec;
|
||||
tvec_arg = t_vec;
|
||||
A_arg = A;
|
||||
DC_arg = distCoeffs;
|
||||
aspectRatio = aspectRatio0;
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
cvProjectPoints2( objectPoints, r_vec, t_vec, A, distCoeffs, imagePoints,
|
||||
dpdr, dpdt, dpdf, dpdc, dpdk, aspectRatio );
|
||||
projectPoints(objectPoints_arg, rvec_arg, tvec_arg, A_arg, DC_arg,
|
||||
imagePoints_arg, J, aspectRatio );
|
||||
}
|
||||
};
|
||||
|
||||
void run(int /* start_from */ )
|
||||
{
|
||||
CvMat zeros = CvMat();
|
||||
|
||||
C_Caller caller, bad_caller;
|
||||
CvMat objectPoints_c, r_vec_c, t_vec_c, A_c, distCoeffs_c, imagePoints_c,
|
||||
dpdr_c, dpdt_c, dpdf_c, dpdc_c, dpdk_c;
|
||||
C_Caller caller;
|
||||
|
||||
const int n = 10;
|
||||
|
||||
Mat imagePoints_cpp(1, n, CV_32FC2); imagePoints_c = cvMat(imagePoints_cpp);
|
||||
|
||||
Mat objectPoints_cpp(1, n, CV_32FC3);
|
||||
randu(objectPoints_cpp, Scalar::all(1), Scalar::all(10));
|
||||
objectPoints_c = cvMat(objectPoints_cpp);
|
||||
|
||||
Mat t_vec_cpp(Mat::zeros(1, 3, CV_32F)); t_vec_c = cvMat(t_vec_cpp);
|
||||
Mat r_vec_cpp(3, 1, CV_32F);
|
||||
cvtest::Rodrigues(Mat::eye(3, 3, CV_32F), r_vec_cpp); r_vec_c = cvMat(r_vec_cpp);
|
||||
|
||||
Mat A_cpp = camMat.clone(); A_c = cvMat(A_cpp);
|
||||
Mat distCoeffs_cpp = distCoeffs.clone(); distCoeffs_c = cvMat(distCoeffs_cpp);
|
||||
|
||||
Mat dpdr_cpp(2*n, 3, CV_32F); dpdr_c = cvMat(dpdr_cpp);
|
||||
Mat dpdt_cpp(2*n, 3, CV_32F); dpdt_c = cvMat(dpdt_cpp);
|
||||
Mat dpdf_cpp(2*n, 2, CV_32F); dpdf_c = cvMat(dpdf_cpp);
|
||||
Mat dpdc_cpp(2*n, 2, CV_32F); dpdc_c = cvMat(dpdc_cpp);
|
||||
Mat dpdk_cpp(2*n, 4, CV_32F); dpdk_c = cvMat(dpdk_cpp);
|
||||
|
||||
caller.aspectRatio = 1.0;
|
||||
caller.objectPoints = &objectPoints_c;
|
||||
caller.r_vec = &r_vec_c;
|
||||
caller.t_vec = &t_vec_c;
|
||||
caller.A = &A_c;
|
||||
caller.distCoeffs = &distCoeffs_c;
|
||||
caller.imagePoints = &imagePoints_c;
|
||||
caller.dpdr = &dpdr_c;
|
||||
caller.dpdt = &dpdt_c;
|
||||
caller.dpdf = &dpdf_c;
|
||||
caller.dpdc = &dpdc_c;
|
||||
caller.dpdk = &dpdk_c;
|
||||
caller.objectPoints = objectPoints_cpp;
|
||||
caller.t_vec = Mat::zeros(1, 3, CV_32F);
|
||||
cvtest::Rodrigues(Mat::eye(3, 3, CV_32F), caller.r_vec);
|
||||
caller.A = Mat::eye(3, 3, CV_32F);
|
||||
caller.distCoeffs = Mat::zeros(1, 5, CV_32F);
|
||||
caller.aspectRatio0 = 1.0;
|
||||
|
||||
/********************/
|
||||
int errors = 0;
|
||||
|
||||
caller.initArgs();
|
||||
caller.objectPoints_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Zero objectPoints", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.objectPoints = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero objectPoints", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.rvec_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Zero r_vec", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.r_vec = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero r_vec", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.tvec_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Zero t_vec", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.t_vec = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero t_vec", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.A_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Zero camMat", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.A = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero camMat", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.imagePoints_arg = noArray();
|
||||
errors += run_test_case( CV_StsBadArg, "Zero imagePoints", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.imagePoints = 0;
|
||||
errors += run_test_case( CV_StsBadArg, "Zero imagePoints", bad_caller );
|
||||
Mat save_rvec = caller.r_vec;
|
||||
caller.initArgs();
|
||||
caller.r_vec.create(2, 2, CV_32F);
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvec format", caller );
|
||||
|
||||
caller.initArgs();
|
||||
caller.r_vec.create(1, 3, CV_8U);
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvec format", caller );
|
||||
caller.r_vec = save_rvec;
|
||||
|
||||
/****************************/
|
||||
Mat bad_r_vec_cpp1(r_vec_cpp.size(), CV_32S); CvMat bad_r_vec_c1 = cvMat(bad_r_vec_cpp1);
|
||||
Mat bad_r_vec_cpp2(2, 2, CV_32F); CvMat bad_r_vec_c2 = cvMat(bad_r_vec_cpp2);
|
||||
Mat bad_r_vec_cpp3(r_vec_cpp.size(), CV_32FC2); CvMat bad_r_vec_c3 = cvMat(bad_r_vec_cpp3);
|
||||
Mat save_tvec = caller.t_vec;
|
||||
caller.initArgs();
|
||||
caller.t_vec.create(3, 3, CV_32F);
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvec format", caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.r_vec = &bad_r_vec_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvec format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.r_vec = &bad_r_vec_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvec format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.r_vec = &bad_r_vec_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad rvec format", bad_caller );
|
||||
caller.initArgs();
|
||||
caller.t_vec.create(1, 3, CV_8U);
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvec format", caller );
|
||||
caller.t_vec = save_tvec;
|
||||
|
||||
/****************************/
|
||||
Mat bad_t_vec_cpp1(t_vec_cpp.size(), CV_32S); CvMat bad_t_vec_c1 = cvMat(bad_t_vec_cpp1);
|
||||
Mat bad_t_vec_cpp2(2, 2, CV_32F); CvMat bad_t_vec_c2 = cvMat(bad_t_vec_cpp2);
|
||||
Mat bad_t_vec_cpp3(1, 1, CV_32FC2); CvMat bad_t_vec_c3 = cvMat(bad_t_vec_cpp3);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.t_vec = &bad_t_vec_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvec format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.t_vec = &bad_t_vec_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvec format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.t_vec = &bad_t_vec_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad tvec format", bad_caller );
|
||||
Mat save_A = caller.A;
|
||||
caller.initArgs();
|
||||
caller.A.create(2, 2, CV_32F);
|
||||
errors += run_test_case( CV_StsBadArg, "Bad A format", caller );
|
||||
caller.A = save_A;
|
||||
|
||||
/****************************/
|
||||
Mat bad_A_cpp1(A_cpp.size(), CV_32S); CvMat bad_A_c1 = cvMat(bad_A_cpp1);
|
||||
Mat bad_A_cpp2(2, 2, CV_32F); CvMat bad_A_c2 = cvMat(bad_A_cpp2);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.A = &bad_A_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad A format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.A = &bad_A_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad A format", bad_caller );
|
||||
|
||||
/****************************/
|
||||
Mat bad_distCoeffs_cpp1(distCoeffs_cpp.size(), CV_32S); CvMat bad_distCoeffs_c1 = cvMat(bad_distCoeffs_cpp1);
|
||||
Mat bad_distCoeffs_cpp2(2, 2, CV_32F); CvMat bad_distCoeffs_c2 = cvMat(bad_distCoeffs_cpp2);
|
||||
Mat bad_distCoeffs_cpp3(1, 7, CV_32F); CvMat bad_distCoeffs_c3 = cvMat(bad_distCoeffs_cpp3);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = &zeros;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = &bad_distCoeffs_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = &bad_distCoeffs_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = &bad_distCoeffs_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs format", bad_caller );
|
||||
|
||||
|
||||
/****************************/
|
||||
Mat bad_dpdr_cpp1(dpdr_cpp.size(), CV_32S); CvMat bad_dpdr_c1 = cvMat(bad_dpdr_cpp1);
|
||||
Mat bad_dpdr_cpp2(dpdr_cpp.cols+1, 3, CV_32F); CvMat bad_dpdr_c2 = cvMat(bad_dpdr_cpp2);
|
||||
Mat bad_dpdr_cpp3(dpdr_cpp.cols, 7, CV_32F); CvMat bad_dpdr_c3 = cvMat(bad_dpdr_cpp3);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdr = &zeros;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdr format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdr = &bad_dpdr_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdr format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdr = &bad_dpdr_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdr format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdr = &bad_dpdr_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdr format", bad_caller );
|
||||
|
||||
/****************************/
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdt = &zeros;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdt format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdt = &bad_dpdr_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdt format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdt = &bad_dpdr_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdt format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdt = &bad_dpdr_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdt format", bad_caller );
|
||||
|
||||
/****************************/
|
||||
|
||||
Mat bad_dpdf_cpp2(dpdr_cpp.cols+1, 2, CV_32F); CvMat bad_dpdf_c2 = cvMat(bad_dpdf_cpp2);
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdf = &zeros;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdf format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdf = &bad_dpdr_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdf format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdf = &bad_dpdf_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdf format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdf = &bad_dpdr_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdf format", bad_caller );
|
||||
|
||||
/****************************/
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdc = &zeros;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdc format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdc = &bad_dpdr_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdc format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdc = &bad_dpdf_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdc format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdc = &bad_dpdr_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdc format", bad_caller );
|
||||
|
||||
/****************************/
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdk = &zeros;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdk format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdk = &bad_dpdr_c1;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdk format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdk = &bad_dpdf_c2;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdk format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.dpdk = &bad_dpdr_c3;
|
||||
errors += run_test_case( CV_StsBadArg, "Bad dpdk format", bad_caller );
|
||||
|
||||
bad_caller = caller;
|
||||
bad_caller.distCoeffs = 0;
|
||||
errors += run_test_case( CV_StsNullPtr, "distCoeffs is NULL while dpdk is not", bad_caller );
|
||||
|
||||
Mat save_DC = caller.distCoeffs;
|
||||
caller.initArgs();
|
||||
caller.distCoeffs.create(3, 3, CV_32F);
|
||||
errors += run_test_case( CV_StsBadArg, "Bad distCoeffs format", caller );
|
||||
caller.distCoeffs = save_DC;
|
||||
|
||||
if (errors)
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
@ -776,8 +392,8 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
TEST(Calib3d_CalibrateCamera_C, badarg) { CV_CameraCalibrationBadArgTest test; test.safe_run(); }
|
||||
TEST(Calib3d_Rodrigues_C, badarg) { CV_Rodrigues2BadArgTest test; test.safe_run(); }
|
||||
TEST(Calib3d_ProjectPoints_C, badarg) { CV_ProjectPoints2BadArgTest test; test.safe_run(); }
|
||||
TEST(Calib3d_CalibrateCamera_CPP, badarg) { CV_CameraCalibrationBadArgTest test; test.safe_run(); }
|
||||
TEST(Calib3d_Rodrigues_CPP, badarg) { CV_Rodrigues2BadArgTest test; test.safe_run(); }
|
||||
TEST(Calib3d_ProjectPoints_CPP, badarg) { CV_ProjectPoints2BadArgTest test; test.safe_run(); }
|
||||
|
||||
}} // namespace
|
||||
|
@ -48,53 +48,32 @@ namespace opencv_test { namespace {
|
||||
class CV_ChessboardDetectorBadArgTest : public cvtest::BadArgTest
|
||||
{
|
||||
public:
|
||||
CV_ChessboardDetectorBadArgTest();
|
||||
CV_ChessboardDetectorBadArgTest() { flags0 = 0; }
|
||||
protected:
|
||||
void run(int);
|
||||
bool checkByGenerator();
|
||||
|
||||
bool cpp;
|
||||
|
||||
/* cpp interface */
|
||||
Mat img;
|
||||
Size pattern_size;
|
||||
int flags;
|
||||
Size pattern_size, pattern_size0;
|
||||
int flags, flags0;
|
||||
vector<Point2f> corners;
|
||||
_InputArray img_arg;
|
||||
_OutputArray corners_arg;
|
||||
|
||||
/* c interface */
|
||||
CvMat arr;
|
||||
CvPoint2D32f* out_corners;
|
||||
int* out_corner_count;
|
||||
|
||||
|
||||
/* c interface draw corners */
|
||||
bool drawCorners;
|
||||
CvMat drawCorImg;
|
||||
bool was_found;
|
||||
void initArgs()
|
||||
{
|
||||
img_arg = img;
|
||||
corners_arg = corners;
|
||||
pattern_size = pattern_size0;
|
||||
flags = flags0;
|
||||
}
|
||||
|
||||
void run_func()
|
||||
{
|
||||
if (cpp)
|
||||
findChessboardCorners(img, pattern_size, corners, flags);
|
||||
else
|
||||
if (!drawCorners)
|
||||
cvFindChessboardCorners( &arr, cvSize(pattern_size), out_corners, out_corner_count, flags );
|
||||
else
|
||||
cvDrawChessboardCorners( &drawCorImg, cvSize(pattern_size),
|
||||
(CvPoint2D32f*)(corners.empty() ? 0 : &corners[0]),
|
||||
(int)corners.size(), was_found);
|
||||
findChessboardCorners(img_arg, pattern_size, corners_arg, flags);
|
||||
}
|
||||
};
|
||||
|
||||
CV_ChessboardDetectorBadArgTest::CV_ChessboardDetectorBadArgTest()
|
||||
{
|
||||
cpp = false;
|
||||
flags = 0;
|
||||
out_corners = NULL;
|
||||
out_corner_count = NULL;
|
||||
drawCorners = was_found = false;
|
||||
}
|
||||
|
||||
/* ///////////////////// chess_corner_test ///////////////////////// */
|
||||
void CV_ChessboardDetectorBadArgTest::run( int /*start_from */)
|
||||
{
|
||||
@ -111,34 +90,18 @@ void CV_ChessboardDetectorBadArgTest::run( int /*start_from */)
|
||||
/* /*//*/ */
|
||||
int errors = 0;
|
||||
flags = CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE;
|
||||
cpp = true;
|
||||
|
||||
img = cb.clone();
|
||||
initArgs();
|
||||
pattern_size = Size(2,2);
|
||||
errors += run_test_case( CV_StsOutOfRange, "Invlid pattern size" );
|
||||
|
||||
errors += run_test_case( Error::StsOutOfRange, "Invlid pattern size" );
|
||||
pattern_size = cbg.cornersSize();
|
||||
|
||||
cb.convertTo(img, CV_32F);
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "Not 8-bit image" );
|
||||
errors += run_test_case( Error::StsUnsupportedFormat, "Not 8-bit image" );
|
||||
|
||||
cv::merge(vector<Mat>(2, cb), img);
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "2 channel image" );
|
||||
|
||||
cpp = false;
|
||||
drawCorners = false;
|
||||
|
||||
img = cb.clone();
|
||||
arr = cvMat(img);
|
||||
out_corner_count = 0;
|
||||
out_corners = 0;
|
||||
errors += run_test_case( CV_StsNullPtr, "Null pointer to corners" );
|
||||
|
||||
drawCorners = true;
|
||||
Mat cvdrawCornImg(img.size(), CV_8UC2);
|
||||
drawCorImg = cvMat(cvdrawCornImg);
|
||||
was_found = true;
|
||||
errors += run_test_case( CV_StsUnsupportedFormat, "2 channel image" );
|
||||
|
||||
errors += run_test_case( Error::StsUnsupportedFormat, "2 channel image" );
|
||||
|
||||
if (errors)
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
|
@ -40,6 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
namespace cvtest {
|
||||
@ -349,8 +350,10 @@ static int cvTsRodrigues( const CvMat* src, CvMat* dst, CvMat* jacobian )
|
||||
|
||||
/*extern*/ void Rodrigues(const Mat& src, Mat& dst, Mat* jac)
|
||||
{
|
||||
CV_Assert(src.data != dst.data && "Inplace is not supported");
|
||||
CV_Assert(!dst.empty() && "'dst' must be allocated");
|
||||
if(src.rows == 1 || src.cols == 1)
|
||||
dst.create(3, 3, src.depth());
|
||||
else
|
||||
dst.create(3, 1, src.depth());
|
||||
CvMat _src = cvMat(src), _dst = cvMat(dst), _jac;
|
||||
if( jac )
|
||||
_jac = cvMat(*jac);
|
||||
@ -663,53 +666,36 @@ int CV_RodriguesTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
void CV_RodriguesTest::run_func()
|
||||
{
|
||||
CvMat v2m_jac, m2v_jac;
|
||||
|
||||
if( calc_jacobians )
|
||||
cv::Mat v = test_mat[INPUT][0], M = test_mat[OUTPUT][0], v2 = test_mat[OUTPUT][2];
|
||||
cv::Mat M0 = M, v2_0 = v2;
|
||||
if( !calc_jacobians )
|
||||
{
|
||||
v2m_jac = cvMat(test_mat[OUTPUT][1]);
|
||||
m2v_jac = cvMat(test_mat[OUTPUT][3]);
|
||||
}
|
||||
|
||||
if( !test_cpp )
|
||||
{
|
||||
CvMat _input = cvMat(test_mat[INPUT][0]), _output = cvMat(test_mat[OUTPUT][0]), _output2 = cvMat(test_mat[OUTPUT][2]);
|
||||
cvRodrigues2( &_input, &_output, calc_jacobians ? &v2m_jac : 0 );
|
||||
cvRodrigues2( &_output, &_output2, calc_jacobians ? &m2v_jac : 0 );
|
||||
cv::Rodrigues(v, M);
|
||||
cv::Rodrigues(M, v2);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat v = test_mat[INPUT][0], M = test_mat[OUTPUT][0], v2 = test_mat[OUTPUT][2];
|
||||
cv::Mat M0 = M, v2_0 = v2;
|
||||
if( !calc_jacobians )
|
||||
cv::Mat J1 = test_mat[OUTPUT][1], J2 = test_mat[OUTPUT][3];
|
||||
cv::Mat J1_0 = J1, J2_0 = J2;
|
||||
cv::Rodrigues(v, M, J1);
|
||||
cv::Rodrigues(M, v2, J2);
|
||||
if( J1.data != J1_0.data )
|
||||
{
|
||||
cv::Rodrigues(v, M);
|
||||
cv::Rodrigues(M, v2);
|
||||
if( J1.size() != J1_0.size() )
|
||||
J1 = J1.t();
|
||||
J1.convertTo(J1_0, J1_0.type());
|
||||
}
|
||||
else
|
||||
if( J2.data != J2_0.data )
|
||||
{
|
||||
cv::Mat J1 = test_mat[OUTPUT][1], J2 = test_mat[OUTPUT][3];
|
||||
cv::Mat J1_0 = J1, J2_0 = J2;
|
||||
cv::Rodrigues(v, M, J1);
|
||||
cv::Rodrigues(M, v2, J2);
|
||||
if( J1.data != J1_0.data )
|
||||
{
|
||||
if( J1.size() != J1_0.size() )
|
||||
J1 = J1.t();
|
||||
J1.convertTo(J1_0, J1_0.type());
|
||||
}
|
||||
if( J2.data != J2_0.data )
|
||||
{
|
||||
if( J2.size() != J2_0.size() )
|
||||
J2 = J2.t();
|
||||
J2.convertTo(J2_0, J2_0.type());
|
||||
}
|
||||
if( J2.size() != J2_0.size() )
|
||||
J2 = J2.t();
|
||||
J2.convertTo(J2_0, J2_0.type());
|
||||
}
|
||||
if( M.data != M0.data )
|
||||
M.reshape(M0.channels(), M0.rows).convertTo(M0, M0.type());
|
||||
if( v2.data != v2_0.data )
|
||||
v2.reshape(v2_0.channels(), v2_0.rows).convertTo(v2_0, v2_0.type());
|
||||
}
|
||||
if( M.data != M0.data )
|
||||
M.reshape(M0.channels(), M0.rows).convertTo(M0, M0.type());
|
||||
if( v2.data != v2_0.data )
|
||||
v2.reshape(v2_0.channels(), v2_0.rows).convertTo(v2_0, v2_0.type());
|
||||
}
|
||||
|
||||
|
||||
@ -851,19 +837,14 @@ void CV_FundamentalMatTest::get_test_array_types_and_sizes( int /*test_case_idx*
|
||||
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, 1);
|
||||
|
||||
sizes[INPUT][0] = cvSize(dims, pt_count);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, dims);
|
||||
else
|
||||
{
|
||||
sizes[INPUT][0] = cvSize(dims, pt_count);
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, dims);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
{
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, dims);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
|
||||
sizes[INPUT][1] = sizes[INPUT][0];
|
||||
@ -980,12 +961,12 @@ int CV_FundamentalMatTest::prepare_test_case( int test_case_idx )
|
||||
void CV_FundamentalMatTest::run_func()
|
||||
{
|
||||
// cvFindFundamentalMat calls cv::findFundamentalMat
|
||||
CvMat _input0 = cvMat(test_mat[INPUT][0]), _input1 = cvMat(test_mat[INPUT][1]);
|
||||
CvMat F = cvMat(test_mat[TEMP][0]), mask = cvMat(test_mat[TEMP][1]);
|
||||
f_result = cvFindFundamentalMat( &_input0, &_input1, &F, method, MAX(sigma*3, 0.01), 0, &mask );
|
||||
cv::Mat _input0 = test_mat[INPUT][0], _input1 = test_mat[INPUT][1];
|
||||
cv::Mat& F = test_mat[TEMP][0], &mask = test_mat[TEMP][1];
|
||||
F = cv::findFundamentalMat( _input0, _input1, method, MAX(sigma*3, 0.01), 0, mask );
|
||||
f_result = !F.empty();
|
||||
}
|
||||
|
||||
|
||||
void CV_FundamentalMatTest::prepare_to_validation( int test_case_idx )
|
||||
{
|
||||
const Mat& Rt = test_mat[INPUT][3];
|
||||
@ -1025,7 +1006,11 @@ void CV_FundamentalMatTest::prepare_to_validation( int test_case_idx )
|
||||
test_convertHomogeneous( test_mat[INPUT][0], p1 );
|
||||
test_convertHomogeneous( test_mat[INPUT][1], p2 );
|
||||
|
||||
cvtest::convert(test_mat[TEMP][0], F, F.type());
|
||||
Mat Fsrc = test_mat[TEMP][0];
|
||||
if( Fsrc.rows > 3 )
|
||||
Fsrc = Fsrc.rowRange(0, 3);
|
||||
|
||||
cvtest::convert(Fsrc, F, F.type());
|
||||
|
||||
if( method <= CV_FM_8POINT )
|
||||
memset( status, 1, pt_count );
|
||||
@ -1144,19 +1129,14 @@ void CV_EssentialMatTest::get_test_array_types_and_sizes( int /*test_case_idx*/,
|
||||
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, 1);
|
||||
|
||||
if( 0 && cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, dims);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(dims, pt_count);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
{
|
||||
sizes[INPUT][0] = cvSize(dims, pt_count);
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, dims);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
{
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, dims);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
|
||||
sizes[INPUT][1] = sizes[INPUT][0];
|
||||
@ -1464,57 +1444,33 @@ void CV_ConvertHomogeneousTest::get_test_array_types_and_sizes( int /*test_case_
|
||||
{
|
||||
RNG& rng = ts->get_rng();
|
||||
int pt_depth1 = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F;
|
||||
int pt_depth2 = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F;
|
||||
int pt_depth2 = pt_depth1;//cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F;
|
||||
double pt_count_exp = cvtest::randReal(rng)*6 + 1;
|
||||
int t;
|
||||
|
||||
pt_count = cvRound(exp(pt_count_exp));
|
||||
pt_count = MAX( pt_count, 5 );
|
||||
|
||||
dims1 = 2 + (cvtest::randInt(rng) % 3);
|
||||
dims2 = 2 + (cvtest::randInt(rng) % 3);
|
||||
|
||||
if( dims1 == dims2 + 2 )
|
||||
dims1--;
|
||||
else if( dims1 == dims2 - 2 )
|
||||
dims1++;
|
||||
dims1 = 2 + (cvtest::randInt(rng) % 2);
|
||||
dims2 = dims1 + 1;
|
||||
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
CV_SWAP( dims1, dims2, t );
|
||||
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth1, 1);
|
||||
|
||||
sizes[INPUT][0] = cvSize(dims1, pt_count);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, dims1);
|
||||
else
|
||||
{
|
||||
sizes[INPUT][0] = cvSize(dims1, pt_count);
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth1, dims1);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
{
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth1, dims1);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
|
||||
types[OUTPUT][0] = CV_MAKETYPE(pt_depth2, 1);
|
||||
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[OUTPUT][0] = cvSize(pt_count, dims2);
|
||||
else
|
||||
{
|
||||
sizes[OUTPUT][0] = cvSize(dims2, pt_count);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
{
|
||||
types[OUTPUT][0] = CV_MAKETYPE(pt_depth2, dims2);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[OUTPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[OUTPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
}
|
||||
types[OUTPUT][0] = CV_MAKETYPE(pt_depth2, dims2);
|
||||
sizes[OUTPUT][0] = cvSize(1, pt_count);
|
||||
|
||||
types[REF_OUTPUT][0] = types[OUTPUT][0];
|
||||
sizes[REF_OUTPUT][0] = sizes[OUTPUT][0];
|
||||
@ -1543,8 +1499,11 @@ void CV_ConvertHomogeneousTest::fill_array( int /*test_case_idx*/, int /*i*/, in
|
||||
|
||||
void CV_ConvertHomogeneousTest::run_func()
|
||||
{
|
||||
CvMat _input = cvMat(test_mat[INPUT][0]), _output = cvMat(test_mat[OUTPUT][0]);
|
||||
cvConvertPointsHomogeneous( &_input, &_output );
|
||||
cv::Mat _input = test_mat[INPUT][0], &_output = test_mat[OUTPUT][0];
|
||||
if( dims1 > dims2 )
|
||||
cv::convertPointsFromHomogeneous(_input, _output);
|
||||
else
|
||||
cv::convertPointsToHomogeneous(_input, _output);
|
||||
}
|
||||
|
||||
|
||||
@ -1600,7 +1559,7 @@ void CV_ComputeEpilinesTest::get_test_array_types_and_sizes( int /*test_case_idx
|
||||
RNG& rng = ts->get_rng();
|
||||
int fm_depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F;
|
||||
int pt_depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F;
|
||||
int ln_depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F;
|
||||
int ln_depth = pt_depth;
|
||||
double pt_count_exp = cvtest::randReal(rng)*6;
|
||||
|
||||
which_image = 1 + (cvtest::randInt(rng) % 2);
|
||||
@ -1613,40 +1572,21 @@ void CV_ComputeEpilinesTest::get_test_array_types_and_sizes( int /*test_case_idx
|
||||
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, 1);
|
||||
|
||||
if( cvtest::randInt(rng) % 2 && !few_points )
|
||||
sizes[INPUT][0] = cvSize(pt_count, dims);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(dims, pt_count);
|
||||
if( cvtest::randInt(rng) % 2 || few_points )
|
||||
{
|
||||
sizes[INPUT][0] = cvSize(dims, pt_count);
|
||||
if( cvtest::randInt(rng) % 2 || few_points )
|
||||
{
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, dims);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, dims);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[INPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[INPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
|
||||
types[INPUT][1] = CV_MAKETYPE(fm_depth, 1);
|
||||
sizes[INPUT][1] = cvSize(3, 3);
|
||||
|
||||
types[OUTPUT][0] = CV_MAKETYPE(ln_depth, 1);
|
||||
|
||||
if( cvtest::randInt(rng) % 2 && !few_points )
|
||||
sizes[OUTPUT][0] = cvSize(pt_count, 3);
|
||||
else
|
||||
{
|
||||
sizes[OUTPUT][0] = cvSize(3, pt_count);
|
||||
if( cvtest::randInt(rng) % 2 || few_points )
|
||||
{
|
||||
types[OUTPUT][0] = CV_MAKETYPE(ln_depth, 3);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
sizes[OUTPUT][0] = cvSize(pt_count, 1);
|
||||
else
|
||||
sizes[OUTPUT][0] = cvSize(1, pt_count);
|
||||
}
|
||||
}
|
||||
types[OUTPUT][0] = CV_MAKETYPE(ln_depth, 3);
|
||||
sizes[OUTPUT][0] = cvSize(1, pt_count);
|
||||
|
||||
types[REF_OUTPUT][0] = types[OUTPUT][0];
|
||||
sizes[REF_OUTPUT][0] = sizes[OUTPUT][0];
|
||||
@ -1678,8 +1618,8 @@ void CV_ComputeEpilinesTest::fill_array( int test_case_idx, int i, int j, Mat& a
|
||||
|
||||
void CV_ComputeEpilinesTest::run_func()
|
||||
{
|
||||
CvMat _points = cvMat(test_mat[INPUT][0]), _F = cvMat(test_mat[INPUT][1]), _lines = cvMat(test_mat[OUTPUT][0]);
|
||||
cvComputeCorrespondEpilines( &_points, which_image, &_F, &_lines );
|
||||
cv::Mat _points = test_mat[INPUT][0], _F = test_mat[INPUT][1], &_lines = test_mat[OUTPUT][0];
|
||||
cv::computeCorrespondEpilines( _points, which_image, _F, _lines );
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +40,9 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
// POSIT is not exposed to C++ API yet, so the test is disabled
|
||||
#if 0
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -219,4 +221,7 @@ void CV_POSITTest::run( int start_from )
|
||||
TEST(Calib3d_POSIT, accuracy) { CV_POSITTest test; test.safe_run(); }
|
||||
|
||||
}} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
|
@ -41,7 +41,6 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -121,14 +120,9 @@ protected:
|
||||
|
||||
Mat_<double> Q(4, 4);
|
||||
randu(Q, Scalar(-5), Scalar(5));
|
||||
|
||||
Mat_<out3d_t> _3dImg(disp.size());
|
||||
|
||||
CvMat cvdisp = cvMat(disp); CvMat cv_3dImg = cvMat(_3dImg); CvMat cvQ = cvMat(Q);
|
||||
cvReprojectImageTo3D( &cvdisp, &cv_3dImg, &cvQ, handleMissingValues );
|
||||
|
||||
if (std::numeric_limits<OutT>::max() == std::numeric_limits<float>::max())
|
||||
reprojectImageTo3D(disp, _3dImg, Q, handleMissingValues);
|
||||
reprojectImageTo3D(disp, _3dImg, Q, handleMissingValues);
|
||||
|
||||
for(int y = 0; y < disp.rows; ++y)
|
||||
for(int x = 0; x < disp.cols; ++x)
|
||||
|
@ -42,7 +42,6 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -172,7 +171,6 @@ protected:
|
||||
const CvMat* _distCoeffs, const CvMat* matR, const CvMat* matP);
|
||||
|
||||
private:
|
||||
bool useCPlus;
|
||||
bool useDstMat;
|
||||
static const int N_POINTS = 10;
|
||||
static const int MAX_X = 2048;
|
||||
@ -204,7 +202,7 @@ CV_UndistortPointsTest::CV_UndistortPointsTest()
|
||||
test_array[TEMP].push_back(NULL); // dst points
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
|
||||
useCPlus = useDstMat = false;
|
||||
useDstMat = false;
|
||||
zero_new_cam = zero_distortion = zero_R = false;
|
||||
}
|
||||
|
||||
@ -212,16 +210,8 @@ void CV_UndistortPointsTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
{
|
||||
cvtest::ArrayTest::get_test_array_types_and_sizes(test_case_idx,sizes,types);
|
||||
RNG& rng = ts->get_rng();
|
||||
useCPlus = ((cvtest::randInt(rng) % 2)!=0);
|
||||
//useCPlus = 0;
|
||||
if (useCPlus)
|
||||
{
|
||||
types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = types[TEMP][0]= CV_32FC2;
|
||||
}
|
||||
else
|
||||
{
|
||||
types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = types[TEMP][0]= cvtest::randInt(rng)%2 ? CV_64FC2 : CV_32FC2;
|
||||
}
|
||||
//rng.next();
|
||||
types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = types[TEMP][0]= CV_32FC2;
|
||||
types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
types[INPUT][3] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
@ -364,15 +354,12 @@ int CV_UndistortPointsTest::prepare_test_case(int test_case_idx)
|
||||
zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true;
|
||||
zero_R = (cvtest::randInt(rng)%2) == 0 ? false : true;
|
||||
|
||||
if (useCPlus)
|
||||
{
|
||||
_points.convertTo(src_points, CV_32F);
|
||||
_points.convertTo(src_points, CV_32F);
|
||||
|
||||
camera_mat = test_mat[INPUT][1];
|
||||
distortion_coeffs = test_mat[INPUT][2];
|
||||
R = test_mat[INPUT][3];
|
||||
P = test_mat[INPUT][4];
|
||||
}
|
||||
camera_mat = test_mat[INPUT][1];
|
||||
distortion_coeffs = test_mat[INPUT][2];
|
||||
R = test_mat[INPUT][3];
|
||||
P = test_mat[INPUT][4];
|
||||
|
||||
return code;
|
||||
}
|
||||
@ -407,28 +394,21 @@ void CV_UndistortPointsTest::prepare_to_validation(int /*test_case_idx*/)
|
||||
cvtest::convert(test_mat[INPUT][3], __rot, __rot.type());
|
||||
cvtest::convert(test_mat[INPUT][4], __proj, __proj.type());
|
||||
|
||||
if (useCPlus)
|
||||
if (useDstMat)
|
||||
{
|
||||
if (useDstMat)
|
||||
CvMat temp = cvMat(dst_points_mat);
|
||||
for (int i=0;i<N_POINTS*2;i++)
|
||||
{
|
||||
CvMat temp = cvMat(dst_points_mat);
|
||||
for (int i=0;i<N_POINTS*2;i++)
|
||||
{
|
||||
points[i] = temp.data.fl[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0;i<N_POINTS;i++)
|
||||
{
|
||||
points[2*i] = dst_points[i].x;
|
||||
points[2*i+1] = dst_points[i].y;
|
||||
}
|
||||
points[i] = temp.data.fl[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cvtest::convert(test_mat[TEMP][0],__points, __points.type());
|
||||
for (int i=0;i<N_POINTS;i++)
|
||||
{
|
||||
points[2*i] = dst_points[i].x;
|
||||
points[2*i+1] = dst_points[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
CvMat* input2 = zero_distortion ? 0 : &_distort;
|
||||
@ -449,39 +429,20 @@ void CV_UndistortPointsTest::prepare_to_validation(int /*test_case_idx*/)
|
||||
|
||||
void CV_UndistortPointsTest::run_func()
|
||||
{
|
||||
cv::Mat input2,input3,input4;
|
||||
input2 = zero_distortion ? cv::Mat() : cv::Mat(test_mat[INPUT][2]);
|
||||
input3 = zero_R ? cv::Mat() : cv::Mat(test_mat[INPUT][3]);
|
||||
input4 = zero_new_cam ? cv::Mat() : cv::Mat(test_mat[INPUT][4]);
|
||||
|
||||
if (useCPlus)
|
||||
if (useDstMat)
|
||||
{
|
||||
cv::Mat input2,input3,input4;
|
||||
input2 = zero_distortion ? cv::Mat() : cv::Mat(test_mat[INPUT][2]);
|
||||
input3 = zero_R ? cv::Mat() : cv::Mat(test_mat[INPUT][3]);
|
||||
input4 = zero_new_cam ? cv::Mat() : cv::Mat(test_mat[INPUT][4]);
|
||||
|
||||
if (useDstMat)
|
||||
{
|
||||
//cv::undistortPoints(src_points,dst_points_mat,camera_mat,distortion_coeffs,R,P);
|
||||
cv::undistortPoints(src_points,dst_points_mat,camera_mat,input2,input3,input4);
|
||||
}
|
||||
else
|
||||
{
|
||||
//cv::undistortPoints(src_points,dst_points,camera_mat,distortion_coeffs,R,P);
|
||||
cv::undistortPoints(src_points,dst_points,camera_mat,input2,input3,input4);
|
||||
}
|
||||
//cv::undistortPoints(src_points,dst_points_mat,camera_mat,distortion_coeffs,R,P);
|
||||
cv::undistortPoints(src_points,dst_points_mat,camera_mat,input2,input3,input4);
|
||||
}
|
||||
else
|
||||
{
|
||||
CvMat _input0 = cvMat(test_mat[INPUT][0]), _input1 = cvMat(test_mat[INPUT][1]), _input2, _input3, _input4;
|
||||
CvMat _output = cvMat(test_mat[TEMP][0]);
|
||||
if(!zero_distortion)
|
||||
_input2 = cvMat(test_mat[INPUT][2]);
|
||||
if(!zero_R)
|
||||
_input3 = cvMat(test_mat[INPUT][3]);
|
||||
if(!zero_new_cam)
|
||||
_input4 = cvMat(test_mat[INPUT][4]);
|
||||
cvUndistortPoints(&_input0, &_output, &_input1,
|
||||
zero_distortion ? 0 : &_input2,
|
||||
zero_R ? 0 : &_input3,
|
||||
zero_new_cam ? 0 : &_input4);
|
||||
//cv::undistortPoints(src_points,dst_points,camera_mat,distortion_coeffs,R,P);
|
||||
cv::undistortPoints(src_points,dst_points,camera_mat,input2,input3,input4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,83 +541,76 @@ protected:
|
||||
void run_func();
|
||||
|
||||
private:
|
||||
bool useCPlus;
|
||||
static const int N_POINTS = 100;
|
||||
static const int MAX_X = 2048;
|
||||
static const int MAX_Y = 2048;
|
||||
static const int MAX_X = 1024;
|
||||
static const int MAX_Y = 1024;
|
||||
bool zero_new_cam;
|
||||
bool zero_distortion;
|
||||
bool zero_R;
|
||||
|
||||
|
||||
cv::Size img_size;
|
||||
|
||||
cv::Mat camera_mat;
|
||||
cv::Mat R;
|
||||
cv::Mat new_camera_mat;
|
||||
cv::Mat distortion_coeffs;
|
||||
cv::Mat mapx;
|
||||
cv::Mat mapy;
|
||||
CvMat* _mapx;
|
||||
CvMat* _mapy;
|
||||
int mat_type;
|
||||
int map_type;
|
||||
};
|
||||
|
||||
CV_InitUndistortRectifyMapTest::CV_InitUndistortRectifyMapTest()
|
||||
{
|
||||
test_array[INPUT].push_back(NULL); // test points matrix
|
||||
test_array[INPUT].push_back(NULL); // camera matrix
|
||||
test_array[INPUT].push_back(NULL); // distortion coeffs
|
||||
test_array[INPUT].push_back(NULL); // R matrix
|
||||
test_array[INPUT].push_back(NULL); // new camera matrix
|
||||
test_array[OUTPUT].push_back(NULL); // distorted dst points
|
||||
test_array[OUTPUT].push_back(NULL); // distorted mapx
|
||||
test_array[OUTPUT].push_back(NULL); // distorted mapy
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
|
||||
useCPlus = false;
|
||||
zero_distortion = zero_new_cam = zero_R = false;
|
||||
_mapx = _mapy = NULL;
|
||||
mat_type = 0;
|
||||
map_type = 0;
|
||||
}
|
||||
|
||||
void CV_InitUndistortRectifyMapTest::get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types )
|
||||
{
|
||||
cvtest::ArrayTest::get_test_array_types_and_sizes(test_case_idx,sizes,types);
|
||||
RNG& rng = ts->get_rng();
|
||||
useCPlus = ((cvtest::randInt(rng) % 2)!=0);
|
||||
//useCPlus = 0;
|
||||
types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_64FC2;
|
||||
//rng.next();
|
||||
|
||||
map_type = CV_32F;
|
||||
types[OUTPUT][0] = types[OUTPUT][1] = types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = map_type;
|
||||
|
||||
img_size.width = cvtest::randInt(rng) % MAX_X + 1;
|
||||
img_size.height = cvtest::randInt(rng) % MAX_Y + 1;
|
||||
|
||||
types[INPUT][0] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
types[INPUT][3] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
types[INPUT][4] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
|
||||
sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(N_POINTS,1);
|
||||
sizes[INPUT][1] = sizes[INPUT][3] = cvSize(3,3);
|
||||
sizes[INPUT][4] = cvSize(3,3);
|
||||
sizes[OUTPUT][0] = sizes[OUTPUT][1] = sizes[REF_OUTPUT][0] = sizes[REF_OUTPUT][1] = img_size;
|
||||
sizes[INPUT][0] = sizes[INPUT][2] = sizes[INPUT][3] = cvSize(3,3);
|
||||
|
||||
Size dsize;
|
||||
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(1,4);
|
||||
dsize = Size(1,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(1,5);
|
||||
dsize = Size(1,5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(4,1);
|
||||
dsize = Size(4,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(5,1);
|
||||
dsize = Size(5,1);
|
||||
}
|
||||
}
|
||||
sizes[INPUT][1] = dsize;
|
||||
}
|
||||
|
||||
|
||||
@ -668,48 +622,14 @@ int CV_InitUndistortRectifyMapTest::prepare_test_case(int test_case_idx)
|
||||
if (code <= 0)
|
||||
return code;
|
||||
|
||||
img_size.width = cvtest::randInt(rng) % MAX_X + 1;
|
||||
img_size.height = cvtest::randInt(rng) % MAX_Y + 1;
|
||||
|
||||
if (useCPlus)
|
||||
{
|
||||
mat_type = (cvtest::randInt(rng) % 2) == 0 ? CV_32FC1 : CV_16SC2;
|
||||
if ((cvtest::randInt(rng) % 4) == 0)
|
||||
mat_type = -1;
|
||||
if ((cvtest::randInt(rng) % 4) == 0)
|
||||
mat_type = CV_32FC2;
|
||||
_mapx = 0;
|
||||
_mapy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int typex = (cvtest::randInt(rng) % 2) == 0 ? CV_32FC1 : CV_16SC2;
|
||||
//typex = CV_32FC1; ///!!!!!!!!!!!!!!!!
|
||||
int typey = (typex == CV_32FC1) ? CV_32FC1 : CV_16UC1;
|
||||
|
||||
_mapx = cvCreateMat(img_size.height,img_size.width,typex);
|
||||
_mapy = cvCreateMat(img_size.height,img_size.width,typey);
|
||||
|
||||
|
||||
}
|
||||
|
||||
int dist_size = test_mat[INPUT][2].cols > test_mat[INPUT][2].rows ? test_mat[INPUT][2].cols : test_mat[INPUT][2].rows;
|
||||
int dist_size = test_mat[INPUT][1].cols > test_mat[INPUT][1].rows ? test_mat[INPUT][1].cols : test_mat[INPUT][1].rows;
|
||||
double cam[9] = {0,0,0,0,0,0,0,0,1};
|
||||
vector<double> dist(dist_size);
|
||||
vector<double> new_cam(test_mat[INPUT][4].cols * test_mat[INPUT][4].rows);
|
||||
vector<Point2d> points(N_POINTS);
|
||||
vector<double> new_cam(test_mat[INPUT][3].cols * test_mat[INPUT][3].rows);
|
||||
|
||||
Mat _camera(3,3,CV_64F,cam);
|
||||
Mat _distort(test_mat[INPUT][2].size(),CV_64F,&dist[0]);
|
||||
Mat _new_cam(test_mat[INPUT][4].size(),CV_64F,&new_cam[0]);
|
||||
Mat _points(test_mat[INPUT][0].size(),CV_64FC2, &points[0]);
|
||||
|
||||
//Generating points
|
||||
for (int i=0;i<N_POINTS;i++)
|
||||
{
|
||||
points[i].x = cvtest::randReal(rng)*img_size.width;
|
||||
points[i].y = cvtest::randReal(rng)*img_size.height;
|
||||
}
|
||||
Mat _distort(test_mat[INPUT][1].size(),CV_64F,&dist[0]);
|
||||
Mat _new_cam(test_mat[INPUT][3].size(),CV_64F,&new_cam[0]);
|
||||
|
||||
//Generating camera matrix
|
||||
double sz = MAX(img_size.width,img_size.height);
|
||||
@ -752,7 +672,6 @@ int CV_InitUndistortRectifyMapTest::prepare_test_case(int test_case_idx)
|
||||
new_cam[2] = cam[2] + (cvtest::randReal(rng) - (double)0.5)*0.3*img_size.width; //15%
|
||||
new_cam[5] = cam[5] + (cvtest::randReal(rng) - (double)0.5)*0.3*img_size.height; //15%
|
||||
|
||||
|
||||
//Generating R matrix
|
||||
Mat _rot(3,3,CV_64F);
|
||||
Mat rotation(1,3,CV_64F);
|
||||
@ -763,169 +682,36 @@ int CV_InitUndistortRectifyMapTest::prepare_test_case(int test_case_idx)
|
||||
|
||||
//cvSetIdentity(_rot);
|
||||
//copying data
|
||||
cvtest::convert( _points, test_mat[INPUT][0], test_mat[INPUT][0].type());
|
||||
cvtest::convert( _camera, test_mat[INPUT][1], test_mat[INPUT][1].type());
|
||||
cvtest::convert( _distort, test_mat[INPUT][2], test_mat[INPUT][2].type());
|
||||
cvtest::convert( _rot, test_mat[INPUT][3], test_mat[INPUT][3].type());
|
||||
cvtest::convert( _new_cam, test_mat[INPUT][4], test_mat[INPUT][4].type());
|
||||
cvtest::convert( _camera, test_mat[INPUT][0], test_mat[INPUT][0].type());
|
||||
cvtest::convert( _distort, test_mat[INPUT][1], test_mat[INPUT][1].type());
|
||||
cvtest::convert( _rot, test_mat[INPUT][2], test_mat[INPUT][2].type());
|
||||
cvtest::convert( _new_cam, test_mat[INPUT][3], test_mat[INPUT][3].type());
|
||||
|
||||
zero_distortion = (cvtest::randInt(rng)%2) == 0 ? false : true;
|
||||
zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true;
|
||||
zero_R = (cvtest::randInt(rng)%2) == 0 ? false : true;
|
||||
|
||||
if (useCPlus)
|
||||
{
|
||||
camera_mat = test_mat[INPUT][1];
|
||||
distortion_coeffs = test_mat[INPUT][2];
|
||||
R = test_mat[INPUT][3];
|
||||
new_camera_mat = test_mat[INPUT][4];
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/)
|
||||
{
|
||||
#if 0
|
||||
int dist_size = test_mat[INPUT][2].cols > test_mat[INPUT][2].rows ? test_mat[INPUT][2].cols : test_mat[INPUT][2].rows;
|
||||
double cam[9] = {0,0,0,0,0,0,0,0,1};
|
||||
double rot[9] = {1,0,0,0,1,0,0,0,1};
|
||||
vector<double> dist(dist_size);
|
||||
vector<double> new_cam(test_mat[INPUT][4].cols * test_mat[INPUT][4].rows);
|
||||
vector<Point2d> points(N_POINTS);
|
||||
vector<Point2d> r_points(N_POINTS);
|
||||
//Run reference calculations
|
||||
Mat ref_points(test_mat[INPUT][0].size(),CV_64FC2,&r_points[0]);
|
||||
Mat _camera(3,3,CV_64F,cam);
|
||||
Mat _rot(3,3,CV_64F,rot);
|
||||
Mat _distort(test_mat[INPUT][2].size(),CV_64F,&dist[0]);
|
||||
Mat _new_cam(test_mat[INPUT][4].size(),CV_64F,&new_cam[0]);
|
||||
Mat _points(test_mat[INPUT][0].size(),CV_64FC2,&points[0]);
|
||||
|
||||
cvtest::convert(test_mat[INPUT][1],_camera,_camera.type());
|
||||
cvtest::convert(test_mat[INPUT][2],_distort,_distort.type());
|
||||
cvtest::convert(test_mat[INPUT][3],_rot,_rot.type());
|
||||
cvtest::convert(test_mat[INPUT][4],_new_cam,_new_cam.type());
|
||||
|
||||
//Applying precalculated undistort rectify map
|
||||
if (!useCPlus)
|
||||
{
|
||||
mapx = cv::Mat(_mapx);
|
||||
mapy = cv::Mat(_mapy);
|
||||
}
|
||||
cv::Mat map1,map2;
|
||||
cv::convertMaps(mapx,mapy,map1,map2,CV_32FC1);
|
||||
CvMat _map1 = map1;
|
||||
CvMat _map2 = map2;
|
||||
const Point2d* sptr = (const Point2d*)test_mat[INPUT][0].data;
|
||||
for( int i = 0;i < N_POINTS; i++ )
|
||||
{
|
||||
int u = saturate_cast<int>(sptr[i].x);
|
||||
int v = saturate_cast<int>(sptr[i].y);
|
||||
points[i].x = _map1.data.fl[v*_map1.cols + u];
|
||||
points[i].y = _map2.data.fl[v*_map2.cols + u];
|
||||
}
|
||||
|
||||
//---
|
||||
|
||||
cv::undistortPoints(_points, ref_points, _camera,
|
||||
zero_distortion ? Mat() : _distort,
|
||||
zero_R ? Mat::eye(3,3,CV_64F) : _rot,
|
||||
zero_new_cam ? _camera : _new_cam);
|
||||
//cvTsDistortPoints(&_points,&ref_points,&_camera,&_distort,&_rot,&_new_cam);
|
||||
cvtest::convert(ref_points, test_mat[REF_OUTPUT][0], test_mat[REF_OUTPUT][0].type());
|
||||
cvtest::copy(test_mat[INPUT][0],test_mat[OUTPUT][0]);
|
||||
|
||||
cvReleaseMat(&_mapx);
|
||||
cvReleaseMat(&_mapy);
|
||||
#else
|
||||
int dist_size = test_mat[INPUT][2].cols > test_mat[INPUT][2].rows ? test_mat[INPUT][2].cols : test_mat[INPUT][2].rows;
|
||||
double cam[9] = {0,0,0,0,0,0,0,0,1};
|
||||
double rot[9] = {1,0,0,0,1,0,0,0,1};
|
||||
double* dist = new double[dist_size ];
|
||||
double* new_cam = new double[test_mat[INPUT][4].cols * test_mat[INPUT][4].rows];
|
||||
double* points = new double[N_POINTS*2];
|
||||
double* r_points = new double[N_POINTS*2];
|
||||
//Run reference calculations
|
||||
CvMat ref_points= cvMat(test_mat[INPUT][0].rows,test_mat[INPUT][0].cols,CV_64FC2,r_points);
|
||||
CvMat _camera = cvMat(3,3,CV_64F,cam);
|
||||
CvMat _rot = cvMat(3,3,CV_64F,rot);
|
||||
CvMat _distort = cvMat(test_mat[INPUT][2].rows,test_mat[INPUT][2].cols,CV_64F,dist);
|
||||
CvMat _new_cam = cvMat(test_mat[INPUT][4].rows,test_mat[INPUT][4].cols,CV_64F,new_cam);
|
||||
CvMat _points= cvMat(test_mat[INPUT][0].rows,test_mat[INPUT][0].cols,CV_64FC2,points);
|
||||
|
||||
CvMat _input1 = cvMat(test_mat[INPUT][1]);
|
||||
CvMat _input2 = cvMat(test_mat[INPUT][2]);
|
||||
CvMat _input3 = cvMat(test_mat[INPUT][3]);
|
||||
CvMat _input4 = cvMat(test_mat[INPUT][4]);
|
||||
|
||||
cvtest::convert(cvarrToMat(&_input1), cvarrToMat(&_camera), -1);
|
||||
cvtest::convert(cvarrToMat(&_input2), cvarrToMat(&_distort), -1);
|
||||
cvtest::convert(cvarrToMat(&_input3), cvarrToMat(&_rot), -1);
|
||||
cvtest::convert(cvarrToMat(&_input4), cvarrToMat(&_new_cam), -1);
|
||||
|
||||
//Applying precalculated undistort rectify map
|
||||
if (!useCPlus)
|
||||
{
|
||||
mapx = cv::cvarrToMat(_mapx);
|
||||
mapy = cv::cvarrToMat(_mapy);
|
||||
}
|
||||
cv::Mat map1,map2;
|
||||
cv::convertMaps(mapx,mapy,map1,map2,CV_32FC1);
|
||||
CvMat _map1 = cvMat(map1);
|
||||
CvMat _map2 = cvMat(map2);
|
||||
for (int i=0;i<N_POINTS;i++)
|
||||
{
|
||||
double u = test_mat[INPUT][0].ptr<double>()[2*i];
|
||||
double v = test_mat[INPUT][0].ptr<double>()[2*i+1];
|
||||
_points.data.db[2*i] = (double)_map1.data.fl[(int)v*_map1.cols+(int)u];
|
||||
_points.data.db[2*i+1] = (double)_map2.data.fl[(int)v*_map2.cols+(int)u];
|
||||
}
|
||||
|
||||
//---
|
||||
|
||||
cvUndistortPoints(&_points,&ref_points,&_camera,
|
||||
zero_distortion ? 0 : &_distort, zero_R ? 0 : &_rot, zero_new_cam ? &_camera : &_new_cam);
|
||||
//cvTsDistortPoints(&_points,&ref_points,&_camera,&_distort,&_rot,&_new_cam);
|
||||
CvMat dst = cvMat(test_mat[REF_OUTPUT][0]);
|
||||
cvtest::convert(cvarrToMat(&ref_points), cvarrToMat(&dst), -1);
|
||||
|
||||
cvtest::copy(test_mat[INPUT][0],test_mat[OUTPUT][0]);
|
||||
|
||||
delete[] dist;
|
||||
delete[] new_cam;
|
||||
delete[] points;
|
||||
delete[] r_points;
|
||||
cvReleaseMat(&_mapx);
|
||||
cvReleaseMat(&_mapy);
|
||||
#endif
|
||||
cvtest::initUndistortMap(test_mat[INPUT][0],
|
||||
zero_distortion ? cv::Mat() : test_mat[INPUT][1],
|
||||
zero_R ? cv::Mat() : test_mat[INPUT][2],
|
||||
zero_new_cam ? test_mat[INPUT][0] : test_mat[INPUT][3],
|
||||
img_size, test_mat[REF_OUTPUT][0], test_mat[REF_OUTPUT][1],
|
||||
test_mat[REF_OUTPUT][0].type());
|
||||
}
|
||||
|
||||
void CV_InitUndistortRectifyMapTest::run_func()
|
||||
{
|
||||
if (useCPlus)
|
||||
{
|
||||
cv::Mat input2,input3,input4;
|
||||
input2 = zero_distortion ? cv::Mat() : test_mat[INPUT][2];
|
||||
input3 = zero_R ? cv::Mat() : test_mat[INPUT][3];
|
||||
input4 = zero_new_cam ? cv::Mat() : test_mat[INPUT][4];
|
||||
cv::initUndistortRectifyMap(camera_mat,input2,input3,input4,img_size,mat_type,mapx,mapy);
|
||||
}
|
||||
else
|
||||
{
|
||||
CvMat input1 = cvMat(test_mat[INPUT][1]), input2, input3, input4;
|
||||
if( !zero_distortion )
|
||||
input2 = cvMat(test_mat[INPUT][2]);
|
||||
if( !zero_R )
|
||||
input3 = cvMat(test_mat[INPUT][3]);
|
||||
if( !zero_new_cam )
|
||||
input4 = cvMat(test_mat[INPUT][4]);
|
||||
cvInitUndistortRectifyMap(&input1,
|
||||
zero_distortion ? 0 : &input2,
|
||||
zero_R ? 0 : &input3,
|
||||
zero_new_cam ? 0 : &input4,
|
||||
_mapx,_mapy);
|
||||
}
|
||||
cv::Mat camera_mat = test_mat[INPUT][0];
|
||||
cv::Mat dist = zero_distortion ? cv::Mat() : test_mat[INPUT][1];
|
||||
cv::Mat R = zero_R ? cv::Mat() : test_mat[INPUT][2];
|
||||
cv::Mat new_cam = zero_new_cam ? cv::Mat() : test_mat[INPUT][3];
|
||||
cv::Mat& mapx = test_mat[OUTPUT][0], &mapy = test_mat[OUTPUT][1];
|
||||
cv::initUndistortRectifyMap(camera_mat,dist,R,new_cam,img_size,map_type,mapx,mapy);
|
||||
}
|
||||
|
||||
double CV_InitUndistortRectifyMapTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ )
|
||||
@ -1227,7 +1013,6 @@ protected:
|
||||
void fill_array( int test_case_idx, int i, int j, Mat& arr );
|
||||
|
||||
private:
|
||||
bool useCPlus;
|
||||
cv::Mat input0;
|
||||
cv::Mat input1;
|
||||
cv::Mat input2;
|
||||
@ -1276,21 +1061,13 @@ void CV_UndistortTest::fill_array( int test_case_idx, int i, int j, Mat& arr )
|
||||
|
||||
void CV_UndistortTest::run_func()
|
||||
{
|
||||
if (!useCPlus)
|
||||
if (zero_distortion)
|
||||
{
|
||||
CvMat a = cvMat(test_mat[INPUT][1]), k = cvMat(test_mat[INPUT][2]);
|
||||
cvUndistort2( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &a, &k);
|
||||
cv::undistort(input0,input_output,input1,cv::Mat());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zero_distortion)
|
||||
{
|
||||
cv::undistort(input0,input_output,input1,cv::Mat());
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::undistort(input0,input_output,input1,input2);
|
||||
}
|
||||
cv::undistort(input0,input_output,input1,input2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1353,14 +1130,11 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
|
||||
_new_cam.convertTo(_new_cam0, _new_cam0.depth());
|
||||
|
||||
//Testing C++ code
|
||||
useCPlus = ((cvtest::randInt(rng) % 2)!=0);
|
||||
if (useCPlus)
|
||||
{
|
||||
input0 = test_mat[INPUT][0];
|
||||
input1 = test_mat[INPUT][1];
|
||||
input2 = test_mat[INPUT][2];
|
||||
input_new_cam = test_mat[INPUT][3];
|
||||
}
|
||||
//useCPlus = ((cvtest::randInt(rng) % 2)!=0);
|
||||
input0 = test_mat[INPUT][0];
|
||||
input1 = test_mat[INPUT][1];
|
||||
input2 = test_mat[INPUT][2];
|
||||
input_new_cam = test_mat[INPUT][3];
|
||||
|
||||
return code;
|
||||
}
|
||||
@ -1368,16 +1142,14 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
void CV_UndistortTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
{
|
||||
if (useCPlus)
|
||||
{
|
||||
Mat& output = test_mat[INPUT_OUTPUT][0];
|
||||
input_output.convertTo(output, output.type());
|
||||
}
|
||||
Mat& output = test_mat[INPUT_OUTPUT][0];
|
||||
input_output.convertTo(output, output.type());
|
||||
Mat& src = test_mat[INPUT][0];
|
||||
Mat& dst = test_mat[REF_INPUT_OUTPUT][0];
|
||||
Mat& dst0 = test_mat[INPUT_OUTPUT][0];
|
||||
Mat mapx, mapy;
|
||||
cvtest::initUndistortMap( test_mat[INPUT][1], test_mat[INPUT][2], dst.size(), mapx, mapy );
|
||||
cvtest::initUndistortMap( test_mat[INPUT][1], test_mat[INPUT][2],
|
||||
Mat(), Mat(), dst.size(), mapx, mapy, CV_32F );
|
||||
Mat mask( dst.size(), CV_8U );
|
||||
test_remap( src, dst, mapx, mapy, &mask, interpolation );
|
||||
dst.setTo(Scalar::all(0), mask);
|
||||
@ -1446,12 +1218,13 @@ void CV_UndistortMapTest::fill_array( int test_case_idx, int i, int j, Mat& arr
|
||||
|
||||
void CV_UndistortMapTest::run_func()
|
||||
{
|
||||
CvMat a = cvMat(test_mat[INPUT][0]), k = cvMat(test_mat[INPUT][1]);
|
||||
cv::Mat a = test_mat[INPUT][0], k = test_mat[INPUT][1];
|
||||
cv::Mat &mapx = test_mat[OUTPUT][0], &mapy = !dualChannel ? test_mat[OUTPUT][1] : mapx;
|
||||
cv::Size mapsz = test_mat[OUTPUT][0].size();
|
||||
|
||||
if (!dualChannel )
|
||||
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], test_array[OUTPUT][1] );
|
||||
else
|
||||
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], 0 );
|
||||
cv::initUndistortRectifyMap(a, k, cv::Mat(), a,
|
||||
mapsz, dualChannel ? CV_32FC2 : CV_32FC1,
|
||||
mapx, !dualChannel ? cv::_InputOutputArray(mapy) : cv::noArray());
|
||||
}
|
||||
|
||||
|
||||
@ -1503,7 +1276,8 @@ int CV_UndistortMapTest::prepare_test_case( int test_case_idx )
|
||||
void CV_UndistortMapTest::prepare_to_validation( int )
|
||||
{
|
||||
Mat mapx, mapy;
|
||||
cvtest::initUndistortMap( test_mat[INPUT][0], test_mat[INPUT][1], test_mat[REF_OUTPUT][0].size(), mapx, mapy );
|
||||
cvtest::initUndistortMap( test_mat[INPUT][0], test_mat[INPUT][1], Mat(), Mat(),
|
||||
test_mat[REF_OUTPUT][0].size(), mapx, mapy, CV_32F );
|
||||
if( !dualChannel )
|
||||
{
|
||||
mapx.copyTo(test_mat[REF_OUTPUT][0]);
|
||||
|
@ -40,7 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -55,19 +55,9 @@ protected:
|
||||
private:
|
||||
//common
|
||||
cv::Size img_size;
|
||||
bool useCPlus;
|
||||
//static const int N_POINTS = 1;
|
||||
static const int N_POINTS2 = 2;
|
||||
|
||||
//C
|
||||
CvMat* _camera_mat;
|
||||
CvMat* matR;
|
||||
CvMat* matP;
|
||||
CvMat* _distortion_coeffs;
|
||||
CvMat* _src_points;
|
||||
CvMat* _dst_points;
|
||||
|
||||
|
||||
//C++
|
||||
cv::Mat camera_mat;
|
||||
cv::Mat R;
|
||||
@ -80,27 +70,17 @@ private:
|
||||
|
||||
CV_UndistortPointsBadArgTest::CV_UndistortPointsBadArgTest ()
|
||||
{
|
||||
useCPlus = false;
|
||||
_camera_mat = matR = matP = _distortion_coeffs = _src_points = _dst_points = NULL;
|
||||
}
|
||||
|
||||
void CV_UndistortPointsBadArgTest::run_func()
|
||||
{
|
||||
if (useCPlus)
|
||||
{
|
||||
cv::undistortPoints(src_points,dst_points,camera_mat,distortion_coeffs,R,P);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvUndistortPoints(_src_points,_dst_points,_camera_mat,_distortion_coeffs,matR,matP);
|
||||
}
|
||||
cv::undistortPoints(src_points,dst_points,camera_mat,distortion_coeffs,R,P);
|
||||
}
|
||||
|
||||
void CV_UndistortPointsBadArgTest::run(int)
|
||||
{
|
||||
//RNG& rng = ts->get_rng();
|
||||
int errcount = 0;
|
||||
useCPlus = false;
|
||||
//initializing
|
||||
img_size.width = 800;
|
||||
img_size.height = 600;
|
||||
@ -110,7 +90,6 @@ void CV_UndistortPointsBadArgTest::run(int)
|
||||
static_cast<double>(img_size.width) / 4.0,
|
||||
static_cast<double>(img_size.height) / 4.0,
|
||||
};
|
||||
double d_points[N_POINTS2];
|
||||
double p[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f};
|
||||
double r[9] = {1,0,0,0,1,0,0,0,1};
|
||||
|
||||
@ -119,137 +98,6 @@ void CV_UndistortPointsBadArgTest::run(int)
|
||||
CvMat _P_orig = cvMat(3,3,CV_64F,p);
|
||||
CvMat _R_orig = cvMat(3,3,CV_64F,r);
|
||||
CvMat _src_points_orig = cvMat(1,4,CV_64FC2,s_points);
|
||||
CvMat _dst_points_orig = cvMat(1,4,CV_64FC2,d_points);
|
||||
|
||||
_camera_mat = &_camera_mat_orig;
|
||||
_distortion_coeffs = &_distortion_coeffs_orig;
|
||||
matP = &_P_orig;
|
||||
matR = &_R_orig;
|
||||
_src_points = &_src_points_orig;
|
||||
_dst_points = &_dst_points_orig;
|
||||
|
||||
//tests
|
||||
CvMat* temp1;
|
||||
CvMat* temp;
|
||||
IplImage* temp_img = cvCreateImage(cvSize(img_size.width,img_size.height),8,3);
|
||||
|
||||
//-----------
|
||||
temp = (CvMat*)temp_img;
|
||||
_src_points = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Input data is not CvMat*" );
|
||||
_src_points = &_src_points_orig;
|
||||
|
||||
temp = (CvMat*)temp_img;
|
||||
_dst_points = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Output data is not CvMat*" );
|
||||
_dst_points = &_dst_points_orig;
|
||||
|
||||
temp = cvCreateMat(2,3,CV_64F);
|
||||
_src_points = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid input data matrix size" );
|
||||
_src_points = &_src_points_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(2,3,CV_64F);
|
||||
_dst_points = temp;
|
||||
errcount += run_test_case(CV_StsAssert, "Invalid output data matrix size" );
|
||||
_dst_points = &_dst_points_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(1,3,CV_64F);
|
||||
temp1 = cvCreateMat(4,1,CV_64F);
|
||||
_dst_points = temp;
|
||||
_src_points = temp1;
|
||||
errcount += run_test_case(CV_StsAssert, "Output and input data sizes mismatch" );
|
||||
_dst_points = &_dst_points_orig;
|
||||
_src_points = &_src_points_orig;
|
||||
cvReleaseMat(&temp);
|
||||
cvReleaseMat(&temp1);
|
||||
|
||||
temp = cvCreateMat(1,3,CV_32S);
|
||||
_dst_points = temp;
|
||||
errcount += run_test_case(CV_StsAssert, "Invalid output data matrix type" );
|
||||
_dst_points = &_dst_points_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(1,3,CV_32S);
|
||||
_src_points = temp;
|
||||
errcount += run_test_case(CV_StsAssert, "Invalid input data matrix type" );
|
||||
_src_points = &_src_points_orig;
|
||||
cvReleaseMat(&temp);
|
||||
//------------
|
||||
temp = cvCreateMat(2,3,CV_64F);
|
||||
_camera_mat = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid camera data matrix size" );
|
||||
_camera_mat = &_camera_mat_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(3,4,CV_64F);
|
||||
_camera_mat = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid camera data matrix size" );
|
||||
_camera_mat = &_camera_mat_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = (CvMat*)temp_img;
|
||||
_camera_mat = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Camera data is not CvMat*" );
|
||||
_camera_mat = &_camera_mat_orig;
|
||||
//----------
|
||||
|
||||
temp = (CvMat*)temp_img;
|
||||
_distortion_coeffs = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Distortion coefficients data is not CvMat*" );
|
||||
_distortion_coeffs = &_distortion_coeffs_orig;
|
||||
|
||||
temp = cvCreateMat(1,6,CV_64F);
|
||||
_distortion_coeffs = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid distortion coefficients data matrix size" );
|
||||
_distortion_coeffs = &_distortion_coeffs_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(3,3,CV_64F);
|
||||
_distortion_coeffs = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid distortion coefficients data matrix size" );
|
||||
_distortion_coeffs = &_distortion_coeffs_orig;
|
||||
cvReleaseMat(&temp);
|
||||
//----------
|
||||
temp = (CvMat*)temp_img;
|
||||
matR = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "R data is not CvMat*" );
|
||||
matR = &_R_orig;
|
||||
|
||||
temp = cvCreateMat(4,3,CV_64F);
|
||||
matR = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid R data matrix size" );
|
||||
matR = &_R_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(3,2,CV_64F);
|
||||
matR = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid R data matrix size" );
|
||||
matR = &_R_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
//-----------
|
||||
temp = (CvMat*)temp_img;
|
||||
matP = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "P data is not CvMat*" );
|
||||
matP = &_P_orig;
|
||||
|
||||
temp = cvCreateMat(4,3,CV_64F);
|
||||
matP = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid P data matrix size" );
|
||||
matP = &_P_orig;
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(3,2,CV_64F);
|
||||
matP = temp;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid P data matrix size" );
|
||||
matP = &_P_orig;
|
||||
cvReleaseMat(&temp);
|
||||
//------------
|
||||
//C++ tests
|
||||
useCPlus = true;
|
||||
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
@ -257,27 +105,19 @@ void CV_UndistortPointsBadArgTest::run(int)
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
|
||||
temp = cvCreateMat(2,2,CV_32FC2);
|
||||
src_points = cv::cvarrToMat(temp);
|
||||
src_points.create(2, 2, CV_32F);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid input data matrix size" );
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(1,4,CV_64FC2);
|
||||
src_points = cv::cvarrToMat(temp);
|
||||
src_points.create(1, 4, CV_64FC2);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid input data matrix type" );
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
src_points = cv::Mat();
|
||||
errcount += run_test_case( CV_StsAssert, "Input data matrix is not continuous" );
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
|
||||
|
||||
//------------
|
||||
cvReleaseImage(&temp_img);
|
||||
ts->set_failed_test_info(errcount > 0 ? cvtest::TS::FAIL_BAD_ARG_CHECK : cvtest::TS::OK);
|
||||
}
|
||||
|
||||
@ -292,20 +132,7 @@ protected:
|
||||
void run_func();
|
||||
|
||||
private:
|
||||
//common
|
||||
cv::Size img_size;
|
||||
bool useCPlus;
|
||||
|
||||
//C
|
||||
CvMat* _camera_mat;
|
||||
CvMat* matR;
|
||||
CvMat* _new_camera_mat;
|
||||
CvMat* _distortion_coeffs;
|
||||
CvMat* _mapx;
|
||||
CvMat* _mapy;
|
||||
|
||||
|
||||
//C++
|
||||
cv::Mat camera_mat;
|
||||
cv::Mat R;
|
||||
cv::Mat new_camera_mat;
|
||||
@ -318,20 +145,11 @@ private:
|
||||
|
||||
CV_InitUndistortRectifyMapBadArgTest::CV_InitUndistortRectifyMapBadArgTest ()
|
||||
{
|
||||
useCPlus = false;
|
||||
_camera_mat = matR = _new_camera_mat = _distortion_coeffs = _mapx = _mapy = NULL;
|
||||
}
|
||||
|
||||
void CV_InitUndistortRectifyMapBadArgTest::run_func()
|
||||
{
|
||||
if (useCPlus)
|
||||
{
|
||||
cv::initUndistortRectifyMap(camera_mat,distortion_coeffs,R,new_camera_mat,img_size,mat_type,mapx,mapy);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvInitUndistortRectifyMap(_camera_mat,_distortion_coeffs,matR,_new_camera_mat,_mapx,_mapy);
|
||||
}
|
||||
cv::initUndistortRectifyMap(camera_mat,distortion_coeffs,R,new_camera_mat,img_size,mat_type,mapx,mapy);
|
||||
}
|
||||
|
||||
void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
@ -342,8 +160,8 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
img_size.height = 600;
|
||||
double cam[9] = {150.f, 0.f, img_size.width/2.f, 0, 300.f, img_size.height/2.f, 0.f, 0.f, 1.f};
|
||||
double dist[4] = {0.01,0.02,0.001,0.0005};
|
||||
float* arr_mapx = new float[img_size.width*img_size.height];
|
||||
float* arr_mapy = new float[img_size.width*img_size.height];
|
||||
std::vector<float> arr_mapx(img_size.width*img_size.height);
|
||||
std::vector<float> arr_mapy(img_size.width*img_size.height);
|
||||
double arr_new_camera_mat[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f};
|
||||
double r[9] = {1,0,0,0,1,0,0,0,1};
|
||||
|
||||
@ -351,25 +169,10 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64F,dist);
|
||||
CvMat _new_camera_mat_orig = cvMat(3,3,CV_64F,arr_new_camera_mat);
|
||||
CvMat _R_orig = cvMat(3,3,CV_64F,r);
|
||||
CvMat _mapx_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_mapx);
|
||||
CvMat _mapy_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_mapy);
|
||||
CvMat _mapx_orig = cvMat(img_size.height,img_size.width,CV_32FC1,&arr_mapx[0]);
|
||||
CvMat _mapy_orig = cvMat(img_size.height,img_size.width,CV_32FC1,&arr_mapy[0]);
|
||||
int mat_type_orig = CV_32FC1;
|
||||
|
||||
_camera_mat = &_camera_mat_orig;
|
||||
_distortion_coeffs = &_distortion_coeffs_orig;
|
||||
_new_camera_mat = &_new_camera_mat_orig;
|
||||
matR = &_R_orig;
|
||||
_mapx = &_mapx_orig;
|
||||
_mapy = &_mapy_orig;
|
||||
mat_type = mat_type_orig;
|
||||
|
||||
//tests
|
||||
useCPlus = true;
|
||||
CvMat* temp;
|
||||
|
||||
//C++ tests
|
||||
useCPlus = true;
|
||||
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
new_camera_mat = cv::cvarrToMat(&_new_camera_mat_orig);
|
||||
@ -377,32 +180,23 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
mapx = cv::cvarrToMat(&_mapx_orig);
|
||||
mapy = cv::cvarrToMat(&_mapy_orig);
|
||||
|
||||
|
||||
mat_type = CV_64F;
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid map matrix type" );
|
||||
mat_type = mat_type_orig;
|
||||
|
||||
temp = cvCreateMat(3,2,CV_32FC1);
|
||||
camera_mat = cv::cvarrToMat(temp);
|
||||
camera_mat.create(3, 2, CV_32F);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid camera data matrix size" );
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(4,3,CV_32FC1);
|
||||
R = cv::cvarrToMat(temp);
|
||||
R.create(4, 3, CV_32F);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid R data matrix size" );
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(6,1,CV_32FC1);
|
||||
distortion_coeffs = cv::cvarrToMat(temp);
|
||||
distortion_coeffs.create(6, 1, CV_32F);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid distortion coefficients data matrix size" );
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
//------------
|
||||
delete[] arr_mapx;
|
||||
delete[] arr_mapy;
|
||||
ts->set_failed_test_info(errcount > 0 ? cvtest::TS::FAIL_BAD_ARG_CHECK : cvtest::TS::OK);
|
||||
}
|
||||
|
||||
@ -419,17 +213,7 @@ protected:
|
||||
private:
|
||||
//common
|
||||
cv::Size img_size;
|
||||
bool useCPlus;
|
||||
|
||||
//C
|
||||
CvMat* _camera_mat;
|
||||
CvMat* _new_camera_mat;
|
||||
CvMat* _distortion_coeffs;
|
||||
CvMat* _src;
|
||||
CvMat* _dst;
|
||||
|
||||
|
||||
//C++
|
||||
cv::Mat camera_mat;
|
||||
cv::Mat new_camera_mat;
|
||||
cv::Mat distortion_coeffs;
|
||||
@ -440,20 +224,11 @@ private:
|
||||
|
||||
CV_UndistortBadArgTest::CV_UndistortBadArgTest ()
|
||||
{
|
||||
useCPlus = false;
|
||||
_camera_mat = _new_camera_mat = _distortion_coeffs = _src = _dst = NULL;
|
||||
}
|
||||
|
||||
void CV_UndistortBadArgTest::run_func()
|
||||
{
|
||||
if (useCPlus)
|
||||
{
|
||||
cv::undistort(src,dst,camera_mat,distortion_coeffs,new_camera_mat);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvUndistort2(_src,_dst,_camera_mat,_distortion_coeffs,_new_camera_mat);
|
||||
}
|
||||
cv::undistort(src,dst,camera_mat,distortion_coeffs,new_camera_mat);
|
||||
}
|
||||
|
||||
void CV_UndistortBadArgTest::run(int)
|
||||
@ -464,52 +239,15 @@ void CV_UndistortBadArgTest::run(int)
|
||||
img_size.height = 600;
|
||||
double cam[9] = {150.f, 0.f, img_size.width/2.f, 0, 300.f, img_size.height/2.f, 0.f, 0.f, 1.f};
|
||||
double dist[4] = {0.01,0.02,0.001,0.0005};
|
||||
float* arr_src = new float[img_size.width*img_size.height];
|
||||
float* arr_dst = new float[img_size.width*img_size.height];
|
||||
std::vector<float> arr_src(img_size.width*img_size.height);
|
||||
std::vector<float> arr_dst(img_size.width*img_size.height);
|
||||
double arr_new_camera_mat[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f};
|
||||
|
||||
CvMat _camera_mat_orig = cvMat(3,3,CV_64F,cam);
|
||||
CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64F,dist);
|
||||
CvMat _new_camera_mat_orig = cvMat(3,3,CV_64F,arr_new_camera_mat);
|
||||
CvMat _src_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_src);
|
||||
CvMat _dst_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_dst);
|
||||
|
||||
_camera_mat = &_camera_mat_orig;
|
||||
_distortion_coeffs = &_distortion_coeffs_orig;
|
||||
_new_camera_mat = &_new_camera_mat_orig;
|
||||
_src = &_src_orig;
|
||||
_dst = &_dst_orig;
|
||||
|
||||
//tests
|
||||
useCPlus = true;
|
||||
CvMat* temp;
|
||||
CvMat* temp1;
|
||||
|
||||
//C tests
|
||||
useCPlus = false;
|
||||
|
||||
temp = cvCreateMat(800,600,CV_32F);
|
||||
temp1 = cvCreateMat(800,601,CV_32F);
|
||||
_src = temp;
|
||||
_dst = temp1;
|
||||
errcount += run_test_case( CV_StsAssert, "Input and output data matrix sizes mismatch" );
|
||||
_src = &_src_orig;
|
||||
_dst = &_dst_orig;
|
||||
cvReleaseMat(&temp);
|
||||
cvReleaseMat(&temp1);
|
||||
|
||||
temp = cvCreateMat(800,600,CV_32F);
|
||||
temp1 = cvCreateMat(800,600,CV_64F);
|
||||
_src = temp;
|
||||
_dst = temp1;
|
||||
errcount += run_test_case( CV_StsAssert, "Input and output data matrix types mismatch" );
|
||||
_src = &_src_orig;
|
||||
_dst = &_dst_orig;
|
||||
cvReleaseMat(&temp);
|
||||
cvReleaseMat(&temp1);
|
||||
|
||||
//C++ tests
|
||||
useCPlus = true;
|
||||
CvMat _src_orig = cvMat(img_size.height,img_size.width,CV_32FC1,&arr_src[0]);
|
||||
CvMat _dst_orig = cvMat(img_size.height,img_size.width,CV_32FC1,&arr_dst[0]);
|
||||
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
@ -517,9 +255,10 @@ void CV_UndistortBadArgTest::run(int)
|
||||
src = cv::cvarrToMat(&_src_orig);
|
||||
dst = cv::cvarrToMat(&_dst_orig);
|
||||
|
||||
camera_mat.create(5, 5, CV_64F);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid camera data matrix size" );
|
||||
|
||||
//------------
|
||||
delete[] arr_src;
|
||||
delete[] arr_dst;
|
||||
ts->set_failed_test_info(errcount > 0 ? cvtest::TS::FAIL_BAD_ARG_CHECK : cvtest::TS::OK);
|
||||
}
|
||||
|
||||
|
@ -796,7 +796,7 @@ int CV_RemapTest::prepare_test_case( int test_case_idx )
|
||||
k[2] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
k[3] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
|
||||
cvtest::initUndistortMap( _a, _k, test_mat[INPUT][1].size(), test_mat[INPUT][1], test_mat[INPUT][2] );
|
||||
cvtest::initUndistortMap( _a, _k, Mat(), Mat(), test_mat[INPUT][1].size(), test_mat[INPUT][1], test_mat[INPUT][2], CV_32F );
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
|
@ -220,7 +220,7 @@ void copyMakeBorder(const Mat& src, Mat& dst, int top, int bottom, int left, int
|
||||
Mat calcSobelKernel2D( int dx, int dy, int apertureSize, int origin=0 );
|
||||
Mat calcLaplaceKernel2D( int aperture_size );
|
||||
|
||||
void initUndistortMap( const Mat& a, const Mat& k, Size sz, Mat& mapx, Mat& mapy );
|
||||
void initUndistortMap( const Mat& a, const Mat& k, const Mat& R, const Mat& new_a, Size sz, Mat& mapx, Mat& mapy, int map_type );
|
||||
|
||||
void minMaxLoc(const Mat& src, double* minval, double* maxval,
|
||||
vector<int>* minloc, vector<int>* maxloc, const Mat& mask=Mat());
|
||||
@ -594,7 +594,7 @@ protected:
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
thrown = true;
|
||||
if( e.code != expected_code )
|
||||
if( e.code != expected_code && e.code != cv::Error::StsAssert && e.code != cv::Error::StsError )
|
||||
{
|
||||
ts->printf(TS::LOG, "%s (test case #%d): the error code %d is different from the expected %d\n",
|
||||
descr, test_case_idx, e.code, expected_code);
|
||||
|
@ -2810,29 +2810,57 @@ Mat calcLaplaceKernel2D( int aperture_size )
|
||||
}
|
||||
|
||||
|
||||
void initUndistortMap( const Mat& _a0, const Mat& _k0, Size sz, Mat& _mapx, Mat& _mapy )
|
||||
void initUndistortMap( const Mat& _a0, const Mat& _k0, const Mat& _R0, const Mat& _new_cam0, Size sz, Mat& __mapx, Mat& __mapy, int map_type )
|
||||
{
|
||||
_mapx.create(sz, CV_32F);
|
||||
_mapy.create(sz, CV_32F);
|
||||
Mat _mapx(sz, CV_32F), _mapy(sz, CV_32F);
|
||||
|
||||
double a[9], k[5]={0,0,0,0,0};
|
||||
Mat _a(3, 3, CV_64F, a);
|
||||
double a[9], k[5]={0,0,0,0,0}, iR[9]={1, 0, 0, 0, 1, 0, 0, 0, 1}, a1[9];
|
||||
Mat _a(3, 3, CV_64F, a), _a1(3, 3, CV_64F, a1);
|
||||
Mat _k(_k0.rows,_k0.cols, CV_MAKETYPE(CV_64F,_k0.channels()),k);
|
||||
Mat _iR(3, 3, CV_64F, iR);
|
||||
double fx, fy, cx, cy, ifx, ify, cxn, cyn;
|
||||
|
||||
CV_Assert(_k0.empty() ||
|
||||
_k0.size() == Size(5, 1) ||
|
||||
_k0.size() == Size(1, 5) ||
|
||||
_k0.size() == Size(4, 1) ||
|
||||
_k0.size() == Size(1, 4));
|
||||
CV_Assert(_a0.size() == Size(3, 3));
|
||||
|
||||
_a0.convertTo(_a, CV_64F);
|
||||
_k0.convertTo(_k, CV_64F);
|
||||
if( !_k0.empty() )
|
||||
_k0.convertTo(_k, CV_64F);
|
||||
if( !_R0.empty() )
|
||||
{
|
||||
CV_Assert(_R0.size() == Size(3, 3));
|
||||
Mat tmp;
|
||||
_R0.convertTo(tmp, CV_64F);
|
||||
invert(tmp, _iR, DECOMP_LU);
|
||||
}
|
||||
if( !_new_cam0.empty() )
|
||||
{
|
||||
CV_Assert(_new_cam0.size() == Size(3, 3));
|
||||
_new_cam0.convertTo(_a1, CV_64F);
|
||||
}
|
||||
else
|
||||
_a.copyTo(_a1);
|
||||
|
||||
fx = a[0]; fy = a[4]; cx = a[2]; cy = a[5];
|
||||
ifx = 1./fx; ify = 1./fy;
|
||||
cxn = cx;
|
||||
cyn = cy;
|
||||
ifx = 1./a1[0]; ify = 1./a1[4];
|
||||
cxn = a1[2];
|
||||
cyn = a1[5];
|
||||
|
||||
for( int v = 0; v < sz.height; v++ )
|
||||
{
|
||||
for( int u = 0; u < sz.width; u++ )
|
||||
{
|
||||
double x = (u - cxn)*ifx;
|
||||
double y = (v - cyn)*ify;
|
||||
double x_ = (u - cxn)*ifx;
|
||||
double y_ = (v - cyn)*ify;
|
||||
double X = iR[0]*x_ + iR[1]*y_ + iR[2];
|
||||
double Y = iR[3]*x_ + iR[4]*y_ + iR[5];
|
||||
double Z = iR[6]*x_ + iR[7]*y_ + iR[8];
|
||||
double x = X/Z;
|
||||
double y = Y/Z;
|
||||
double x2 = x*x, y2 = y*y;
|
||||
double r2 = x2 + y2;
|
||||
double cdist = 1 + (k[0] + (k[1] + k[4]*r2)*r2)*r2;
|
||||
@ -2843,8 +2871,10 @@ void initUndistortMap( const Mat& _a0, const Mat& _k0, Size sz, Mat& _mapx, Mat&
|
||||
_mapx.at<float>(v, u) = (float)(x1*fx + cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_mapx.convertTo(__mapx, map_type);
|
||||
_mapy.convertTo(__mapy, map_type);
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream& out, const MatInfo& m)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user