mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 14:29:49 +08:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
commit
0b9d53829f
@ -833,6 +833,13 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers,
|
||||
to.convertTo(tmp2, CV_32FC2);
|
||||
to = tmp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// avoid changing of inputs in compressElems() call
|
||||
from = from.clone();
|
||||
to = to.clone();
|
||||
}
|
||||
|
||||
// convert to N x 1 vectors
|
||||
from = from.reshape(2, count);
|
||||
to = to.reshape(2, count);
|
||||
@ -900,6 +907,13 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie
|
||||
to.convertTo(tmp2, CV_32FC2);
|
||||
to = tmp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// avoid changing of inputs in compressElems() call
|
||||
from = from.clone();
|
||||
to = to.clone();
|
||||
}
|
||||
|
||||
// convert to N x 1 vectors
|
||||
from = from.reshape(2, count);
|
||||
to = to.reshape(2, count);
|
||||
|
@ -152,4 +152,46 @@ TEST_P(EstimateAffine2D, testConversion)
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3d, EstimateAffine2D, Method::all());
|
||||
|
||||
|
||||
// https://github.com/opencv/opencv/issues/14259
|
||||
TEST(EstimateAffine2D, issue_14259_dont_change_inputs)
|
||||
{
|
||||
/*const static*/ float pts0_[10] = {
|
||||
0.0f, 0.0f,
|
||||
0.0f, 8.0f,
|
||||
4.0f, 0.0f, // outlier
|
||||
8.0f, 8.0f,
|
||||
8.0f, 0.0f
|
||||
};
|
||||
/*const static*/ float pts1_[10] = {
|
||||
0.1f, 0.1f,
|
||||
0.1f, 8.1f,
|
||||
0.0f, 4.0f, // outlier
|
||||
8.1f, 8.1f,
|
||||
8.1f, 0.1f
|
||||
};
|
||||
|
||||
Mat pts0(Size(1, 5), CV_32FC2, (void*)pts0_);
|
||||
Mat pts1(Size(1, 5), CV_32FC2, (void*)pts1_);
|
||||
|
||||
Mat pts0_copy = pts0.clone();
|
||||
Mat pts1_copy = pts1.clone();
|
||||
|
||||
Mat inliers;
|
||||
|
||||
cv::Mat A = cv::estimateAffine2D(pts0, pts1, inliers);
|
||||
|
||||
for(int i = 0; i < pts0.rows; ++i)
|
||||
{
|
||||
EXPECT_EQ(pts0_copy.at<Vec2f>(i), pts0.at<Vec2f>(i)) << "pts0: i=" << i;
|
||||
}
|
||||
|
||||
for(int i = 0; i < pts1.rows; ++i)
|
||||
{
|
||||
EXPECT_EQ(pts1_copy.at<Vec2f>(i), pts1.at<Vec2f>(i)) << "pts1: i=" << i;
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, (int)inliers.at<uchar>(2));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
@ -161,4 +161,46 @@ TEST_P(EstimateAffinePartial2D, testConversion)
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3d, EstimateAffinePartial2D, Method::all());
|
||||
|
||||
|
||||
// https://github.com/opencv/opencv/issues/14259
|
||||
TEST(EstimateAffinePartial2D, issue_14259_dont_change_inputs)
|
||||
{
|
||||
/*const static*/ float pts0_[10] = {
|
||||
0.0f, 0.0f,
|
||||
0.0f, 8.0f,
|
||||
4.0f, 0.0f, // outlier
|
||||
8.0f, 8.0f,
|
||||
8.0f, 0.0f
|
||||
};
|
||||
/*const static*/ float pts1_[10] = {
|
||||
0.1f, 0.1f,
|
||||
0.1f, 8.1f,
|
||||
0.0f, 4.0f, // outlier
|
||||
8.1f, 8.1f,
|
||||
8.1f, 0.1f
|
||||
};
|
||||
|
||||
Mat pts0(Size(1, 5), CV_32FC2, (void*)pts0_);
|
||||
Mat pts1(Size(1, 5), CV_32FC2, (void*)pts1_);
|
||||
|
||||
Mat pts0_copy = pts0.clone();
|
||||
Mat pts1_copy = pts1.clone();
|
||||
|
||||
Mat inliers;
|
||||
|
||||
cv::Mat A = cv::estimateAffinePartial2D(pts0, pts1, inliers);
|
||||
|
||||
for(int i = 0; i < pts0.rows; ++i)
|
||||
{
|
||||
EXPECT_EQ(pts0_copy.at<Vec2f>(i), pts0.at<Vec2f>(i)) << "pts0: i=" << i;
|
||||
}
|
||||
|
||||
for(int i = 0; i < pts1.rows; ++i)
|
||||
{
|
||||
EXPECT_EQ(pts1_copy.at<Vec2f>(i), pts1.at<Vec2f>(i)) << "pts1: i=" << i;
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, (int)inliers.at<uchar>(2));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user