PCL apply filter on octree without cloud copy
up vote
0
down vote
favorite
I have huge point cloud, and I want to apply voxelGrid on it. But since the point cloud is too big, I have error such as "[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow"
. So I wanted to build an octree first from my pointcloud, and then apply the filter on each leaf (i.e apply the filter on the pointcloud with the good index)
The problem occurs here, when I apply the filter, PCL wants me to chose a PointCloud in which it will be saved, and the original point cloud is substituted with the result of the filter. I would like to know if it is possible to modify the filter so that it doesn't remove the points, but only put to (0,0,0) the points at the index in the pointcloud that must be removed?
My code :
void Octree::applyExample(float x, float y, float z) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 100000;
cloud->height = 1;
cloud->is_dense = false;
cloud->points.resize(cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size(); ++i)
{
cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}
octree.setInputCloud(cloud);
octree.addPointsFromInputCloud();
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it;
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it_end = octree.leaf_end();
for (it = octree.leaf_begin(); it != it_end; ++it)
{
pcl::IndicesPtr indexVector(new vector<int>);
pcl::octree::OctreeContainerPointIndices& container = it.getLeafContainer();
container.getPointIndices(*indexVector);
FILTREexample(cloud, indexVector, x, y, z);
}
}
and filter :
void FILTREexample(pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud, pcl::IndicesPtr indices, float x, float y, float z) {
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(pointcloud);
sor.setIndices(indices);
sor.setLeafSize(x, y, z);
sor.filter(*pointcloud); //The problem occurs here
//Everytime, the pointcloud is substituted with the result of the filter, but I'd like to still have my "entire" pointcloud, but either with the filtered point deleted, or the filtered point put to 0,0,0.
}
Would it be possible to do such a thing?
c++ point-cloud-library
add a comment |
up vote
0
down vote
favorite
I have huge point cloud, and I want to apply voxelGrid on it. But since the point cloud is too big, I have error such as "[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow"
. So I wanted to build an octree first from my pointcloud, and then apply the filter on each leaf (i.e apply the filter on the pointcloud with the good index)
The problem occurs here, when I apply the filter, PCL wants me to chose a PointCloud in which it will be saved, and the original point cloud is substituted with the result of the filter. I would like to know if it is possible to modify the filter so that it doesn't remove the points, but only put to (0,0,0) the points at the index in the pointcloud that must be removed?
My code :
void Octree::applyExample(float x, float y, float z) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 100000;
cloud->height = 1;
cloud->is_dense = false;
cloud->points.resize(cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size(); ++i)
{
cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}
octree.setInputCloud(cloud);
octree.addPointsFromInputCloud();
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it;
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it_end = octree.leaf_end();
for (it = octree.leaf_begin(); it != it_end; ++it)
{
pcl::IndicesPtr indexVector(new vector<int>);
pcl::octree::OctreeContainerPointIndices& container = it.getLeafContainer();
container.getPointIndices(*indexVector);
FILTREexample(cloud, indexVector, x, y, z);
}
}
and filter :
void FILTREexample(pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud, pcl::IndicesPtr indices, float x, float y, float z) {
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(pointcloud);
sor.setIndices(indices);
sor.setLeafSize(x, y, z);
sor.filter(*pointcloud); //The problem occurs here
//Everytime, the pointcloud is substituted with the result of the filter, but I'd like to still have my "entire" pointcloud, but either with the filtered point deleted, or the filtered point put to 0,0,0.
}
Would it be possible to do such a thing?
c++ point-cloud-library
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have huge point cloud, and I want to apply voxelGrid on it. But since the point cloud is too big, I have error such as "[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow"
. So I wanted to build an octree first from my pointcloud, and then apply the filter on each leaf (i.e apply the filter on the pointcloud with the good index)
The problem occurs here, when I apply the filter, PCL wants me to chose a PointCloud in which it will be saved, and the original point cloud is substituted with the result of the filter. I would like to know if it is possible to modify the filter so that it doesn't remove the points, but only put to (0,0,0) the points at the index in the pointcloud that must be removed?
My code :
void Octree::applyExample(float x, float y, float z) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 100000;
cloud->height = 1;
cloud->is_dense = false;
cloud->points.resize(cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size(); ++i)
{
cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}
octree.setInputCloud(cloud);
octree.addPointsFromInputCloud();
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it;
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it_end = octree.leaf_end();
for (it = octree.leaf_begin(); it != it_end; ++it)
{
pcl::IndicesPtr indexVector(new vector<int>);
pcl::octree::OctreeContainerPointIndices& container = it.getLeafContainer();
container.getPointIndices(*indexVector);
FILTREexample(cloud, indexVector, x, y, z);
}
}
and filter :
void FILTREexample(pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud, pcl::IndicesPtr indices, float x, float y, float z) {
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(pointcloud);
sor.setIndices(indices);
sor.setLeafSize(x, y, z);
sor.filter(*pointcloud); //The problem occurs here
//Everytime, the pointcloud is substituted with the result of the filter, but I'd like to still have my "entire" pointcloud, but either with the filtered point deleted, or the filtered point put to 0,0,0.
}
Would it be possible to do such a thing?
c++ point-cloud-library
I have huge point cloud, and I want to apply voxelGrid on it. But since the point cloud is too big, I have error such as "[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow"
. So I wanted to build an octree first from my pointcloud, and then apply the filter on each leaf (i.e apply the filter on the pointcloud with the good index)
The problem occurs here, when I apply the filter, PCL wants me to chose a PointCloud in which it will be saved, and the original point cloud is substituted with the result of the filter. I would like to know if it is possible to modify the filter so that it doesn't remove the points, but only put to (0,0,0) the points at the index in the pointcloud that must be removed?
My code :
void Octree::applyExample(float x, float y, float z) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 100000;
cloud->height = 1;
cloud->is_dense = false;
cloud->points.resize(cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size(); ++i)
{
cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}
octree.setInputCloud(cloud);
octree.addPointsFromInputCloud();
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it;
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it_end = octree.leaf_end();
for (it = octree.leaf_begin(); it != it_end; ++it)
{
pcl::IndicesPtr indexVector(new vector<int>);
pcl::octree::OctreeContainerPointIndices& container = it.getLeafContainer();
container.getPointIndices(*indexVector);
FILTREexample(cloud, indexVector, x, y, z);
}
}
and filter :
void FILTREexample(pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud, pcl::IndicesPtr indices, float x, float y, float z) {
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(pointcloud);
sor.setIndices(indices);
sor.setLeafSize(x, y, z);
sor.filter(*pointcloud); //The problem occurs here
//Everytime, the pointcloud is substituted with the result of the filter, but I'd like to still have my "entire" pointcloud, but either with the filtered point deleted, or the filtered point put to 0,0,0.
}
Would it be possible to do such a thing?
c++ point-cloud-library
c++ point-cloud-library
asked yesterday
Raph Schim
17915
17915
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265873%2fpcl-apply-filter-on-octree-without-cloud-copy%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password