37 #ifndef PCL_FEATURES_IMPL_SHOT_OMP_H_
38 #define PCL_FEATURES_IMPL_SHOT_OMP_H_
44 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
bool
47 if (!FeatureFromNormals<PointInT, PointNT, PointOutT>::initCompute ())
49 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
54 if (this->getKSearch () != 0)
57 "[pcl::%s::initCompute] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
58 getClassName().c_str ());
63 typename boost::shared_ptr<SHOTLocalReferenceFrameEstimationOMP<PointInT, PointRFT> > lrf_estimator(
new SHOTLocalReferenceFrameEstimationOMP<PointInT, PointRFT>());
64 lrf_estimator->setRadiusSearch (search_radius_);
65 lrf_estimator->setInputCloud (input_);
66 lrf_estimator->setIndices (indices_);
67 lrf_estimator->setNumberOfThreads(
threads_);
70 lrf_estimator->setSearchSurface(surface_);
72 if (!FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFrames (indices_->size (), lrf_estimator))
74 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
82 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
bool
85 if (!FeatureFromNormals<PointInT, PointNT, PointOutT>::initCompute ())
87 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
92 if (this->getKSearch () != 0)
95 "[pcl::%s::initCompute] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
96 getClassName().c_str ());
101 typename boost::shared_ptr<SHOTLocalReferenceFrameEstimationOMP<PointInT, PointRFT> > lrf_estimator(
new SHOTLocalReferenceFrameEstimationOMP<PointInT, PointRFT>());
102 lrf_estimator->setRadiusSearch (search_radius_);
103 lrf_estimator->setInputCloud (input_);
104 lrf_estimator->setIndices (indices_);
105 lrf_estimator->setNumberOfThreads(
threads_);
108 lrf_estimator->setSearchSurface(surface_);
110 if (!FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFrames (indices_->size (), lrf_estimator))
112 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
120 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intRFT>
bool
123 if (!FeatureFromNormals<PointInT, PointNT, pcl::SHOT>::initCompute ())
125 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
130 if (this->getKSearch () != 0)
133 "[pcl::%s::initCompute] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
134 getClassName().c_str ());
139 typename boost::shared_ptr<SHOTLocalReferenceFrameEstimationOMP<PointInT, PointRFT> > lrf_estimator(
new SHOTLocalReferenceFrameEstimationOMP<PointInT, PointRFT>());
140 lrf_estimator->setRadiusSearch (search_radius_);
141 lrf_estimator->setInputCloud (input_);
142 lrf_estimator->setIndices (indices_);
143 lrf_estimator->setNumberOfThreads(
threads_);
146 lrf_estimator->setSearchSurface(surface_);
148 if (!FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFrames (indices_->size (), lrf_estimator))
150 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
158 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
void
165 descLength_ = nr_grid_sector_ * (nr_shape_bins_ + 1);
167 sqradius_ = search_radius_ * search_radius_;
168 radius3_4_ = (search_radius_ * 3) / 4;
169 radius1_4_ = search_radius_ / 4;
170 radius1_2_ = search_radius_ / 2;
172 assert(descLength_ == 352);
174 int data_size =
static_cast<int> (indices_->size ());
175 Eigen::VectorXf *shot =
new Eigen::VectorXf[
threads_];
178 shot[i].setZero (descLength_);
180 output.is_dense =
true;
182 #pragma omp parallel for num_threads(threads_)
183 for (
int idx = 0; idx < data_size; ++idx)
186 int tid = omp_get_thread_num ();
191 bool lrf_is_nan =
false;
192 const PointRFT& current_frame = (*frames_)[idx];
197 PCL_WARN (
"[pcl::%s::computeFeature] The local reference frame is not valid! Aborting description of point with index %d\n",
198 getClassName ().c_str (), (*indices_)[idx]);
204 std::vector<int> nn_indices (k_);
205 std::vector<float> nn_dists (k_);
207 if (!
isFinite ((*input_)[(*indices_)[idx]]) || lrf_is_nan || this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices,
211 for (
int d = 0; d < shot[tid].size (); ++d)
212 output.points[idx].descriptor[d] = std::numeric_limits<float>::quiet_NaN ();
213 for (
int d = 0; d < 9; ++d)
214 output.points[idx].rf[d] = std::numeric_limits<float>::quiet_NaN ();
216 output.is_dense =
false;
224 for (
int d = 0; d < shot[tid].size (); ++d)
225 output.points[idx].descriptor[d] = shot[tid][d];
226 for (
int d = 0; d < 9; ++d)
227 output.points[idx].rf[d] = frames_->points[idx].rf[(4 * (d / 3) + (d % 3))];
233 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intRFT>
void
240 descLength_ = nr_grid_sector_ * (nr_shape_bins_ + 1);
242 sqradius_ = search_radius_ * search_radius_;
243 radius3_4_ = (search_radius_ * 3) / 4;
244 radius1_4_ = search_radius_ / 4;
245 radius1_2_ = search_radius_ / 2;
247 for (
size_t idx = 0; idx < indices_->size (); ++idx)
248 output.points[idx].descriptor.resize (descLength_);
250 int data_size =
static_cast<int> (indices_->size ());
251 Eigen::VectorXf *shot =
new Eigen::VectorXf[
threads_];
254 shot[i].setZero (descLength_);
256 output.is_dense =
true;
258 #pragma omp parallel for num_threads(threads_)
259 for (
int idx = 0; idx < data_size; ++idx)
262 int tid = omp_get_thread_num ();
267 bool lrf_is_nan =
false;
268 const PointRFT& current_frame = (*frames_)[idx];
273 PCL_WARN (
"[pcl::%s::computeFeature] The local reference frame is not valid! Aborting description of point with index %d\n",
274 getClassName ().c_str (), (*indices_)[idx]);
280 std::vector<int> nn_indices (k_);
281 std::vector<float> nn_dists (k_);
283 if (!
isFinite ((*input_)[(*indices_)[idx]]) || lrf_is_nan || this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices,
287 for (
int d = 0; d < shot[tid].size (); ++d)
288 output.points[idx].descriptor[d] = std::numeric_limits<float>::quiet_NaN ();
289 for (
int d = 0; d < 9; ++d)
290 output.points[idx].rf[d] = std::numeric_limits<float>::quiet_NaN ();
292 output.is_dense =
false;
300 for (
int d = 0; d < shot[tid].size (); ++d)
301 output.points[idx].descriptor[d] = shot[tid][d];
302 for (
int d = 0; d < 9; ++d)
303 output.points[idx].rf[d] = frames_->points[idx].rf[(4 * (d / 3) + (d % 3))];
309 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
void
315 descLength_ = (b_describe_shape_) ? nr_grid_sector_ * (nr_shape_bins_ + 1) : 0;
316 descLength_ += (b_describe_color_) ? nr_grid_sector_ * (nr_color_bins_ + 1) : 0;
318 assert( (!b_describe_color_ && b_describe_shape_ && descLength_ == 352) ||
319 (b_describe_color_ && !b_describe_shape_ && descLength_ == 992) ||
320 (b_describe_color_ && b_describe_shape_ && descLength_ == 1344)
323 sqradius_ = search_radius_ * search_radius_;
324 radius3_4_ = (search_radius_ * 3) / 4;
325 radius1_4_ = search_radius_ / 4;
326 radius1_2_ = search_radius_ / 2;
328 int data_size =
static_cast<int> (indices_->size ());
329 Eigen::VectorXf *shot =
new Eigen::VectorXf[
threads_];
332 shot[i].setZero (descLength_);
334 output.is_dense =
true;
336 #pragma omp parallel for num_threads(threads_)
337 for (
int idx = 0; idx < data_size; ++idx)
340 int tid = omp_get_thread_num ();
346 std::vector<int> nn_indices (k_);
347 std::vector<float> nn_dists (k_);
349 bool lrf_is_nan =
false;
350 const PointRFT& current_frame = (*frames_)[idx];
355 PCL_WARN (
"[pcl::%s::computeFeature] The local reference frame is not valid! Aborting description of point with index %d\n",
356 getClassName ().c_str (), (*indices_)[idx]);
360 if (!
isFinite ((*input_)[(*indices_)[idx]]) ||
362 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
365 for (
int d = 0; d < shot[tid].size (); ++d)
366 output.points[idx].descriptor[d] = std::numeric_limits<float>::quiet_NaN ();
367 for (
int d = 0; d < 9; ++d)
368 output.points[idx].rf[d] = std::numeric_limits<float>::quiet_NaN ();
370 output.is_dense =
false;
378 for (
int d = 0; d < shot[tid].size (); ++d)
379 output.points[idx].descriptor[d] = shot[tid][d];
380 for (
int d = 0; d < 9; ++d)
381 output.points[idx].rf[d] = frames_->points[idx].rf[ (4*(d/3) + (d%3)) ];
388 template<
typename Po
intNT,
typename Po
intRFT>
void
394 descLength_ = (b_describe_shape_) ? nr_grid_sector_ * (nr_shape_bins_ + 1) : 0;
395 descLength_ += (b_describe_color_) ? nr_grid_sector_ * (nr_color_bins_ + 1) : 0;
397 sqradius_ = search_radius_ * search_radius_;
398 radius3_4_ = (search_radius_ * 3) / 4;
399 radius1_4_ = search_radius_ / 4;
400 radius1_2_ = search_radius_ / 2;
403 for (
size_t idx = 0; idx < indices_->size (); ++idx)
404 output.points[idx].descriptor.resize (descLength_);
406 int data_size =
static_cast<int> (indices_->size ());
407 Eigen::VectorXf *shot =
new Eigen::VectorXf[
threads_];
410 shot[i].setZero (descLength_);
412 output.is_dense =
true;
414 #pragma omp parallel for num_threads(threads_)
415 for (
int idx = 0; idx < data_size; ++idx)
418 int tid = omp_get_thread_num ();
424 std::vector<int> nn_indices (k_);
425 std::vector<float> nn_dists (k_);
427 bool lrf_is_nan =
false;
428 const PointRFT& current_frame = (*frames_)[idx];
433 PCL_WARN (
"[pcl::%s::computeFeature] The local reference frame is not valid! Aborting description of point with index %d\n",
434 getClassName ().c_str (), (*indices_)[idx]);
438 if (!
isFinite ((*input_)[(*indices_)[idx]]) ||
440 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
443 for (
int d = 0; d < shot[tid].size (); ++d)
444 output.points[idx].descriptor[d] = std::numeric_limits<float>::quiet_NaN ();
445 for (
int d = 0; d < 9; ++d)
446 output.points[idx].rf[d] = std::numeric_limits<float>::quiet_NaN ();
448 output.is_dense =
false;
456 for (
int d = 0; d < shot[tid].size (); ++d)
457 output.points[idx].descriptor[d] = shot[tid][d];
458 for (
int d = 0; d < 9; ++d)
459 output.points[idx].rf[d] = frames_->points[idx].rf[ (4*(d/3) + (d%3)) ];
465 #define PCL_INSTANTIATE_SHOTEstimationOMP(T,NT,OutT,RFT) template class PCL_EXPORTS pcl::SHOTEstimationOMP<T,NT,OutT,RFT>;
466 #define PCL_INSTANTIATE_SHOTColorEstimationOMP(T,NT,OutT,RFT) template class PCL_EXPORTS pcl::SHOTColorEstimationOMP<T,NT,OutT,RFT>;
468 #endif // PCL_FEATURES_IMPL_SHOT_OMP_H_