GithubHelp home page GithubHelp logo

Comments (6)

gtinchev avatar gtinchev commented on May 24, 2024 1

The example by @jspricke is wrong.
It should be:
bb_filter.setHullCloud(surface_hull);

As one should be using the points after the reconstruction.

from pcl.

jspricke avatar jspricke commented on May 24, 2024

Hi,

could you please provide a minimal test case, so we can reproduce thid?

Thanks

Jochen

from pcl.

pseandersson avatar pseandersson commented on May 24, 2024

// As a main cloud "cloud" 0000002.txt is used from KITTI Benchmark 2011_09_26_drive_0001
// available at http://www.cvlibs.net/datasets/kitti/raw_data.php
/* getBoundingBox(...)->points()
22.9035 7.80552 -1.79216
27.4452 7.61189 -1.79216
27.5215 9.40126 -1.79216
22.9798 9.59489 -1.79216
22.9035 7.80552 -1.79216 // Duplicate of row 1
22.9035 7.80552 0.483439
27.4452 7.61189 0.483439
27.5215 9.40126 0.483439
22.9798 9.59489 0.483439
22.9035 7.80552 0.483439 // Duplicate of row 6
*/
pcl::PointCloudpcl::PointXYZ::Ptr boundingbox_ptr, surface_hull (new pcl::PointCloudpcl::PointXYZ);
boundingbox_ptr = getBoundingBox(...);

pcl::ConvexHullpcl::PointXYZ hull;
hull.setInputCloud(boundingbox_ptr);
hull.setDimension(3);
std::vectorpcl::Vertices polygons;
hull.reconstruct(*surface_hull,polygons);

pcl::PointCloudpcl::PointXYZ::Ptr objects (new pcl::PointCloudpcl::PointXYZ);
pcl::CropHullpcl::PointXYZ bb_filter;

bb_filter.setDim(3);
bb_filter.setInputCloud(cloud);
bb_filter.setHullIndices(polygons);
bb_filter.setHullCloud(boundingbox_ptr);
bb_filter.filter(*objects);

from pcl.

jspricke avatar jspricke commented on May 24, 2024

Here is a minimal example:

#include <iostream>

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/surface/convex_hull.h>
#include <pcl/filters/crop_hull.h>

int main()
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  cloud->push_back(pcl::PointXYZ(25.587, 7.8600001, 0.29100001));
  cloud->push_back(pcl::PointXYZ(24.372999, 8.5909996, 0.28799999));

  pcl::PointCloud<pcl::PointXYZ>::Ptr boundingbox_ptr (new pcl::PointCloud<pcl::PointXYZ>);
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9035, 7.80552, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.4452, 7.61189, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.5215, 9.40126, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9798, 9.59489, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9035, 7.80552, 0.483439));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.4452, 7.61189, 0.483439));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.5215, 9.40126, 0.483439));
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9798, 9.59489, 0.483439));

  pcl::ConvexHull<pcl::PointXYZ> hull;
  hull.setInputCloud(boundingbox_ptr);
  hull.setDimension(3);
  std::vector<pcl::Vertices> polygons;

  pcl::PointCloud<pcl::PointXYZ>::Ptr surface_hull (new pcl::PointCloud<pcl::PointXYZ>);
  hull.reconstruct(*surface_hull, polygons);

  for(int i = 0; i < polygons.size(); i++)
    std::cout << polygons[i] << std::endl;

  pcl::PointCloud<pcl::PointXYZ>::Ptr objects (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::CropHull<pcl::PointXYZ> bb_filter;

  bb_filter.setDim(3);
  bb_filter.setInputCloud(cloud);
  bb_filter.setHullIndices(polygons);
  bb_filter.setHullCloud(boundingbox_ptr);
  bb_filter.filter(*objects);
  std::cout << objects->size() << std::endl;

  boundingbox_ptr->clear();
  objects->clear();

  boundingbox_ptr->push_back(pcl::PointXYZ(22.9035, 7.80552, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.4452, 7.61189, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.5215, 9.40126, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9798, 9.59489, -1.79216));
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9035, 7.80552, -1.79216)); // Duplicate of row 1
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9035, 7.80552, 0.483439));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.4452, 7.61189, 0.483439));
  boundingbox_ptr->push_back(pcl::PointXYZ(27.5215, 9.40126, 0.483439));
  boundingbox_ptr->push_back(pcl::PointXYZ(22.9798, 9.59489, 0.483439));

  bb_filter.setHullCloud(boundingbox_ptr);
  bb_filter.filter(*objects);
  std::cout << objects->size() << std::endl;
}

Problem seems to be that the indices in polygons don't correspond to the ones in boundingbox_ptr.

from pcl.

rbrusu avatar rbrusu commented on May 24, 2024

Is there any follow up needed on this issue?

from pcl.

rbrusu avatar rbrusu commented on May 24, 2024

Closed due to lack of activity.

from pcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.