pcl::ConvexHull::reconstruct() not thread safe - qh_qh already defined

Created on 10 Jan 2015  路  7Comments  路  Source: PointCloudLibrary/pcl

I believe I have found a threading issue with the recontruct() function but could use some advice. According to QHull's website:

With care, you may create multiple Qhull instances, but only one thread may use qh_qh, qh_qhstat, and qhmem at a time (i.e., most of libqhull, the original C program). only one instance may be active at time.

When I create 12 threads using #pragma omp parallel for schedule(dynamic) I get qhull errors despite allocating 12 different wrapper classes like so:

Error:

QH6205 qhull error (qh_initqhull_start): qh_qh already defined.  Call qh_save_qhull() first

Wrapper function:

std::vector<tf::Point> TestStability::convexHull(const std::vector<tf::Point>& points) const
{


  std::vector<tf::Point> hull;

  pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_points(new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PointCloud<pcl::PointXYZ> chull_points;
  pcl::ConvexHull<pcl::PointXYZ> chull;

  if (points.empty()){
    ROS_ERROR("convexHull on empty set of points!");
    return hull;
  }

  for (unsigned i = 0; i < points.size(); ++i){
    pcl_points->points.push_back(pcl::PointXYZ(points[i].x(), points[i].y(), 0.0));
  }

  chull.setDimension(2);
  chull.setInputCloud(pcl_points);
  std::vector<pcl::Vertices> polygons;


  chull.reconstruct(chull_points, polygons);

  if (polygons.size() == 0){
    ROS_ERROR("Convex hull polygons are empty");
    return hull;
  } else if (polygons.size() > 1){
    ROS_WARN("Convex hull polygons are larger than 1");
  }

  for (unsigned i = 0; i < polygons[0].vertices.size(); ++i){
    int idx = polygons[0].vertices[i];
    tf::Point p(chull_points.points[idx].x,
                chull_points.points[idx].y,
                chull_points.points[idx].z);
    hull.push_back(p);
  }

  return hull;
}

The qhull error occurs when calling:

chull.reconstruct(chull_points, polygons);

bug surface

All 7 comments

Did you ever solve this issue? It seems Qhull has a new version that supports Multithreading

No I did not, I've since moved on from this project. My solution was just to use a mutex for calling this... not that great.

Well..I do need it for my code:

Reentrant Qhull was updated to support multiple threads sometime mid last year:

http://www.qhull.org/html/qh-code.htm

Will maybe need to look into replacing the routines used in PCL with libqhull_r routines

https://github.com/PointCloudLibrary/pcl/blob/master/surface/include/pcl/surface/impl/convex_hull.hpp

I obtain exactly the same issue when I try to compute boundary in parallel section...

This is really an old issue. Briefly, I try to replace every header from libqhull by libqhull_r (as it is avaible in the package I installed on my ubuntu 16.04). As excepted, it doesn't work as is. Some prototype as changed, so it doesn't compile anymore. Wait and see.

Related issue: #1618.
Related pull request: #1565.

Thanks body.

Closing this as a duplicate of #1618. Please reopen if needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zubair1502 picture zubair1502  路  5Comments

rmsalinas picture rmsalinas  路  3Comments

jacquelinekay picture jacquelinekay  路  5Comments

dooxe picture dooxe  路  3Comments

Passworteingeben picture Passworteingeben  路  3Comments