Skip to content

Commit be7d394

Browse files
committed
bug in nms
1 parent 3eaef36 commit be7d394

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

examples/SuperPoint.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ std::vector<int> SuperPoint::nmsFast(const std::vector<cv::KeyPoint>& keyPoints,
2828
{
2929
static const int TO_PROCESS = 1;
3030
static const int EMPTY_OR_SUPPRESSED = 0;
31-
static const int KEPT = -1;
3231

3332
std::vector<int> sortedIndices(keyPoints.size());
3433
std::iota(sortedIndices.begin(), sortedIndices.end(), 0);
@@ -37,14 +36,14 @@ std::vector<int> SuperPoint::nmsFast(const std::vector<cv::KeyPoint>& keyPoints,
3736
std::stable_sort(sortedIndices.begin(), sortedIndices.end(),
3837
[&keyPoints](int lidx, int ridx) { return keyPoints[lidx].response > keyPoints[ridx].response; });
3938

40-
cv::Mat grid = cv::Mat(height, width, CV_8S, TO_PROCESS);
39+
cv::Mat grid = cv::Mat(height, width, CV_8U, TO_PROCESS);
4140
std::vector<int> keepIndices;
4241

4342
for (int idx : sortedIndices) {
4443
int x = keyPoints[idx].pt.x;
4544
int y = keyPoints[idx].pt.y;
4645

47-
if (grid.at<schar>(y, x) == TO_PROCESS) {
46+
if (grid.at<uchar>(y, x) == TO_PROCESS) {
4847
for (int i = y - distThresh; i < y + distThresh; ++i) {
4948
if (i < 0 || i >= height) {
5049
continue;
@@ -54,11 +53,9 @@ std::vector<int> SuperPoint::nmsFast(const std::vector<cv::KeyPoint>& keyPoints,
5453
if (j < 0 || j >= width) {
5554
continue;
5655
}
57-
grid.at<int>(i, j) = EMPTY_OR_SUPPRESSED;
56+
grid.at<uchar>(i, j) = EMPTY_OR_SUPPRESSED;
5857
}
5958
}
60-
61-
grid.at<int>(y, x) = KEPT;
6259
keepIndices.emplace_back(idx);
6360
}
6461
}

0 commit comments

Comments
 (0)