38 #ifndef PCL_GPU_FEATURES_TEST_DATA_SOURCE_HPP_
39 #define PCL_GPU_FEATURES_TEST_DATA_SOURCE_HPP_
43 #include <pcl/point_types.h>
44 #include <pcl/point_cloud.h>
45 #include <pcl/io/pcd_io.h>
46 #include <pcl/common/common.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;
99 int r = std::max(1, std::min(255, static_cast<int>((
double(rand())/RAND_MAX)*255)));
100 int g = std::max(1, std::min(255, static_cast<int>((
double(rand())/RAND_MAX)*255)));
101 int b = std::max(1, std::min(255, static_cast<int>((
double(rand())/RAND_MAX)*255)));
103 *
reinterpret_cast<int*
>(&p.data[3]) = (b << 16) + (g << 8) + r;
130 const auto cloud_size = cloud->
size();
132 std::vector<float> dists;
133 neighbors_all.resize(cloud_size);
134 for(std::size_t i = 0; i < cloud_size; ++i)
137 sizes.push_back((
int)neighbors_all[i].size());
139 max_nn_size = *max_element(sizes.begin(), sizes.end());
144 radius = radius == -1 ? this->radius :
radius;
149 const auto cloud_size = cloud->
size();
151 std::vector<float> dists;
152 neighbors_all.resize(cloud_size);
153 for(std::size_t i = 0; i < cloud_size; ++i)
155 kdtree->
radiusSearch((*cloud)[i], radius, neighbors_all[i], dists);
156 sizes.push_back((
int)neighbors_all[i].size());
158 max_nn_size = *max_element(sizes.begin(), sizes.end());
163 data.resize(max_nn_size * neighbors_all.size());
165 for(std::size_t i = 0; i < neighbors_all.size(); ++i)
166 copy(neighbors_all[i].begin(), neighbors_all[i].end(), ps.
ptr(i));
172 for(std::size_t i = 0; i < cloud->
size(); i+= 10)
177 if (!normals->
empty())
179 normals_surface->
clear();
180 for(std::size_t i = 0; i < normals->
size(); i+= 10)
181 normals_surface->
push_back((*normals)[i]);
183 normals_surface->
width = surface->
size();
184 normals_surface->
height = 1;
191 for(std::size_t i = 0; i < cloud->
size(); i += step)
192 indices->push_back(i);
A point structure representing normal coordinates and the surface curvature estimate.
shared_ptr< KdTree< PointT, Tree > > Ptr
KdTreeFLANN is a generic type of 3D spatial locator using kD-tree structures.
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...
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< Indices > IndicesPtr
void getNeghborsArray(std::vector< int > &data)
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
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...
PointXYZ operator()(const Normal &n) const
std::vector< std::vector< int > > neighbors_all
std::uint32_t width
The point cloud width (if organized as an image-structure).
void findRadiusNeghbors(float radius=-1)
static const int max_elements
void generateIndices(std::size_t step=100)
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
void clear()
Removes all points in a cloud and sets the width and height to 0.
void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr()) override
Provide a pointer to the input dataset.
int read(const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, const int offset=0) override
Read a point cloud data from a PCD file and store it into a pcl/PCLPointCloud2.
std::uint32_t height
The point cloud height (if organized as an image-structure).
PointCloud represents the base class in PCL for storing collections of 3D points. ...
Simple point cloud visualization class.
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
void runCloudViewer() const
shared_ptr< KdTreeFLANN< PointT, Dist >> Ptr
Point Cloud Data (PCD) file format reader.
void compute(PointCloudOut &output)
Base method for feature estimation for all points given in using th...
void setKSearch(int k)
Set the number of k nearest neighbors to use for the feature estimation.
void setInputCloud(const PointCloudConstPtr &cloud) override
Provide a pointer to the input dataset.
__PCL_GPU_HOST_DEVICE__ T * ptr(int y=0)
int radiusSearch(const PointT &point, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const override
Search for all the nearest neighbors of the query point in a given radius.
PointCloud< PointXYZ >::Ptr surface
int nearestKSearch(const PointT &point, unsigned int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const override
Search for k-nearest neighbors for the given query point.