未验证 提交 53b678d5 编写于 作者: A Alexander Smorkalov 提交者: GitHub

Merge pull request #23632 from asmorkalov:as/AffineFeature_mask_fix_3.4

Fixed mask handling in AffineFeature
......@@ -243,7 +243,7 @@ private:
else
mask0 = mask;
pose = Matx23f(1,0,0,
0,1,0);
0,1,0);
if( phi == 0 )
image.copyTo(rotImage);
......@@ -276,6 +276,8 @@ private:
}
if( phi != 0 || tilt != 1 )
warpAffine(mask0, warpedMask, pose, warpedImage.size(), INTER_NEAREST);
else
warpedMask = mask0;
}
......
......@@ -182,4 +182,26 @@ TEST(Features2d_AFFINE_FEATURE, regression)
#endif
}
TEST(Features2d_AFFINE_FEATURE, mask)
{
Mat gray = imread(cvtest::findDataFile("features2d/tsukuba.png"), IMREAD_GRAYSCALE);
ASSERT_FALSE(gray.empty()) << "features2d/tsukuba.png image was not found in test data!";
// small tilt range to limit internal mask warping
Ptr<AffineFeature> ext = AffineFeature::create(SIFT::create(), 1, 0);
Mat mask = Mat::zeros(gray.size(), CV_8UC1);
mask(Rect(50, 50, mask.cols-100, mask.rows-100)).setTo(255);
// calc and compare keypoints
vector<KeyPoint> calcKeypoints;
ext->detectAndCompute(gray, mask, calcKeypoints, noArray(), false);
// added expanded test range to cover sub-pixel coordinates for features on mask border
for( size_t i = 0; i < calcKeypoints.size(); i++ )
{
ASSERT_TRUE((calcKeypoints[i].pt.x >= 50-1) && (calcKeypoints[i].pt.x <= mask.cols-50+1));
ASSERT_TRUE((calcKeypoints[i].pt.y >= 50-1) && (calcKeypoints[i].pt.y <= mask.rows-50+1));
}
}
}} // namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册