mirror of
https://github.com/opencv/opencv.git
synced 2024-12-13 16:09:23 +08:00
C-API cleanup: removed or updated some of 3d and calib tests
This commit is contained in:
parent
12738deaef
commit
e2f583a9ee
File diff suppressed because it is too large
Load Diff
@ -15,13 +15,4 @@
|
||||
#include <opencv2/core/ocl.hpp>
|
||||
#endif
|
||||
|
||||
namespace cvtest
|
||||
{
|
||||
void Rodrigues(const Mat& src, Mat& dst, Mat* jac=0);
|
||||
}
|
||||
|
||||
namespace opencv_test {
|
||||
CVTEST_GUARD_SYMBOL(Rodrigues)
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
@ -41,7 +41,6 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -84,7 +83,7 @@ void CV_DefaultNewCameraMatrixTest::get_test_array_types_and_sizes( int test_cas
|
||||
cvtest::ArrayTest::get_test_array_types_and_sizes(test_case_idx,sizes,types);
|
||||
RNG& rng = ts->get_rng();
|
||||
matrix_type = types[INPUT][0] = types[OUTPUT][0]= types[REF_OUTPUT][0] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(3,3);
|
||||
sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = Size(3,3);
|
||||
}
|
||||
|
||||
int CV_DefaultNewCameraMatrixTest::prepare_test_case(int test_case_idx)
|
||||
@ -199,8 +198,8 @@ void CV_GetOptimalNewCameraMatrixNoDistortionTest::get_test_array_types_and_size
|
||||
cvtest::ArrayTest::get_test_array_types_and_sizes(test_case_idx, sizes, types);
|
||||
RNG& rng = ts->get_rng();
|
||||
matrix_type = types[INPUT][0] = types[INPUT][1] = types[OUTPUT][0] = types[REF_OUTPUT][0] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(3,3);
|
||||
sizes[INPUT][1] = cvSize(1,4);
|
||||
sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = Size(3,3);
|
||||
sizes[INPUT][1] = Size(1,4);
|
||||
}
|
||||
|
||||
int CV_GetOptimalNewCameraMatrixNoDistortionTest::prepare_test_case(int test_case_idx)
|
||||
@ -253,846 +252,10 @@ void CV_GetOptimalNewCameraMatrixNoDistortionTest::prepare_to_validation(int /*t
|
||||
cvtest::convert(new_camera_mat, output, output.type());
|
||||
}
|
||||
|
||||
//---------
|
||||
|
||||
class CV_UndistortPointsTest : public cvtest::ArrayTest
|
||||
{
|
||||
public:
|
||||
CV_UndistortPointsTest();
|
||||
protected:
|
||||
int prepare_test_case (int test_case_idx);
|
||||
void prepare_to_validation( int test_case_idx );
|
||||
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
|
||||
double get_success_error_level( int test_case_idx, int i, int j );
|
||||
void run_func();
|
||||
void distortPoints(const CvMat* _src, CvMat* _dst, const CvMat* _cameraMatrix,
|
||||
const CvMat* _distCoeffs, const CvMat* matR, const CvMat* matP);
|
||||
|
||||
private:
|
||||
bool useDstMat;
|
||||
static const int N_POINTS = 10;
|
||||
static const int MAX_X = 2048;
|
||||
static const int MAX_Y = 2048;
|
||||
|
||||
bool zero_new_cam;
|
||||
bool zero_distortion;
|
||||
bool zero_R;
|
||||
|
||||
cv::Size img_size;
|
||||
cv::Mat dst_points_mat;
|
||||
|
||||
cv::Mat camera_mat;
|
||||
cv::Mat R;
|
||||
cv::Mat P;
|
||||
cv::Mat distortion_coeffs;
|
||||
cv::Mat src_points;
|
||||
std::vector<cv::Point2f> dst_points;
|
||||
};
|
||||
|
||||
CV_UndistortPointsTest::CV_UndistortPointsTest()
|
||||
{
|
||||
test_array[INPUT].push_back(NULL); // 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); // P matrix
|
||||
test_array[OUTPUT].push_back(NULL); // distorted dst points
|
||||
test_array[TEMP].push_back(NULL); // dst points
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
|
||||
useDstMat = false;
|
||||
zero_new_cam = zero_distortion = zero_R = false;
|
||||
}
|
||||
|
||||
void CV_UndistortPointsTest::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();
|
||||
//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;
|
||||
types[INPUT][4] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
|
||||
sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = sizes[TEMP][0]= cvtest::randInt(rng)%2 ? cvSize(1,N_POINTS) : cvSize(N_POINTS,1);
|
||||
sizes[INPUT][1] = sizes[INPUT][3] = cvSize(3,3);
|
||||
sizes[INPUT][4] = cvtest::randInt(rng)%2 ? cvSize(3,3) : cvSize(4,3);
|
||||
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(1,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(1,5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(4,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes[INPUT][2] = cvSize(5,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CV_UndistortPointsTest::prepare_test_case(int test_case_idx)
|
||||
{
|
||||
RNG& rng = ts->get_rng();
|
||||
int code = cvtest::ArrayTest::prepare_test_case( test_case_idx );
|
||||
|
||||
if (code <= 0)
|
||||
return code;
|
||||
|
||||
useDstMat = (cvtest::randInt(rng) % 2) == 0;
|
||||
|
||||
img_size.width = cvtest::randInt(rng) % MAX_X + 1;
|
||||
img_size.height = cvtest::randInt(rng) % MAX_Y + 1;
|
||||
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};
|
||||
vector<double> dist(dist_size);
|
||||
vector<double> proj(test_mat[INPUT][4].cols * test_mat[INPUT][4].rows);
|
||||
vector<Point2d> points(N_POINTS);
|
||||
|
||||
Mat _camera(3,3,CV_64F,cam);
|
||||
Mat _distort(test_mat[INPUT][2].rows,test_mat[INPUT][2].cols,CV_64F,&dist[0]);
|
||||
Mat _proj(test_mat[INPUT][4].size(), CV_64F, &proj[0]);
|
||||
Mat _points(test_mat[INPUT][0].size(), CV_64FC2, &points[0]);
|
||||
|
||||
_proj = Scalar::all(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;
|
||||
}
|
||||
|
||||
//Generating camera matrix
|
||||
double sz = MAX(img_size.width,img_size.height);
|
||||
double aspect_ratio = cvtest::randReal(rng)*0.6 + 0.7;
|
||||
cam[2] = (img_size.width - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
cam[5] = (img_size.height - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
cam[0] = sz/(0.9 - cvtest::randReal(rng)*0.6);
|
||||
cam[4] = aspect_ratio*cam[0];
|
||||
|
||||
//Generating distortion coeffs
|
||||
dist[0] = cvtest::randReal(rng)*0.06 - 0.03;
|
||||
dist[1] = cvtest::randReal(rng)*0.06 - 0.03;
|
||||
if( dist[0]*dist[1] > 0 )
|
||||
dist[1] = -dist[1];
|
||||
if( cvtest::randInt(rng)%4 != 0 )
|
||||
{
|
||||
dist[2] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
dist[3] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
if (dist_size > 4)
|
||||
dist[4] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist[2] = dist[3] = 0;
|
||||
if (dist_size > 4)
|
||||
dist[4] = 0;
|
||||
}
|
||||
|
||||
//Generating P matrix (projection)
|
||||
if( test_mat[INPUT][4].cols != 4 )
|
||||
{
|
||||
proj[8] = 1;
|
||||
if (cvtest::randInt(rng)%2 == 0) // use identity new camera matrix
|
||||
{
|
||||
proj[0] = 1;
|
||||
proj[4] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj[0] = cam[0] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[0]; //10%
|
||||
proj[4] = cam[4] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[4]; //10%
|
||||
proj[2] = cam[2] + (cvtest::randReal(rng) - (double)0.5)*0.3*img_size.width; //15%
|
||||
proj[5] = cam[5] + (cvtest::randReal(rng) - (double)0.5)*0.3*img_size.height; //15%
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
proj[10] = 1;
|
||||
proj[0] = cam[0] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[0]; //10%
|
||||
proj[5] = cam[4] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[4]; //10%
|
||||
proj[2] = cam[2] + (cvtest::randReal(rng) - (double)0.5)*0.3*img_size.width; //15%
|
||||
proj[6] = cam[5] + (cvtest::randReal(rng) - (double)0.5)*0.3*img_size.height; //15%
|
||||
|
||||
proj[3] = (img_size.height + img_size.width - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
proj[7] = (img_size.height + img_size.width - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
proj[11] = (img_size.height + img_size.width - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
}
|
||||
|
||||
//Generating R matrix
|
||||
Mat _rot(3,3,CV_64F);
|
||||
Mat rotation(1,3,CV_64F);
|
||||
rotation.at<double>(0) = CV_PI*(cvtest::randReal(rng) - (double)0.5); // phi
|
||||
rotation.at<double>(1) = CV_PI*(cvtest::randReal(rng) - (double)0.5); // ksi
|
||||
rotation.at<double>(2) = CV_PI*(cvtest::randReal(rng) - (double)0.5); //khi
|
||||
cvtest::Rodrigues(rotation, _rot);
|
||||
|
||||
//copying data
|
||||
//src_points = &_points;
|
||||
_points.convertTo(test_mat[INPUT][0], test_mat[INPUT][0].type());
|
||||
_camera.convertTo(test_mat[INPUT][1], test_mat[INPUT][1].type());
|
||||
_distort.convertTo(test_mat[INPUT][2], test_mat[INPUT][2].type());
|
||||
_rot.convertTo(test_mat[INPUT][3], test_mat[INPUT][3].type());
|
||||
_proj.convertTo(test_mat[INPUT][4], test_mat[INPUT][4].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;
|
||||
|
||||
_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];
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void CV_UndistortPointsTest::prepare_to_validation(int /*test_case_idx*/)
|
||||
{
|
||||
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* proj = 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 _proj = cvMat(test_mat[INPUT][4].rows,test_mat[INPUT][4].cols,CV_64F,proj);
|
||||
CvMat _points= cvMat(test_mat[TEMP][0].rows,test_mat[TEMP][0].cols,CV_64FC2,points);
|
||||
|
||||
Mat __camera = cvarrToMat(&_camera);
|
||||
Mat __distort = cvarrToMat(&_distort);
|
||||
Mat __rot = cvarrToMat(&_rot);
|
||||
Mat __proj = cvarrToMat(&_proj);
|
||||
Mat __points = cvarrToMat(&_points);
|
||||
Mat _ref_points = cvarrToMat(&ref_points);
|
||||
|
||||
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], __proj, __proj.type());
|
||||
|
||||
if (useDstMat)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
CvMat* input2 = zero_distortion ? 0 : &_distort;
|
||||
CvMat* input3 = zero_R ? 0 : &_rot;
|
||||
CvMat* input4 = zero_new_cam ? 0 : &_proj;
|
||||
distortPoints(&_points,&ref_points,&_camera,input2,input3,input4);
|
||||
|
||||
Mat& dst = test_mat[REF_OUTPUT][0];
|
||||
cvtest::convert(_ref_points, dst, dst.type());
|
||||
|
||||
cvtest::copy(test_mat[INPUT][0], test_mat[OUTPUT][0]);
|
||||
|
||||
delete[] dist;
|
||||
delete[] proj;
|
||||
delete[] points;
|
||||
delete[] r_points;
|
||||
}
|
||||
|
||||
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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
void CV_UndistortPointsTest::distortPoints(const CvMat* _src, CvMat* _dst, const CvMat* _cameraMatrix,
|
||||
const CvMat* _distCoeffs,
|
||||
const CvMat* matR, const CvMat* matP)
|
||||
{
|
||||
double a[9];
|
||||
|
||||
CvMat* __P;
|
||||
if ((!matP)||(matP->cols == 3))
|
||||
__P = cvCreateMat(3,3,CV_64F);
|
||||
else
|
||||
__P = cvCreateMat(3,4,CV_64F);
|
||||
if (matP)
|
||||
{
|
||||
cvtest::convert(cvarrToMat(matP), cvarrToMat(__P), -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvZero(__P);
|
||||
__P->data.db[0] = 1;
|
||||
__P->data.db[4] = 1;
|
||||
__P->data.db[8] = 1;
|
||||
}
|
||||
CvMat* __R = cvCreateMat(3,3,CV_64F);
|
||||
if (matR)
|
||||
{
|
||||
cvCopy(matR,__R);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvZero(__R);
|
||||
__R->data.db[0] = 1;
|
||||
__R->data.db[4] = 1;
|
||||
__R->data.db[8] = 1;
|
||||
}
|
||||
for (int i=0;i<N_POINTS;i++)
|
||||
{
|
||||
int movement = __P->cols > 3 ? 1 : 0;
|
||||
double x = (_src->data.db[2*i]-__P->data.db[2])/__P->data.db[0];
|
||||
double y = (_src->data.db[2*i+1]-__P->data.db[5+movement])/__P->data.db[4+movement];
|
||||
CvMat inverse = cvMat(3,3,CV_64F,a);
|
||||
cvInvert(__R,&inverse);
|
||||
double w1 = x*inverse.data.db[6]+y*inverse.data.db[7]+inverse.data.db[8];
|
||||
double _x = (x*inverse.data.db[0]+y*inverse.data.db[1]+inverse.data.db[2])/w1;
|
||||
double _y = (x*inverse.data.db[3]+y*inverse.data.db[4]+inverse.data.db[5])/w1;
|
||||
|
||||
//Distortions
|
||||
|
||||
double __x = _x;
|
||||
double __y = _y;
|
||||
if (_distCoeffs)
|
||||
{
|
||||
double r2 = _x*_x+_y*_y;
|
||||
|
||||
__x = _x*(1+_distCoeffs->data.db[0]*r2+_distCoeffs->data.db[1]*r2*r2)+
|
||||
2*_distCoeffs->data.db[2]*_x*_y+_distCoeffs->data.db[3]*(r2+2*_x*_x);
|
||||
__y = _y*(1+_distCoeffs->data.db[0]*r2+_distCoeffs->data.db[1]*r2*r2)+
|
||||
2*_distCoeffs->data.db[3]*_x*_y+_distCoeffs->data.db[2]*(r2+2*_y*_y);
|
||||
if ((_distCoeffs->cols > 4) || (_distCoeffs->rows > 4))
|
||||
{
|
||||
__x+=_x*_distCoeffs->data.db[4]*r2*r2*r2;
|
||||
__y+=_y*_distCoeffs->data.db[4]*r2*r2*r2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_dst->data.db[2*i] = __x*_cameraMatrix->data.db[0]+_cameraMatrix->data.db[2];
|
||||
_dst->data.db[2*i+1] = __y*_cameraMatrix->data.db[4]+_cameraMatrix->data.db[5];
|
||||
|
||||
}
|
||||
|
||||
cvReleaseMat(&__R);
|
||||
cvReleaseMat(&__P);
|
||||
|
||||
}
|
||||
|
||||
|
||||
double CV_UndistortPointsTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ )
|
||||
{
|
||||
return 5e-2;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
class CV_InitUndistortRectifyMapTest : public cvtest::ArrayTest
|
||||
{
|
||||
public:
|
||||
CV_InitUndistortRectifyMapTest();
|
||||
protected:
|
||||
int prepare_test_case (int test_case_idx);
|
||||
void prepare_to_validation( int test_case_idx );
|
||||
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
|
||||
double get_success_error_level( int test_case_idx, int i, int j );
|
||||
void run_func();
|
||||
|
||||
private:
|
||||
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;
|
||||
int map_type;
|
||||
};
|
||||
|
||||
CV_InitUndistortRectifyMapTest::CV_InitUndistortRectifyMapTest()
|
||||
{
|
||||
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 mapx
|
||||
test_array[OUTPUT].push_back(NULL); // distorted mapy
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
|
||||
zero_distortion = zero_new_cam = zero_R = false;
|
||||
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();
|
||||
//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;
|
||||
|
||||
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)
|
||||
{
|
||||
dsize = Size(1,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
dsize = Size(1,5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
dsize = Size(4,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
dsize = Size(5,1);
|
||||
}
|
||||
}
|
||||
sizes[INPUT][1] = dsize;
|
||||
}
|
||||
|
||||
|
||||
int CV_InitUndistortRectifyMapTest::prepare_test_case(int test_case_idx)
|
||||
{
|
||||
RNG& rng = ts->get_rng();
|
||||
int code = cvtest::ArrayTest::prepare_test_case( test_case_idx );
|
||||
|
||||
if (code <= 0)
|
||||
return code;
|
||||
|
||||
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][3].cols * test_mat[INPUT][3].rows);
|
||||
|
||||
Mat _camera(3,3,CV_64F,cam);
|
||||
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);
|
||||
double aspect_ratio = cvtest::randReal(rng)*0.6 + 0.7;
|
||||
cam[2] = (img_size.width - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
cam[5] = (img_size.height - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
cam[0] = sz/(0.9 - cvtest::randReal(rng)*0.6);
|
||||
cam[4] = aspect_ratio*cam[0];
|
||||
|
||||
//Generating distortion coeffs
|
||||
dist[0] = cvtest::randReal(rng)*0.06 - 0.03;
|
||||
dist[1] = cvtest::randReal(rng)*0.06 - 0.03;
|
||||
if( dist[0]*dist[1] > 0 )
|
||||
dist[1] = -dist[1];
|
||||
if( cvtest::randInt(rng)%4 != 0 )
|
||||
{
|
||||
dist[2] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
dist[3] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
if (dist_size > 4)
|
||||
dist[4] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist[2] = dist[3] = 0;
|
||||
if (dist_size > 4)
|
||||
dist[4] = 0;
|
||||
}
|
||||
|
||||
//Generating new camera matrix
|
||||
_new_cam = Scalar::all(0);
|
||||
new_cam[8] = 1;
|
||||
|
||||
//new_cam[0] = cam[0];
|
||||
//new_cam[4] = cam[4];
|
||||
//new_cam[2] = cam[2];
|
||||
//new_cam[5] = cam[5];
|
||||
|
||||
new_cam[0] = cam[0] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[0]; //10%
|
||||
new_cam[4] = cam[4] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[4]; //10%
|
||||
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);
|
||||
rotation.at<double>(0) = CV_PI/8*(cvtest::randReal(rng) - (double)0.5); // phi
|
||||
rotation.at<double>(1) = CV_PI/8*(cvtest::randReal(rng) - (double)0.5); // ksi
|
||||
rotation.at<double>(2) = CV_PI/3*(cvtest::randReal(rng) - (double)0.5); //khi
|
||||
cvtest::Rodrigues(rotation, _rot);
|
||||
|
||||
//cvSetIdentity(_rot);
|
||||
//copying data
|
||||
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;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/)
|
||||
{
|
||||
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()
|
||||
{
|
||||
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];
|
||||
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*/ )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
class CV_InitInverseRectificationMapTest : public cvtest::ArrayTest
|
||||
{
|
||||
public:
|
||||
CV_InitInverseRectificationMapTest();
|
||||
protected:
|
||||
int prepare_test_case (int test_case_idx);
|
||||
void prepare_to_validation( int test_case_idx );
|
||||
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
|
||||
double get_success_error_level( int test_case_idx, int i, int j );
|
||||
void run_func();
|
||||
|
||||
private:
|
||||
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;
|
||||
int map_type;
|
||||
};
|
||||
|
||||
CV_InitInverseRectificationMapTest::CV_InitInverseRectificationMapTest()
|
||||
{
|
||||
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); // inverse rectified mapx
|
||||
test_array[OUTPUT].push_back(NULL); // inverse rectified mapy
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
|
||||
zero_distortion = zero_new_cam = zero_R = false;
|
||||
map_type = 0;
|
||||
}
|
||||
|
||||
void CV_InitInverseRectificationMapTest::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();
|
||||
//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;
|
||||
|
||||
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)
|
||||
{
|
||||
dsize = Size(1,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
dsize = Size(1,5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cvtest::randInt(rng)%2)
|
||||
{
|
||||
dsize = Size(4,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
dsize = Size(5,1);
|
||||
}
|
||||
}
|
||||
sizes[INPUT][1] = dsize;
|
||||
}
|
||||
|
||||
|
||||
int CV_InitInverseRectificationMapTest::prepare_test_case(int test_case_idx)
|
||||
{
|
||||
RNG& rng = ts->get_rng();
|
||||
int code = cvtest::ArrayTest::prepare_test_case( test_case_idx );
|
||||
|
||||
if (code <= 0)
|
||||
return code;
|
||||
|
||||
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][3].cols * test_mat[INPUT][3].rows);
|
||||
|
||||
Mat _camera(3,3,CV_64F,cam);
|
||||
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);
|
||||
double aspect_ratio = cvtest::randReal(rng)*0.6 + 0.7;
|
||||
cam[2] = (img_size.width - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
cam[5] = (img_size.height - 1)*0.5 + cvtest::randReal(rng)*10 - 5;
|
||||
cam[0] = sz/(0.9 - cvtest::randReal(rng)*0.6);
|
||||
cam[4] = aspect_ratio*cam[0];
|
||||
|
||||
//Generating distortion coeffs
|
||||
dist[0] = cvtest::randReal(rng)*0.06 - 0.03;
|
||||
dist[1] = cvtest::randReal(rng)*0.06 - 0.03;
|
||||
if( dist[0]*dist[1] > 0 )
|
||||
dist[1] = -dist[1];
|
||||
if( cvtest::randInt(rng)%4 != 0 )
|
||||
{
|
||||
dist[2] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
dist[3] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
if (dist_size > 4)
|
||||
dist[4] = cvtest::randReal(rng)*0.004 - 0.002;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist[2] = dist[3] = 0;
|
||||
if (dist_size > 4)
|
||||
dist[4] = 0;
|
||||
}
|
||||
|
||||
//Generating new camera matrix
|
||||
_new_cam = Scalar::all(0);
|
||||
new_cam[8] = 1;
|
||||
|
||||
// If P == K
|
||||
//new_cam[0] = cam[0];
|
||||
//new_cam[4] = cam[4];
|
||||
//new_cam[2] = cam[2];
|
||||
//new_cam[5] = cam[5];
|
||||
|
||||
// If P != K
|
||||
new_cam[0] = cam[0] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[0]; //10%
|
||||
new_cam[4] = cam[4] + (cvtest::randReal(rng) - (double)0.5)*0.2*cam[4]; //10%
|
||||
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);
|
||||
rotation.at<double>(0) = CV_PI/8*(cvtest::randReal(rng) - (double)0.5); // phi
|
||||
rotation.at<double>(1) = CV_PI/8*(cvtest::randReal(rng) - (double)0.5); // ksi
|
||||
rotation.at<double>(2) = CV_PI/3*(cvtest::randReal(rng) - (double)0.5); //khi
|
||||
cvtest::Rodrigues(rotation, _rot);
|
||||
|
||||
//cvSetIdentity(_rot);
|
||||
//copying data
|
||||
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;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void CV_InitInverseRectificationMapTest::prepare_to_validation(int/* test_case_idx*/)
|
||||
{
|
||||
// Configure Parameters
|
||||
Mat _a0 = test_mat[INPUT][0];
|
||||
Mat _d0 = zero_distortion ? cv::Mat() : test_mat[INPUT][1];
|
||||
Mat _R0 = zero_R ? cv::Mat() : test_mat[INPUT][2];
|
||||
Mat _new_cam0 = zero_new_cam ? test_mat[INPUT][0] : test_mat[INPUT][3];
|
||||
Mat _mapx(img_size, CV_32F), _mapy(img_size, CV_32F);
|
||||
|
||||
double a[9], d[5]={0., 0., 0., 0. , 0.}, R[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 _d(_d0.rows,_d0.cols, CV_MAKETYPE(CV_64F,_d0.channels()),d);
|
||||
Mat _R(3, 3, CV_64F, R);
|
||||
double fx, fy, cx, cy, ifx, ify, cxn, cyn;
|
||||
|
||||
// Camera matrix
|
||||
CV_Assert(_a0.size() == Size(3, 3));
|
||||
_a0.convertTo(_a, CV_64F);
|
||||
if( !_new_cam0.empty() )
|
||||
{
|
||||
CV_Assert(_new_cam0.size() == Size(3, 3));
|
||||
_new_cam0.convertTo(_a1, CV_64F);
|
||||
}
|
||||
else
|
||||
{
|
||||
_a.copyTo(_a1);
|
||||
}
|
||||
|
||||
// Distortion
|
||||
CV_Assert(_d0.empty() ||
|
||||
_d0.size() == Size(5, 1) ||
|
||||
_d0.size() == Size(1, 5) ||
|
||||
_d0.size() == Size(4, 1) ||
|
||||
_d0.size() == Size(1, 4));
|
||||
if( !_d0.empty() )
|
||||
_d0.convertTo(_d, CV_64F);
|
||||
|
||||
// Rotation
|
||||
if( !_R0.empty() )
|
||||
{
|
||||
CV_Assert(_R0.size() == Size(3, 3));
|
||||
Mat tmp;
|
||||
_R0.convertTo(_R, CV_64F);
|
||||
}
|
||||
|
||||
// Copy camera matrix
|
||||
fx = a[0]; fy = a[4]; cx = a[2]; cy = a[5];
|
||||
|
||||
// Copy new camera matrix
|
||||
ifx = a1[0]; ify = a1[4]; cxn = a1[2]; cyn = a1[5];
|
||||
|
||||
// Undistort
|
||||
for( int v = 0; v < img_size.height; v++ )
|
||||
{
|
||||
for( int u = 0; u < img_size.width; u++ )
|
||||
{
|
||||
// Convert from image to pin-hole coordinates
|
||||
double x = (u - cx)/fx;
|
||||
double y = (v - cy)/fy;
|
||||
|
||||
// Undistort
|
||||
double x2 = x*x, y2 = y*y;
|
||||
double r2 = x2 + y2;
|
||||
double cdist = 1./(1. + (d[0] + (d[1] + d[4]*r2)*r2)*r2); // (1. + (d[5] + (d[6] + d[7]*r2)*r2)*r2) == 1 as d[5-7]=0;
|
||||
double x_ = (x - (d[2]*2.*x*y + d[3]*(r2 + 2.*x2)))*cdist;
|
||||
double y_ = (y - (d[3]*2.*x*y + d[2]*(r2 + 2.*y2)))*cdist;
|
||||
|
||||
// Rectify
|
||||
double X = R[0]*x_ + R[1]*y_ + R[2];
|
||||
double Y = R[3]*x_ + R[4]*y_ + R[5];
|
||||
double Z = R[6]*x_ + R[7]*y_ + R[8];
|
||||
double x__ = X/Z;
|
||||
double y__ = Y/Z;
|
||||
|
||||
// Convert from pin-hole to image coordinates
|
||||
_mapy.at<float>(v, u) = (float)(y__*ify + cyn);
|
||||
_mapx.at<float>(v, u) = (float)(x__*ifx + cxn);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert
|
||||
_mapx.convertTo(test_mat[REF_OUTPUT][0], test_mat[REF_OUTPUT][0].type());
|
||||
_mapy.convertTo(test_mat[REF_OUTPUT][1], test_mat[REF_OUTPUT][0].type());
|
||||
}
|
||||
|
||||
void CV_InitInverseRectificationMapTest::run_func()
|
||||
{
|
||||
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::initInverseRectificationMap(camera_mat,dist,R,new_cam,img_size,map_type,mapx,mapy);
|
||||
}
|
||||
|
||||
double CV_InitInverseRectificationMapTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST(Calib3d_DefaultNewCameraMatrix, accuracy) { CV_DefaultNewCameraMatrixTest test; test.safe_run(); }
|
||||
TEST(Calib3d_GetOptimalNewCameraMatrixNoDistortion, accuracy) { CV_GetOptimalNewCameraMatrixNoDistortionTest test; test.safe_run(); }
|
||||
TEST(Calib3d_UndistortPoints, accuracy) { CV_UndistortPointsTest test; test.safe_run(); }
|
||||
TEST(Calib3d_InitUndistortRectifyMap, accuracy) { CV_InitUndistortRectifyMapTest test; test.safe_run(); }
|
||||
TEST(DISABLED_Calib3d_InitInverseRectificationMap, accuracy) { CV_InitInverseRectificationMapTest test; test.safe_run(); }
|
||||
|
||||
////////////////////////////// undistort /////////////////////////////////
|
||||
|
||||
@ -1413,8 +576,8 @@ void CV_UndistortTest::get_test_array_types_and_sizes( int test_case_idx, vector
|
||||
types[INPUT][0] = types[INPUT_OUTPUT][0] = types[REF_INPUT_OUTPUT][0] = type;
|
||||
types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
|
||||
sizes[INPUT][1] = cvSize(3,3);
|
||||
sizes[INPUT][2] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4);
|
||||
sizes[INPUT][1] = Size(3,3);
|
||||
sizes[INPUT][2] = cvtest::randInt(rng)%2 ? Size(4,1) : Size(1,4);
|
||||
types[INPUT][3] = types[INPUT][1];
|
||||
sizes[INPUT][3] = sizes[INPUT][1];
|
||||
interpolation = cv::INTER_LINEAR;
|
||||
@ -1568,8 +731,8 @@ void CV_UndistortMapTest::get_test_array_types_and_sizes( int test_case_idx, vec
|
||||
dualChannel = cvtest::randInt(rng)%2 == 0;
|
||||
types[OUTPUT][0] = types[OUTPUT][1] =
|
||||
types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = dualChannel ? CV_32FC2 : CV_32F;
|
||||
sizes[INPUT][0] = cvSize(3,3);
|
||||
sizes[INPUT][1] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4);
|
||||
sizes[INPUT][0] = Size(3,3);
|
||||
sizes[INPUT][1] = cvtest::randInt(rng)%2 ? Size(4,1) : Size(1,4);
|
||||
|
||||
sz.width = MAX(sz.width,16);
|
||||
sz.height = MAX(sz.height,16);
|
||||
|
@ -40,7 +40,6 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -93,29 +92,22 @@ void CV_UndistortPointsBadArgTest::run(int)
|
||||
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};
|
||||
|
||||
CvMat _camera_mat_orig = cvMat(3,3,CV_64F,cam);
|
||||
CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64F,dist);
|
||||
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);
|
||||
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
P = cv::cvarrToMat(&_P_orig);
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
camera_mat = Mat(3,3,CV_64F,cam);
|
||||
distortion_coeffs = Mat(1,4,CV_64F,dist);
|
||||
P = Mat(3,3,CV_64F,p);
|
||||
R = Mat(3,3,CV_64F,r);
|
||||
|
||||
src_points.create(2, 2, CV_32FC2);
|
||||
errcount += run_test_case( cv::Error::StsAssert, "Invalid input data matrix size" );
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
src_points = Mat(1,4,CV_64FC2,s_points);
|
||||
|
||||
src_points.create(1, 4, CV_64FC2);
|
||||
errcount += run_test_case( cv::Error::StsAssert, "Invalid input data matrix type" );
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
src_points = Mat(1,4,CV_64FC2,s_points);
|
||||
|
||||
src_points = cv::Mat();
|
||||
errcount += run_test_case( cv::Error::StsBadArg, "Input data matrix is not continuous" );
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
src_points = Mat(1,4,CV_64FC2,s_points);
|
||||
|
||||
//------------
|
||||
ts->set_failed_test_info(errcount > 0 ? cvtest::TS::FAIL_BAD_ARG_CHECK : cvtest::TS::OK);
|
||||
@ -165,20 +157,14 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
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};
|
||||
|
||||
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 _R_orig = cvMat(3,3,CV_64F,r);
|
||||
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 = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
new_camera_mat = cv::cvarrToMat(&_new_camera_mat_orig);
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
mapx = cv::cvarrToMat(&_mapx_orig);
|
||||
mapy = cv::cvarrToMat(&_mapy_orig);
|
||||
camera_mat = Mat(3,3,CV_64F,cam);
|
||||
distortion_coeffs = Mat(1,4,CV_64F,dist);
|
||||
new_camera_mat = Mat(3,3,CV_64F,arr_new_camera_mat);
|
||||
R = Mat(3,3,CV_64F,r);
|
||||
mapx = Mat(img_size.height,img_size.width,CV_32FC1,&arr_mapx[0]);
|
||||
mapy = Mat(img_size.height,img_size.width,CV_32FC1,&arr_mapy[0]);
|
||||
|
||||
mat_type = CV_64F;
|
||||
errcount += run_test_case( cv::Error::StsAssert, "Invalid map matrix type" );
|
||||
@ -186,15 +172,15 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
|
||||
camera_mat.create(3, 2, CV_32F);
|
||||
errcount += run_test_case( cv::Error::StsAssert, "Invalid camera data matrix size" );
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
camera_mat = Mat(3,3,CV_64F,cam);
|
||||
|
||||
R.create(4, 3, CV_32F);
|
||||
errcount += run_test_case( cv::Error::StsAssert, "Invalid R data matrix size" );
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
R = Mat(3,3,CV_64F,r);
|
||||
|
||||
distortion_coeffs.create(6, 1, CV_32F);
|
||||
errcount += run_test_case( cv::Error::StsAssert, "Invalid distortion coefficients data matrix size" );
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
distortion_coeffs = Mat(1,4,CV_64F,dist);
|
||||
|
||||
//------------
|
||||
ts->set_failed_test_info(errcount > 0 ? cvtest::TS::FAIL_BAD_ARG_CHECK : cvtest::TS::OK);
|
||||
@ -243,17 +229,11 @@ void CV_UndistortBadArgTest::run(int)
|
||||
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[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);
|
||||
new_camera_mat = cv::cvarrToMat(&_new_camera_mat_orig);
|
||||
src = cv::cvarrToMat(&_src_orig);
|
||||
dst = cv::cvarrToMat(&_dst_orig);
|
||||
camera_mat = Mat(3,3,CV_64F,cam);
|
||||
distortion_coeffs = Mat(1,4,CV_64F,dist);
|
||||
new_camera_mat = Mat(3,3,CV_64F,arr_new_camera_mat);
|
||||
src = Mat(img_size.height,img_size.width,CV_32FC1,&arr_src[0]);
|
||||
dst = Mat(img_size.height,img_size.width,CV_32FC1,&arr_dst[0]);
|
||||
|
||||
camera_mat.create(5, 5, CV_64F);
|
||||
errcount += run_test_case( cv::Error::StsAssert, "Invalid camera data matrix size" );
|
||||
|
@ -41,7 +41,6 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_chessboardgenerator.hpp"
|
||||
#include "opencv2/core/types_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user