47 template<std::
size_t dim>
53 const auto& d = (*data)[0];
78 pts.conservativeResize(idx);
99 template<std::
size_t dim>
105 const std::size_t nbData = (*data).size() - 1;
106 const std::size_t randId =
107 static_cast<std::size_t
>( nbData *
108 (
static_cast<float>(std::rand()/
static_cast<float>(RAND_MAX))));
110 const auto& d = (*data)[randId];
115 if(std::size_t(d)<idx)
119 pts.swapCols(idx, j);
147 template<std::
size_t dim>
152 const int featDim(pts.features.rows());
153 const int descDim(pts.descriptors.rows());
154 const int timeDim(pts.times.rows());
157 const std::size_t nbData = (*data).size();
159 const auto& d = (*data)[0];
168 for(std::size_t
id=1;
id<nbData;++id)
171 const auto& curId = (*data)[id];
172 std::size_t i = curId;
179 for (
int f = 0; f < (featDim - 1); ++f)
180 pts.features(f,j) += pts.features(f,i);
182 if (pts.descriptors.cols() > 0)
183 for (
int d = 0; d < descDim; ++d)
184 pts.descriptors(d,j) += pts.descriptors(d,i);
186 if (pts.times.cols() > 0)
187 for (
int t = 0; t < timeDim; ++t)
188 pts.times(t,j) += pts.times(t,i);
192 for (
int f = 0; f < (featDim - 1); ++f)
193 pts.features(f,j) /=
T(nbData);
195 if (pts.descriptors.cols() > 0)
196 for (
int d = 0; d < descDim; ++d)
197 pts.descriptors(d,j) /=
T(nbData);
199 if (pts.times.cols() > 0)
200 for (
int t = 0; t < timeDim; ++t)
201 pts.times(t,j) /=
T(nbData);
204 pts.swapCols(idx, j);
221 template<std::
size_t dim>
227 const std::size_t nbData = (*data).size();
230 return (p1 - p2).norm();
235 for(std::size_t i=0;i<
dim;++i) center(i)=
T(0.);
237 for(std::size_t
id=0;
id<nbData;++id)
240 const auto& curId = (*data)[id];
241 std::size_t i = curId;
248 for (std::size_t f = 0; f <
dim; ++f)
249 center(f) += pts.features(f,i);
251 for(std::size_t i=0;i<
dim;++i) center(i)/=
T(nbData);
254 T minDist = std::numeric_limits<T>::max();
255 std::size_t medId = 0;
257 for(std::size_t
id=0;
id<nbData;++id)
260 const auto curId = (*data)[id];
261 std::size_t i = curId;
267 const T curDist =
dist(pts.features.col(i).head(
dim), center);
276 pts.swapCols(idx, medId);
289 template <
typename T>
294 maxPointByNode{Parametrizable::get<std::size_t>(
"maxPointByNode")},
295 maxSizeByNode{Parametrizable::get<T>(
"maxSizeByNode")}
299 const int sm = this->
template get<int>(
"samplingMethod");
300 samplingMethod = SamplingMethod(sm);
304 samplingMethod = SamplingMethod::FIRST_PTS;
308 template <
typename T>
313 inPlaceFilter(output);
317 template <
typename T>
320 const std::size_t featDim = cloud.
features.rows();
322 assert(featDim == 4 or featDim == 3);
325 this->sample<2>(cloud);
328 this->sample<3>(cloud);
332 template<std::
size_t dim>
337 oc.
build(cloud, maxPointByNode, maxSizeByNode, buildParallel);
339 switch(samplingMethod)
341 case SamplingMethod::FIRST_PTS:
348 case SamplingMethod::RAND_PTS:
355 case SamplingMethod::CENTROID:
362 case SamplingMethod::MEDOID: