38 #ifndef PCL_GPU_FEATURES_TEST_DATA_SORUCE_HPP_ 39 #define PCL_GPU_FEATURES_TEST_DATA_SORUCE_HPP_ 44 #include <pcl/point_cloud.h> 45 #include <pcl/io/pcd_io.h> 47 #include <pcl/features/normal_3d.h> 48 #include <pcl/visualization/cloud_viewer.h> 49 #include <pcl/gpu/containers/kernel_containers.h> 50 #include <pcl/search/search.h> 52 #include <Eigen/StdVector> 54 #if defined (_WIN32) || defined(_WIN64) 56 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(
pcl::Normal)
67 const static int k = 32;
82 DataSource(
const std::string& file =
"d:/office_chair_model.pcd")
87 pcd.
read(file, *cloud);
91 float sz = (maxp.x - minp.x + maxp.y - minp.y + maxp.z - minp.z) / 3;
97 size_t cloud_size = cloud->
points.size();
98 for(
size_t i = 0; i < cloud_size; ++i)
102 int r = std::max(1, std::min(255, static_cast<int>((
double(rand())/RAND_MAX)*255)));
103 int g = std::max(1, std::min(255, static_cast<int>((
double(rand())/RAND_MAX)*255)));
104 int b = std::max(1, std::min(255, static_cast<int>((
double(rand())/RAND_MAX)*255)));
106 *
reinterpret_cast<int*
>(&p.data[3]) = (b << 16) + (g << 8) + r;
133 size_t cloud_size = cloud->
points.size();
135 std::vector<float> dists;
136 neighbors_all.resize(cloud_size);
137 for(
size_t i = 0; i < cloud_size; ++i)
140 sizes.push_back((
int)neighbors_all[i].size());
142 max_nn_size = *max_element(sizes.begin(), sizes.end());
147 radius = radius == -1 ? this->radius :
radius;
152 size_t cloud_size = cloud->
points.size();
154 std::vector<float> dists;
155 neighbors_all.resize(cloud_size);
156 for(
size_t i = 0; i < cloud_size; ++i)
159 sizes.push_back((
int)neighbors_all[i].size());
161 max_nn_size = *max_element(sizes.begin(), sizes.end());
166 data.resize(max_nn_size * neighbors_all.size());
168 for(
size_t i = 0; i < neighbors_all.size(); ++i)
169 copy(neighbors_all[i].begin(), neighbors_all[i].end(), ps.
ptr(i));
175 for(
size_t i = 0; i < cloud->
points.size(); i+= 10)
180 if (!normals->
points.empty())
182 normals_surface->
points.clear();
183 for(
size_t i = 0; i < normals->
points.size(); i+= 10)
187 normals_surface->
height = 1;
194 for(
size_t i = 0; i < cloud->
points.size(); i += step)
195 indices->push_back(i);
A point structure representing normal coordinates and the surface curvature estimate.
KdTreeFLANN is a generic type of 3D spatial locator using kD-tree structures.
void generateIndices(size_t step=100)
bool wasStopped(int millis_to_wait=1)
Check if the gui was quit, you should quit also.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr())
Provide a pointer to the input dataset.
boost::shared_ptr< std::vector< int > > IndicesPtr
void getNeghborsArray(std::vector< int > &data)
PointCloud< Normal >::Ptr normals
DataSource(const std::string &file="d:/office_chair_model.pcd")
NormalEstimation estimates local surface properties (surface normals and curvatures)at each 3D point...
std::vector< std::vector< int > > neighbors_all
int radiusSearch(const PointT &point, double radius, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const
Search for all the nearest neighbors of the query point in a given radius.
uint32_t height
The point cloud height (if organized as an image-structure).
boost::shared_ptr< PointCloud< PointT > > Ptr
Define standard C methods and C++ classes that are common to all methods.
uint32_t width
The point cloud width (if organized as an image-structure).
void findRadiusNeghbors(float radius=-1)
static const int max_elements
PointXYZ operator()(const Normal &n) const
boost::shared_ptr< KdTree< PointT, Tree > > Ptr
Defines all the PCL implemented PointT point type structures.
A point structure representing Euclidean xyz coordinates.
void showCloud(const ColorCloud::ConstPtr &cloud, const std::string &cloudname="cloud")
Show a cloud, with an optional key for multiple clouds.
PointCloud< PointXYZ >::Ptr cloud
void getMinMax3D(const pcl::PointCloud< PointT > &cloud, PointT &min_pt, PointT &max_pt)
Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud...
PointCloud< Normal >::Ptr normals_surface
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
Simple point cloud visualization class.
int nearestKSearch(const PointT &point, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances) const
Search for k-nearest neighbors for the given query point.
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
Point Cloud Data (PCD) file format reader.
void compute(PointCloudOut &output)
Base method for feature estimation for all points given in <setInputCloud (), setIndices ()> using th...
void setKSearch(int k)
Set the number of k nearest neighbors to use for the feature estimation.
__PCL_GPU_HOST_DEVICE__ T * ptr(int y=0)
PointCloud< PointXYZ >::Ptr surface
boost::shared_ptr< KdTreeFLANN< PointT > > Ptr
void runCloudViewer() const
int read(const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, const int offset=0)
Read a point cloud data from a PCD file and store it into a pcl/PCLPointCloud2.