Skip to content

Commit 37d9339

Browse files
committed
Merge pull request #1888 from alalek:fix_surf_mask_keypoints_3.4
2 parents 25ded91 + 6132943 commit 37d9339

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

modules/xfeatures2d/src/surf.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,19 @@ void SURF_Impl::detectAndCompute(InputArray _img, InputArray _mask,
944944
integral(mask1, msum, CV_32S);
945945
}
946946
fastHessianDetector( sum, msum, keypoints, nOctaves, nOctaveLayers, (float)hessianThreshold );
947+
if (!mask.empty())
948+
{
949+
for (size_t i = 0; i < keypoints.size(); )
950+
{
951+
Point pt(keypoints[i].pt);
952+
if (mask.at<uchar>(pt.y, pt.x) == 0)
953+
{
954+
keypoints.erase(keypoints.begin() + i);
955+
continue; // keep "i"
956+
}
957+
i++;
958+
}
959+
}
947960
}
948961

949962
int i, j, N = (int)keypoints.size();

0 commit comments

Comments
 (0)