44#include <pcl/features/usc.h>
45#include <pcl/features/shot_lrf.h>
48#include <pcl/common/point_tests.h>
49#include <pcl/common/utils.h>
53template <
typename Po
intInT,
typename Po
intOutT,
typename Po
intRFT>
bool
58 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n",
getClassName ().c_str ());
72 PCL_ERROR (
"[pcl::%s::initCompute] Init failed.\n",
getClassName ().c_str ());
78 PCL_ERROR (
"[pcl::%s::initCompute] search_radius_ must be GREATER than min_radius_.\n",
getClassName ().c_str ());
86 float azimuth_interval = 360.0f /
static_cast<float> (
azimuth_bins_);
87 float elevation_interval = 180.0f /
static_cast<float> (
elevation_bins_);
115 float e = 1.0f / 3.0f;
129 float V = integr_phi * integr_theta * integr_r;
145template <
typename Po
intInT,
typename Po
intOutT,
typename Po
intRFT>
void
150 const Eigen::Vector3f x_axis ((*
frames_)[index].x_axis[0],
154 const Eigen::Vector3f normal ((*
frames_)[index].z_axis[0],
160 std::vector<float> nn_dists;
163 for (std::size_t ne = 0; ne < neighb_cnt; ne++)
168 Eigen::Vector3f neighbour = (*surface_)[nn_indices[ne]].getVector3fMap ();
173 float r = std::sqrt (nn_dists[ne]);
176 Eigen::Vector3f proj;
184 Eigen::Vector3f cross = x_axis.cross (proj);
185 float phi =
rad2deg (std::atan2 (cross.norm (), x_axis.dot (proj)));
186 phi = cross.dot (normal) < 0.f ? (360.0f - phi) : phi;
188 Eigen::Vector3f no = neighbour - origin;
190 float theta = normal.dot (no);
191 theta =
pcl::rad2deg (std::acos (std::min (1.0f, std::max (-1.0f, theta))));
199 const auto j = std::distance(
radii_interval_.cbegin (), std::prev(rad_min));
200 const auto k = std::distance(
theta_divisions_.cbegin (), std::prev(theta_min));
201 const auto l = std::distance(
phi_divisions_.cbegin (), std::prev(phi_min));
205 std::vector<float> neighbour_didtances;
213 if (w == std::numeric_limits<float>::infinity ())
214 PCL_ERROR (
"Shape Context Error INF!\n");
216 PCL_ERROR (
"Shape Context Error IND!\n");
225template <
typename Po
intInT,
typename Po
intOutT,
typename Po
intRFT>
void
230 output.is_dense =
true;
232 for (std::size_t point_index = 0; point_index <
indices_->size (); ++point_index)
237 const PointRFT& current_frame = (*frames_)[point_index];
239 !std::isfinite (current_frame.x_axis[0]) ||
240 !std::isfinite (current_frame.y_axis[0]) ||
241 !std::isfinite (current_frame.z_axis[0]) )
244 std::numeric_limits<float>::quiet_NaN ());
245 std::fill_n (output[point_index].rf, 9, 0);
246 output.is_dense =
false;
250 for (
int d = 0; d < 3; ++d)
252 output[point_index].rf[0 + d] = current_frame.x_axis[d];
253 output[point_index].rf[3 + d] = current_frame.y_axis[d];
254 output[point_index].rf[6 + d] = current_frame.z_axis[d];
259 std::copy (descriptor.cbegin (), descriptor.cend (), output[point_index].descriptor);
263#define PCL_INSTANTIATE_UniqueShapeContext(T,OutT,RFT) template class PCL_EXPORTS pcl::UniqueShapeContext<T,OutT,RFT>;
Define standard C methods to do angle calculations.
const std::string & getClassName() const
int searchForNeighbors(std::size_t index, double parameter, pcl::Indices &indices, std::vector< float > &distances) const
void setSearchSurface(const PointCloudInConstPtr &cloud)
Provide a pointer to a dataset to add additional information to estimate the features for every point...
virtual bool initCompute()
This method should get called before starting the actual computation.
void setRadiusSearch(double radius)
Set the sphere radius that is to be used for determining the nearest neighbors used for the feature e...
PointCloudInConstPtr surface_
PointCloudLRFConstPtr frames_
virtual bool initLocalReferenceFrames(const std::size_t &indices_size, const LRFEstimationPtr &lrf_estimation=LRFEstimationPtr())
PointCloudConstPtr input_
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.
SHOTLocalReferenceFrameEstimation estimates the Local Reference Frame used in the calculation of the ...
shared_ptr< SHOTLocalReferenceFrameEstimation< PointInT, PointOutT > > Ptr
std::size_t descriptor_length_
Descriptor length.
std::size_t azimuth_bins_
Bins along the azimuth dimension.
std::size_t elevation_bins_
Bins along the elevation dimension.
double point_density_radius_
Point density radius.
std::vector< float > theta_divisions_
Theta divisions interval.
void computeFeature(PointCloudOut &output) override
The actual feature computation.
std::vector< float > phi_divisions_
Phi divisions interval.
double local_radius_
Radius to compute local RF.
bool initCompute() override
Initialize computation by allocating all the intervals and the volume lookup table.
void computePointDescriptor(std::size_t index, std::vector< float > &desc)
Compute 3D shape context feature descriptor.
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
std::vector< float > volume_lut_
Volumes look up table.
std::vector< float > radii_interval_
values of the radii interval.
double min_radius_
Minimal radius value.
std::size_t radius_bins_
Bins along the radius dimension.
Defines some geometrical functions and utility functions.
float deg2rad(float alpha)
Convert an angle from degrees to radians.
float rad2deg(float alpha)
Convert an angle from radians to degrees.
void project(const PointT &point, const PointT &plane_origin, const NormalT &plane_normal, PointT &projected)
bool equal(T val1, T val2, T eps=std::numeric_limits< T >::min())
Check if val1 and val2 are equal to an epsilon extent.
const Eigen::Map< const Eigen::Vector3f > Vector3fMapConst
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.