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?










share|improve this question


























    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?










    share|improve this question
























      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      Raph Schim

      17915




      17915





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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




















































































          Popular posts from this blog

          mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?