Skip to content

Commit 3854fd3

Browse files
janherlingmetafacebook-github-bot
authored andcommitted
Added new function to NonMaximumSupression
Summary: The new function allows to return all candidates which have been collected in the object. Reviewed By: enpe Differential Revision: D78099129 Privacy Context Container: L1191897 fbshipit-source-id: 69a4b1cfdd11a2b89c267e157fcf16d8592803d0
1 parent da61696 commit 3854fd3

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

impl/ocean/cv/NonMaximumSuppression.h

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ class NonMaximumSuppression
150150
/**
151151
* Definition of a vector holding strength candidate objects.
152152
*/
153-
typedef std::vector<StrengthCandidate> StrengthCandidateRow;
153+
using StrengthCandidateRow = std::vector<StrengthCandidate>;
154154

155155
/**
156156
* Definition of a vector holding a vector of strength candidates.
157157
*/
158-
typedef ShiftVector<StrengthCandidateRow> StrengthCandidateRows;
158+
using StrengthCandidateRows = ShiftVector<StrengthCandidateRow>;
159159

160160
public:
161161

@@ -246,6 +246,17 @@ class NonMaximumSuppression
246246
template <typename TCoordinate, typename TStrength, bool tStrictMaximum = true>
247247
StrengthPositions<TCoordinate, TStrength> suppressNonMaximum(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows, Worker* worker = nullptr, const PositionCallback<TCoordinate, TStrength>* positionCallback = nullptr) const;
248248

249+
/**
250+
* Returns all gathered candidates of this object.
251+
* The resulting candidates are raw candidates without any suppression.
252+
* @param firstColumn The first column from which candidates will be returned, with range [0, width() - 1]
253+
* @param numberColumns The number of columns for which candidates will be returned, with range [1, width() - firstColumn]
254+
* @param firstRow The first row from which candidates will be returned, with range [yOffset(), height() - 1]
255+
* @param numberRows The number of rows for which candidates will be returned, with range [1, height() - firstRow]
256+
* @param strengthPositions The resulting strength positions
257+
*/
258+
void candidates(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows, StrengthPositions<unsigned int, T>& strengthPositions);
259+
249260
/**
250261
* Removes the gathered non-maximum suppression information so that this object can be reused again (for the same task with same resolution etc.).
251262
* The allocated memory will remain so that reusing this object may improve performance.
@@ -526,6 +537,35 @@ typename NonMaximumSuppression<T>::template StrengthPositions<TCoordinate, TStre
526537
return result;
527538
}
528539

540+
template <typename T>
541+
void NonMaximumSuppression<T>::candidates(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows, NonMaximumSuppression<T>::StrengthPositions<unsigned int, T>& strengthPositions)
542+
{
543+
ocean_assert(firstColumn + numberColumns <= width_);
544+
ocean_assert(firstRow + numberRows <= (unsigned int)(rows_.endIndex()));
545+
546+
const unsigned int endColumn = firstColumn + numberColumns;
547+
548+
for (unsigned int y = firstRow; y < firstRow + numberRows; ++y)
549+
{
550+
const StrengthCandidateRow& row = rows_[y];
551+
552+
for (const StrengthCandidate& candidate : row)
553+
{
554+
if (candidate.x() < firstColumn)
555+
{
556+
continue;
557+
}
558+
559+
if (candidate.x() >= endColumn)
560+
{
561+
break;
562+
}
563+
564+
strengthPositions.emplace_back(candidate.x(), y, candidate.strength());
565+
}
566+
}
567+
}
568+
529569
template <typename T>
530570
void NonMaximumSuppression<T>::reset()
531571
{

0 commit comments

Comments
 (0)