21 #ifndef _NON_MAXIMA_SUPPRESSION_H
22 #define _NON_MAXIMA_SUPPRESSION_H
41 template<
class D,
class FeatureListType,
class Param>
42 void NonMaximaSuppression(
const D *src, FeatureListType &maxima,
unsigned int n,
long stride,
unsigned int width,
unsigned int height, D threshold, Param param,
int nThreads = sprint::thread::hardware_concurrency() );
49 template<
class D,
class FeatureListType,
class Param>
70 void *
Process(FeatureListType &maxima,
int j0,
int j1)
const
73 typedef typename FeatureListType::value_type FeatureType;
75 for(
int j=j0; j<j1; j+=n+1)
77 int j_max = std::min(j+n, height-1);
79 for(
int i=0; i<
width; i+=n+1)
86 int i_max = std::min(i+n, width-1);
93 for(
int j2=j; j2<=j_max; ++j2)
95 for(
int i2=i; i2<=i_max; ++i2)
114 int j2_0 = pj - (int) n;
115 if(j2_0 < 0) j2_0 = 0;
116 int j2_1 = pj + (int) n;
117 if(j2_1 >= height) j2_1 = height-1;
119 int i2_0 = pi - (int) n;
120 if(i2_0 < 0) i2_0 = 0;
121 int i2_1 = pi + (int) n;
122 if(i2_1 >= width) i2_1 = width-1;
125 ptr = src + (j2_0 - j ) * stride;
128 for (int32_t j2=j2_0; j2<=j2_1; j2++) {
129 for (int32_t i2=i2_0; i2<=i2_1; i2++) {
130 if (i2<i || i2>i+(
int)n || j2<j || j2>j+(int)n) {
144 p.Set(pi, pj, pval,
id);
145 maxima.push_back( p );
153 src+= (stride * (n+1));
166 template<
class D,
class FeatureListType,
class Param>
167 void NonMaximaSuppression(
const D *src, FeatureListType &maxima,
unsigned int n,
long stride,
unsigned int width,
unsigned int height, D threshold, Param param,
int nThreads )
180 int32_t active = (int)height / ((
int)n+1);
183 if((active > 0) && (nThreads>1) && (active>=3*nThreads) )
186 FeatureListType *outputs =
new FeatureListType[nThreads];
188 for(
int k=0; k<nThreads; ++k)
190 uint32_t k0 = (active * k) / nThreads;
191 uint32_t k1 = (active * (k+1) ) / nThreads;
198 for(
int k =0; k<nThreads; ++k)
200 maxima.insert(maxima.end(), outputs[k].begin(),outputs[k].end());
207 nms.
Process(maxima, 0, (
int) height);
int n
nms step
Definition: NonMaximaSuppression.h:54
const D * m_src
The buffer.
Definition: NonMaximaSuppression.h:52
int width
horizontal number of pixel to be processed
Definition: NonMaximaSuppression.h:58
Definition: thread_group.h:82
The internal NM class.
Definition: NonMaximaSuppression.h:50
void join_all()
wait all threads terminate
Definition: thread_group.h:114
proposal 1 for thread group
long stride
stride
Definition: NonMaximaSuppression.h:56
D threshold
threshold
Definition: NonMaximaSuppression.h:64
method to create function pointer for thread call
bool create_thread(const sprint::thread_function &p)
create an additional thread
Definition: thread_group.h:102
void * Process(FeatureListType &maxima, int j0, int j1) const
Definition: NonMaximaSuppression.h:70
Param id
optional data used by Set Method
Definition: NonMaximaSuppression.h:62
int height
clamping value
Definition: NonMaximaSuppression.h:60
void NonMaximaSuppression(const D *src, FeatureListType &maxima, unsigned int n, long stride, unsigned int width, unsigned int height, D threshold, Param param, int nThreads=sprint::thread::hardware_concurrency())
Definition: NonMaximaSuppression.h:167