mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
fixed cvComputeCorrespondEpilines to handle <5 points (ticket #1635)
This commit is contained in:
parent
7eab7c197d
commit
aed276e67d
@ -680,7 +680,13 @@ CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
|
||||
if( (depth != CV_32F && depth != CV_64F) || (cn != 1 && cn != 2 && cn != 3) )
|
||||
CV_Error( CV_StsUnsupportedFormat, "The format of point matrix is unsupported" );
|
||||
|
||||
if( points->rows > points->cols )
|
||||
if( cn > 1 )
|
||||
{
|
||||
dims = cn;
|
||||
CV_Assert( points->rows == 1 || points->cols == 1 );
|
||||
count = points->rows * points->cols;
|
||||
}
|
||||
else if( points->rows > points->cols )
|
||||
{
|
||||
dims = cn*points->cols;
|
||||
count = points->rows;
|
||||
@ -689,7 +695,7 @@ CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
|
||||
{
|
||||
if( (points->rows > 1 && cn > 1) || (points->rows == 1 && cn == 1) )
|
||||
CV_Error( CV_StsBadSize, "The point matrix does not have a proper layout (2xn, 3xn, nx2 or nx3)" );
|
||||
dims = cn * points->rows;
|
||||
dims = points->rows;
|
||||
count = points->cols;
|
||||
}
|
||||
|
||||
@ -713,7 +719,13 @@ CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
|
||||
if( (abc_depth != CV_32F && abc_depth != CV_64F) || (abc_cn != 1 && abc_cn != 3) )
|
||||
CV_Error( CV_StsUnsupportedFormat, "The format of the matrix of lines is unsupported" );
|
||||
|
||||
if( lines->rows > lines->cols )
|
||||
if( abc_cn > 1 )
|
||||
{
|
||||
abc_dims = abc_cn;
|
||||
CV_Assert( lines->rows == 1 || lines->cols == 1 );
|
||||
abc_count = lines->rows * lines->cols;
|
||||
}
|
||||
else if( lines->rows > lines->cols )
|
||||
{
|
||||
abc_dims = abc_cn*lines->cols;
|
||||
abc_count = lines->rows;
|
||||
@ -722,7 +734,7 @@ CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
|
||||
{
|
||||
if( (lines->rows > 1 && abc_cn > 1) || (lines->rows == 1 && abc_cn == 1) )
|
||||
CV_Error( CV_StsBadSize, "The lines matrix does not have a proper layout (3xn or nx3)" );
|
||||
abc_dims = abc_cn * lines->rows;
|
||||
abc_dims = lines->rows;
|
||||
abc_count = lines->cols;
|
||||
}
|
||||
|
||||
@ -735,7 +747,7 @@ CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
|
||||
elem_size = CV_ELEM_SIZE(depth);
|
||||
abc_elem_size = CV_ELEM_SIZE(abc_depth);
|
||||
|
||||
if( points->rows == dims )
|
||||
if( cn == 1 && points->rows == dims )
|
||||
{
|
||||
plane_stride = points->step;
|
||||
stride = elem_size;
|
||||
@ -746,7 +758,7 @@ CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
|
||||
stride = points->rows == 1 ? dims*elem_size : points->step;
|
||||
}
|
||||
|
||||
if( lines->rows == 3 )
|
||||
if( abc_cn == 1 && lines->rows == 3 )
|
||||
{
|
||||
abc_plane_stride = lines->step;
|
||||
abc_stride = abc_elem_size;
|
||||
|
@ -1246,23 +1246,24 @@ void CV_ComputeEpilinesTest::get_test_array_types_and_sizes( int /*test_case_idx
|
||||
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;
|
||||
double pt_count_exp = cvtest::randReal(rng)*6 + 1;
|
||||
double pt_count_exp = cvtest::randReal(rng)*6;
|
||||
|
||||
which_image = 1 + (cvtest::randInt(rng) % 2);
|
||||
|
||||
pt_count = cvRound(exp(pt_count_exp));
|
||||
pt_count = MAX( pt_count, 5 );
|
||||
pt_count = MAX( pt_count, 1 );
|
||||
bool few_points = pt_count < 5;
|
||||
|
||||
dims = 2 + (cvtest::randInt(rng) % 2);
|
||||
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, 1);
|
||||
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
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 )
|
||||
if( cvtest::randInt(rng) % 2 || few_points )
|
||||
{
|
||||
types[INPUT][0] = CV_MAKETYPE(pt_depth, dims);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
@ -1277,12 +1278,12 @@ void CV_ComputeEpilinesTest::get_test_array_types_and_sizes( int /*test_case_idx
|
||||
|
||||
types[OUTPUT][0] = CV_MAKETYPE(ln_depth, 1);
|
||||
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
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 )
|
||||
if( cvtest::randInt(rng) % 2 || few_points )
|
||||
{
|
||||
types[OUTPUT][0] = CV_MAKETYPE(ln_depth, 3);
|
||||
if( cvtest::randInt(rng) % 2 )
|
||||
@ -1354,10 +1355,10 @@ void CV_ComputeEpilinesTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
test_convertHomogeneous( lines, test_mat[REF_OUTPUT][0] );
|
||||
}
|
||||
|
||||
|
||||
TEST(Calib3d_Rodrigues, accuracy) { CV_RodriguesTest test; test.safe_run(); }
|
||||
TEST(Calib3d_FindFundamentalMat, accuracy) { CV_FundamentalMatTest test; test.safe_run(); }
|
||||
TEST(Calib3d_ConvertHomogeneoous, accuracy) { CV_ConvertHomogeneousTest test; test.safe_run(); }
|
||||
TEST(Calib3d_ComputeEpilines, accuracy) { CV_ComputeEpilinesTest test; test.safe_run(); }
|
||||
|
||||
|
||||
/* End of file. */
|
||||
|
Loading…
Reference in New Issue
Block a user