42 #include <pcl/features/shot_omp.h>
44 #include <pcl/common/point_tests.h>
46 #include <pcl/features/shot_lrf_omp.h>
49 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
bool
54 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
59 if (this->getKSearch () != 0)
62 "[pcl::%s::initCompute] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
63 getClassName().c_str ());
69 lrf_estimator->
setRadiusSearch ((lrf_radius_ > 0 ? lrf_radius_ : search_radius_));
79 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
87 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
bool
92 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
97 if (this->getKSearch () != 0)
100 "[pcl::%s::initCompute] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
101 getClassName().c_str ());
107 lrf_estimator->
setRadiusSearch ((lrf_radius_ > 0 ? lrf_radius_ : search_radius_));
117 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
125 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
void
130 threads_ = omp_get_num_procs();
135 threads_ = nr_threads;
139 template<
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
void
142 descLength_ = nr_grid_sector_ * (nr_shape_bins_ + 1);
144 sqradius_ = search_radius_ * search_radius_;
145 radius3_4_ = (search_radius_ * 3) / 4;
146 radius1_4_ = search_radius_ / 4;
147 radius1_2_ = search_radius_ / 2;
149 assert(descLength_ == 352);
153 #pragma omp parallel for \
156 num_threads(threads_) \
157 schedule(dynamic, chunk_size_)
158 for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
161 Eigen::VectorXf shot;
162 shot.setZero (descLength_);
164 bool lrf_is_nan =
false;
165 const PointRFT& current_frame = (*frames_)[idx];
166 if (!std::isfinite (current_frame.x_axis[0]) ||
167 !std::isfinite (current_frame.y_axis[0]) ||
168 !std::isfinite (current_frame.z_axis[0]))
170 PCL_WARN (
"[pcl::%s::computeFeature] The local reference frame is not valid! Aborting description of point with index %d\n",
171 getClassName ().c_str (), (*indices_)[idx]);
178 std::vector<float> nn_dists (k_);
180 if (!
isFinite ((*input_)[(*indices_)[idx]]) || lrf_is_nan || this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices,
184 for (Eigen::Index d = 0; d < shot.size (); ++d)
185 output[idx].descriptor[d] = std::numeric_limits<float>::quiet_NaN ();
186 for (
int d = 0; d < 9; ++d)
187 output[idx].rf[d] = std::numeric_limits<float>::quiet_NaN ();
194 this->computePointSHOT (idx, nn_indices, nn_dists, shot);
197 for (Eigen::Index d = 0; d < shot.size (); ++d)
198 output[idx].descriptor[d] = shot[d];
199 for (
int d = 0; d < 3; ++d)
201 output[idx].rf[d + 0] = (*frames_)[idx].x_axis[d];
202 output[idx].rf[d + 3] = (*frames_)[idx].y_axis[d];
203 output[idx].rf[d + 6] = (*frames_)[idx].z_axis[d];
209 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
void
214 threads_ = omp_get_num_procs();
219 threads_ = nr_threads;
223 template <
typename Po
intInT,
typename Po
intNT,
typename Po
intOutT,
typename Po
intRFT>
void
226 descLength_ = (b_describe_shape_) ? nr_grid_sector_ * (nr_shape_bins_ + 1) : 0;
227 descLength_ += (b_describe_color_) ? nr_grid_sector_ * (nr_color_bins_ + 1) : 0;
229 assert( (!b_describe_color_ && b_describe_shape_ && descLength_ == 352) ||
230 (b_describe_color_ && !b_describe_shape_ && descLength_ == 992) ||
231 (b_describe_color_ && b_describe_shape_ && descLength_ == 1344)
234 sqradius_ = search_radius_ * search_radius_;
235 radius3_4_ = (search_radius_ * 3) / 4;
236 radius1_4_ = search_radius_ / 4;
237 radius1_2_ = search_radius_ / 2;
241 #pragma omp parallel for \
244 num_threads(threads_) \
245 schedule(dynamic, chunk_size_)
246 for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
248 Eigen::VectorXf shot;
249 shot.setZero (descLength_);
254 std::vector<float> nn_dists (k_);
256 bool lrf_is_nan =
false;
257 const PointRFT& current_frame = (*frames_)[idx];
258 if (!std::isfinite (current_frame.x_axis[0]) ||
259 !std::isfinite (current_frame.y_axis[0]) ||
260 !std::isfinite (current_frame.z_axis[0]))
262 PCL_WARN (
"[pcl::%s::computeFeature] The local reference frame is not valid! Aborting description of point with index %d\n",
263 getClassName ().c_str (), (*indices_)[idx]);
267 if (!
isFinite ((*input_)[(*indices_)[idx]]) ||
269 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0)
272 for (Eigen::Index d = 0; d < shot.size (); ++d)
273 output[idx].descriptor[d] = std::numeric_limits<float>::quiet_NaN ();
274 for (
int d = 0; d < 9; ++d)
275 output[idx].rf[d] = std::numeric_limits<float>::quiet_NaN ();
282 this->computePointSHOT (idx, nn_indices, nn_dists, shot);
285 for (Eigen::Index d = 0; d < shot.size (); ++d)
286 output[idx].descriptor[d] = shot[d];
287 for (
int d = 0; d < 3; ++d)
289 output[idx].rf[d + 0] = (*frames_)[idx].x_axis[d];
290 output[idx].rf[d + 3] = (*frames_)[idx].y_axis[d];
291 output[idx].rf[d + 6] = (*frames_)[idx].z_axis[d];
296 #define PCL_INSTANTIATE_SHOTEstimationOMP(T,NT,OutT,RFT) template class PCL_EXPORTS pcl::SHOTEstimationOMP<T,NT,OutT,RFT>;
297 #define PCL_INSTANTIATE_SHOTColorEstimationOMP(T,NT,OutT,RFT) template class PCL_EXPORTS pcl::SHOTColorEstimationOMP<T,NT,OutT,RFT>;
void setSearchSurface(const PointCloudInConstPtr &cloud)
Provide a pointer to a dataset to add additional information to estimate the features for every point...
void setRadiusSearch(double radius)
Set the sphere radius that is to be used for determining the nearest neighbors used for the feature e...
FeatureWithLocalReferenceFrames provides a public interface for descriptor extractor classes which ne...
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
virtual void setIndices(const IndicesPtr &indices)
Provide a pointer to the vector of indices that represents the input data.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
void computeFeature(PointCloudOut &output) override
Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by ...
bool initCompute() override
This method should get called before starting the actual computation.
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
bool initCompute() override
This method should get called before starting the actual computation.
void computeFeature(PointCloudOut &output) override
Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by ...
SHOTLocalReferenceFrameEstimation estimates the Local Reference Frame used in the calculation of the ...
shared_ptr< SHOTLocalReferenceFrameEstimationOMP< PointInT, PointOutT > > Ptr
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Define methods for measuring time spent in code blocks.
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
IndicesAllocator<> Indices
Type used for indices in PCL.