本文整理汇总了C++中typenamepcl::PointCloud::size方法的典型用法代码示例。如果您正苦于以下问题:C++ PointCloud::size方法的具体用法?C++ PointCloud::size怎么用?C++ PointCloud::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenamepcl::PointCloud
的用法示例。
在下文中一共展示了PointCloud::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acosf
template<typename PointT> void
pcl::approximatePolygon (const PlanarPolygon<PointT>& polygon, PlanarPolygon<PointT>& approx_polygon, float threshold, bool refine, bool closed)
{
const Eigen::Vector4f& coefficients = polygon.getCoefficients ();
const typename pcl::PointCloud<PointT>::VectorType &contour = polygon.getContour ();
Eigen::Vector3f rotation_axis (coefficients[1], -coefficients[0], 0.0f);
rotation_axis.normalize ();
float rotation_angle = acosf (coefficients [2]);
Eigen::Affine3f transformation = Eigen::Translation3f (0, 0, coefficients [3]) * Eigen::AngleAxisf (rotation_angle, rotation_axis);
typename pcl::PointCloud<PointT>::VectorType polygon2D (contour.size ());
for (unsigned pIdx = 0; pIdx < polygon2D.size (); ++pIdx)
polygon2D [pIdx].getVector3fMap () = transformation * contour [pIdx].getVector3fMap ();
typename pcl::PointCloud<PointT>::VectorType approx_polygon2D;
approximatePolygon2D<PointT> (polygon2D, approx_polygon2D, threshold, refine, closed);
typename pcl::PointCloud<PointT>::VectorType &approx_contour = approx_polygon.getContour ();
approx_contour.resize (approx_polygon2D.size ());
Eigen::Affine3f inv_transformation = transformation.inverse ();
for (unsigned pIdx = 0; pIdx < approx_polygon2D.size (); ++pIdx)
approx_contour [pIdx].getVector3fMap () = inv_transformation * approx_polygon2D [pIdx].getVector3fMap ();
}
示例2: observation_transformed
void
MultiviewRecognizerWithChangeDetection<PointT>::reconstructionFiltering(typename pcl::PointCloud<PointT>::Ptr observation,
pcl::PointCloud<pcl::Normal>::Ptr observation_normals, const Eigen::Matrix4f &absolute_pose, size_t view_id) {
CloudPtr observation_transformed(new Cloud);
pcl::transformPointCloud(*observation, *observation_transformed, absolute_pose);
CloudPtr cloud_tmp(new Cloud);
std::vector<int> indices;
v4r::ChangeDetector<PointT>::difference(observation_transformed, removed_points_cumulated_history_[view_id],
cloud_tmp, indices, param_.tolerance_for_cloud_diff_);
/* Visualization of changes removal for reconstruction:
Cloud rec_changes;
rec_changes += *cloud_transformed;
v4r::VisualResultsStorage::copyCloudColored(*removed_points_cumulated_history_[view_id], rec_changes, 255, 0, 0);
v4r::VisualResultsStorage::copyCloudColored(*cloud_tmp, rec_changes, 200, 0, 200);
stringstream ss;
ss << view_id;
visResStore.savePcd("reconstruction_changes_" + ss.str(), rec_changes);*/
std::vector<bool> preserved_mask(observation->size(), false);
for (std::vector<int>::iterator i = indices.begin(); i < indices.end(); i++) {
preserved_mask[*i] = true;
}
for (size_t j = 0; j < preserved_mask.size(); j++) {
if (!preserved_mask[j]) {
setNan(observation->at(j));
setNan(observation_normals->at(j));
}
}
PCL_INFO("Points by change detection removed: %d\n", observation->size() - indices.size());
}
示例3: octree
template <typename PointInT, typename PointNT, typename PointOutT> void
pcl::GFPFHEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut &output)
{
pcl::octree::OctreePointCloudSearch<PointInT> octree (octree_leaf_size_);
octree.setInputCloud (input_);
octree.addPointsFromInputCloud ();
typename pcl::PointCloud<PointInT>::VectorType occupied_cells;
octree.getOccupiedVoxelCenters (occupied_cells);
// Determine the voxels crosses along the line segments
// formed by every pair of occupied cells.
std::vector< std::vector<int> > line_histograms;
for (size_t i = 0; i < occupied_cells.size (); ++i)
{
Eigen::Vector3f origin = occupied_cells[i].getVector3fMap ();
for (size_t j = i+1; j < occupied_cells.size (); ++j)
{
typename pcl::PointCloud<PointInT>::VectorType intersected_cells;
Eigen::Vector3f end = occupied_cells[j].getVector3fMap ();
octree.getApproxIntersectedVoxelCentersBySegment (origin, end, intersected_cells, 0.5f);
// Intersected cells are ordered from closest to furthest w.r.t. the origin.
std::vector<int> histogram;
for (size_t k = 0; k < intersected_cells.size (); ++k)
{
std::vector<int> indices;
octree.voxelSearch (intersected_cells[k], indices);
int label = emptyLabel ();
if (indices.size () != 0)
{
label = getDominantLabel (indices);
}
histogram.push_back (label);
}
line_histograms.push_back(histogram);
}
}
std::vector< std::vector<int> > transition_histograms;
computeTransitionHistograms (line_histograms, transition_histograms);
std::vector<float> distances;
computeDistancesToMean (transition_histograms, distances);
std::vector<float> gfpfh_histogram;
computeDistanceHistogram (distances, gfpfh_histogram);
output.clear ();
output.width = 1;
output.height = 1;
output.points.resize (1);
std::copy (gfpfh_histogram.begin (), gfpfh_histogram.end (), output.points[0].histogram);
}
示例4: ids
template <typename PointT> inline float
pcl::getMeanPointDensity (const typename pcl::PointCloud<PointT>::ConstPtr &cloud, float max_dist, int nr_threads)
{
const float max_dist_sqr = max_dist * max_dist;
const std::size_t s = cloud.size ();
pcl::search::KdTree <PointT> tree;
tree.setInputCloud (cloud);
float mean_dist = 0.f;
int num = 0;
std::vector <int> ids (2);
std::vector <float> dists_sqr (2);
#ifdef _OPENMP
#pragma omp parallel for \
reduction (+:mean_dist, num) \
private (ids, dists_sqr) shared (tree, cloud) \
default (none)num_threads (nr_threads)
#endif
for (int i = 0; i < 1000; i++)
{
tree.nearestKSearch (cloud->points[rand () % s], 2, ids, dists_sqr);
if (dists_sqr[1] < max_dist_sqr)
{
mean_dist += std::sqrt (dists_sqr[1]);
num++;
}
}
return (mean_dist / num);
};
示例5: cropCloudWithSphere
void WorldDownloadManager::cropCloudWithSphere(const Eigen::Vector3f & center,const float radius,
typename pcl::PointCloud<PointT>::ConstPtr cloud,typename pcl::PointCloud<PointT>::Ptr out_cloud)
{
const uint cloud_size = cloud->size();
std::vector<bool> valid_points(cloud_size,true);
// check the points
for (uint i = 0; i < cloud_size; i++)
{
const PointT & pt = (*cloud)[i];
const Eigen::Vector3f ept(pt.x,pt.y,pt.z);
if ((ept - center).squaredNorm() > radius * radius)
valid_points[i] = false;
}
// discard invalid points
out_cloud->clear();
out_cloud->reserve(cloud_size);
uint count = 0;
for (uint i = 0; i < cloud_size; i++)
if (valid_points[i])
{
out_cloud->push_back((*cloud)[i]);
count++;
}
out_cloud->resize(count);
}
示例6: cropCloud
void WorldDownloadManager::cropCloud(const Eigen::Vector3f & min,const Eigen::Vector3f & max,
typename pcl::PointCloud<PointT>::ConstPtr cloud,typename pcl::PointCloud<PointT>::Ptr out_cloud)
{
const uint cloud_size = cloud->size();
std::vector<bool> valid_points(cloud_size,true);
// check the points
for (uint i = 0; i < cloud_size; i++)
{
const PointT & pt = (*cloud)[i];
if (pt.x > max.x() || pt.y > max.y() || pt.z > max.z() ||
pt.x < min.x() || pt.y < min.y() || pt.z < min.z())
valid_points[i] = false;
}
// discard invalid points
out_cloud->clear();
out_cloud->reserve(cloud_size);
uint count = 0;
for (uint i = 0; i < cloud_size; i++)
if (valid_points[i])
{
out_cloud->push_back((*cloud)[i]);
count++;
}
out_cloud->resize(count);
}
示例7: colorize
static bool colorize(const typename pcl::PointCloud<PointTypeIn>& iCloud,
const Eigen::Affine3d& iCloudToCamera,
const bot_core::image_t& iImage,
const BotCamTrans* iCamTrans,
typename pcl::PointCloud<PointTypeOut>& oCloud) {
pcl::copyPointCloud(iCloud, oCloud);
pcl::PointCloud<PointTypeOut> tempCloud;
pcl::transformPointCloud(iCloud, tempCloud, iCloudToCamera.cast<float>());
int numPoints = iCloud.size();
for (int i = 0; i < numPoints; ++i) {
double p[3] = {tempCloud[i].x, tempCloud[i].y, tempCloud[i].z};
double pix[3];
bot_camtrans_project_point(iCamTrans, p, pix);
oCloud[i].r = oCloud[i].g = oCloud[i].b = 0;
if (pix[2] < 0) {
continue;
}
uint8_t r, g, b;
if (interpolate(pix[0], pix[1], iImage, r, g, b)) {
oCloud[i].r = r;
oCloud[i].g = g;
oCloud[i].b = b;
}
}
return true;
}
示例8: radiusFiltering
pcl::IndicesPtr radiusFiltering(
const typename pcl::PointCloud<PointT>::Ptr & cloud,
const pcl::IndicesPtr & indices,
float radiusSearch,
int minNeighborsInRadius)
{
typedef typename pcl::search::KdTree<PointT> KdTree;
typedef typename KdTree::Ptr KdTreePtr;
KdTreePtr tree (new KdTree(false));
if(indices->size())
{
pcl::IndicesPtr output(new std::vector<int>(indices->size()));
int oi = 0; // output iterator
tree->setInputCloud(cloud, indices);
for(unsigned int i=0; i<indices->size(); ++i)
{
std::vector<int> kIndices;
std::vector<float> kDistances;
int k = tree->radiusSearch(cloud->at(indices->at(i)), radiusSearch, kIndices, kDistances);
if(k > minNeighborsInRadius)
{
output->at(oi++) = indices->at(i);
}
}
output->resize(oi);
return output;
}
else
{
pcl::IndicesPtr output(new std::vector<int>(cloud->size()));
int oi = 0; // output iterator
tree->setInputCloud(cloud);
for(unsigned int i=0; i<cloud->size(); ++i)
{
std::vector<int> kIndices;
std::vector<float> kDistances;
int k = tree->radiusSearch(cloud->at(i), radiusSearch, kIndices, kDistances);
if(k > minNeighborsInRadius)
{
output->at(oi++) = i;
}
}
output->resize(oi);
return output;
}
}
示例9: projectCloudOnXYPlane
void projectCloudOnXYPlane(
typename pcl::PointCloud<PointT>::Ptr & cloud)
{
for(unsigned int i=0; i<cloud->size(); ++i)
{
cloud->at(i).z = 0;
}
}
示例10: boxMask
VectorXb boxMask(typename pcl::PointCloud<T>::ConstPtr in, float xmin, float ymin, float zmin, float xmax, float ymax, float zmax) {
int i=0;
VectorXb out(in->size());
BOOST_FOREACH(const T& pt, in->points) {
out[i] = (pt.x >= xmin && pt.x <= xmax && pt.y >= ymin && pt.y <= ymax && pt.z >= zmin && pt.z <= zmax);
++i;
}
return out;
}
示例11: return
template <typename PointT> bool
PCLVisualizer::addCorrespondences (
const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
const std::vector<int> &correspondences,
const std::string &id,
int viewport)
{
// Check to see if this ID entry already exists (has it been already added to the visualizer?)
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
if (am_it != shape_actor_map_->end ())
{
PCL_WARN ("[addCorrespondences] A set of correspondences with id <%s> already exists! Please choose a different id and retry.\n", id.c_str ());
return (false);
}
vtkSmartPointer<vtkAppendPolyData> polydata = vtkSmartPointer<vtkAppendPolyData>::New ();
vtkSmartPointer<vtkUnsignedCharArray> line_colors = vtkSmartPointer<vtkUnsignedCharArray>::New ();
line_colors->SetNumberOfComponents (3);
line_colors->SetName ("Colors");
// Use Red by default (can be changed later)
unsigned char rgb[3];
rgb[0] = 1 * 255.0;
rgb[1] = 0 * 255.0;
rgb[2] = 0 * 255.0;
// Draw lines between the best corresponding points
for (size_t i = 0; i < source_points->size (); ++i)
{
const PointT &p_src = source_points->points[i];
const PointT &p_tgt = target_points->points[correspondences[i]];
// Add the line
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New ();
line->SetPoint1 (p_src.x, p_src.y, p_src.z);
line->SetPoint2 (p_tgt.x, p_tgt.y, p_tgt.z);
line->Update ();
polydata->AddInput (line->GetOutput ());
line_colors->InsertNextTupleValue (rgb);
}
polydata->Update ();
vtkSmartPointer<vtkPolyData> line_data = polydata->GetOutput ();
line_data->GetCellData ()->SetScalars (line_colors);
// Create an Actor
vtkSmartPointer<vtkLODActor> actor;
createActorFromVTKDataSet (line_data, actor);
actor->GetProperty ()->SetRepresentationToWireframe ();
actor->GetProperty ()->SetOpacity (0.5);
addActorToRenderer (actor, viewport);
// Save the pointer/ID pair to the global actor map
(*shape_actor_map_)[id] = actor;
//style_->setCloudActorMap (cloud_actor_map_);
return (true);
}
示例12: toXYZ
pcl::PointCloud<pcl::PointXYZ>::Ptr toXYZ(typename pcl::PointCloud<T>::ConstPtr in) {
pcl::PointCloud<pcl::PointXYZ>::Ptr out(new pcl::PointCloud<PointXYZ>());
out->reserve(in->size());
out->width = in->width;
out->height = in->height;
BOOST_FOREACH(const T& pt, in->points) {
out->points.push_back(PointXYZ(pt.x, pt.y, pt.z));
}
return out;
}
示例13:
void ICCVTutorial<FeatureType>::findCorrespondences (typename pcl::PointCloud<FeatureType>::Ptr source, typename pcl::PointCloud<FeatureType>::Ptr target, std::vector<int>& correspondences) const
{
cout << "correspondence assignment..." << std::flush;
correspondences.resize (source->size());
// Use a KdTree to search for the nearest matches in feature space
pcl::KdTreeFLANN<FeatureType> descriptor_kdtree;
descriptor_kdtree.setInputCloud (target);
// Find the index of the best match for each keypoint, and store it in "correspondences_out"
const int k = 1;
std::vector<int> k_indices (k);
std::vector<float> k_squared_distances (k);
for (size_t i = 0; i < source->size (); ++i)
{
descriptor_kdtree.nearestKSearch (*source, i, k, k_indices, k_squared_distances);
correspondences[i] = k_indices[0];
}
cout << "OK" << endl;
}
示例14:
template <typename PointT> void
pcl::SupervoxelClustering<PointT>::setInputCloud (const typename pcl::PointCloud<PointT>::ConstPtr& cloud)
{
if ( cloud->size () == 0 )
{
PCL_ERROR ("[pcl::SupervoxelClustering::setInputCloud] Empty cloud set, doing nothing \n");
return;
}
input_ = cloud;
adjacency_octree_->setInputCloud (cloud);
}
示例15: publishPointCloud
void SurfelMapPublisher::publishPointCloud(const boost::shared_ptr<MapType>& map)
{
if (m_pointCloudPublisher.getNumSubscribers() == 0)
return;
typename pcl::PointCloud<PointType>::Ptr cellPointsCloud(new pcl::PointCloud<PointType>());
map->lock();
map->getCellPoints(cellPointsCloud);
map->unlock();
cellPointsCloud->header.frame_id = map->getFrameId();
cellPointsCloud->header.stamp = pcl_conversions::toPCL(map->getLastUpdateTimestamp());
m_pointCloudPublisher.publish(cellPointsCloud);
ROS_DEBUG_STREAM("publishing cell points: " << cellPointsCloud->size());
}