Merge pull request #7026 from sovrasov:calib_points_number

This commit is contained in:
Vadim Pisarevsky 2016-08-04 09:14:03 +00:00
commit 7eee5cb724
2 changed files with 51 additions and 3 deletions

View File

@ -1463,8 +1463,13 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA
CV_Assert(!omc.empty() && omc.type() == CV_64FC3);
CV_Assert(!Tc.empty() && Tc.type() == CV_64FC3);
Mat ex((int)(objectPoints.getMat(0).total() * objectPoints.total()), 1, CV_64FC2);
int total_ex = 0;
for (int image_idx = 0; image_idx < (int)objectPoints.total(); ++image_idx)
{
total_ex += (int)objectPoints.getMat(image_idx).total();
}
Mat ex(total_ex, 1, CV_64FC2);
int insert_idx = 0;
for (int image_idx = 0; image_idx < (int)objectPoints.total(); ++image_idx)
{
Mat image, object;
@ -1478,7 +1483,8 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA
std::vector<Point2d> x;
projectPoints(object, x, om, T, params, noArray());
Mat ex_ = (imT ? image.t() : image) - Mat(x);
ex_.copyTo(ex.rowRange(ex_.rows * image_idx, ex_.rows * (image_idx + 1)));
ex_.copyTo(ex.rowRange(insert_idx, insert_idx + ex_.rows));
insert_idx += ex_.rows;
}
meanStdDev(ex, noArray(), std_err);

View File

@ -570,6 +570,48 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
EXPECT_MAT_NEAR(theT, T_correct, 1e-10);
}
TEST_F(fisheyeTest, CalibrationWithDifferentPointsNumber)
{
const int n_images = 2;
std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
std::vector<cv::Point2d> imgPoints1(10);
std::vector<cv::Point2d> imgPoints2(15);
std::vector<cv::Point3d> objectPoints1(imgPoints1.size());
std::vector<cv::Point3d> objectPoints2(imgPoints2.size());
for (size_t i = 0; i < imgPoints1.size(); i++)
{
imgPoints1[i] = cv::Point2d((double)i, (double)i);
objectPoints1[i] = cv::Point3d((double)i, (double)i, 10.0);
}
for (size_t i = 0; i < imgPoints2.size(); i++)
{
imgPoints2[i] = cv::Point2d(i + 0.5, i + 0.5);
objectPoints2[i] = cv::Point3d(i + 0.5, i + 0.5, 10.0);
}
imagePoints[0] = imgPoints1;
imagePoints[1] = imgPoints2;
objectPoints[0] = objectPoints1;
objectPoints[1] = objectPoints2;
cv::Matx33d theK = cv::Matx33d::eye();
cv::Vec4d theD;
int flag = 0;
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
flag |= cv::fisheye::CALIB_USE_INTRINSIC_GUESS;
flag |= cv::fisheye::CALIB_FIX_SKEW;
cv::fisheye::calibrate(objectPoints, imagePoints, cv::Size(100, 100), theK, theD,
cv::noArray(), cv::noArray(), flag, cv::TermCriteria(3, 20, 1e-6));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// fisheyeTest::