PclSharp

repository·master·Indexed 41 days ago

https://github.com/jbruening/pclsharp

C# P/Invoke bindings for the Point Cloud Library (PCL), enabling point cloud processing capabilities within the .NET ecosystem. Includes implementations such as the HeightMap2D filter for identifying local maxima in 2D height maps.

Tokens
924
Snippets
3
Records
5
Agent score
0%

What's inside PclSharp

  1. Install PclSharp via NuGet

    master

    PclSharp provides P/Invoke bindings for the Point Cloud Library (PCL) for use in C#. You can install it as a NuGet package to use PCL functionality within your C# projects.

    https://www.nuget.org/packages/PclSharp/
  2. Reference: HeightMap2D configuration methods

    master

    Methods for configuring the HeightMap2D filter parameters.

    void setGroundCoeffs(const Eigen::VectorXf &ground_coeffs);
    void setMinDistBetweenMaxima(const float &dist);
    float getMinDistBetweenMaxima();
    void setBinSize(const float &value);
    float getBinSize();
    int getMaximaNumberAfterFiltering();
  3. Use the HeightMap2D filter

    master

    The HeightMap2D<PointT> class is a filter used to identify local maxima in a 2D height map derived from a point cloud. It works by binning points into a grid (defined by bin_size_), finding the highest point in each bin, and then performing two stages of processing:

    1. Local Maxima Search: Identifies points that are higher than their immediate neighbors in the grid.
    2. Maxima Filtering: Filters the identified maxima based on a minimum distance constraint (min_dist_between_maxima_) to prevent clusters of points from being identified as multiple maxima.

    To use the filter, you must provide ground plane coefficients and then call filter().

    // Example conceptual usage of HeightMap2D
    PclSharp::filters::HeightMap2D<pcl::PointXYZ> filter;
    
    // 1. Set ground plane coefficients (normal x, y, z and offset d)
    // representing the plane equation: ax + by + cz + d = 0
    Eigen::VectorXf ground_coeffs(4);
    ground_coeffs << 0.0, 0.0, 1.0, 0.0; 
    filter.setGroundCoeffs(ground_coeffs);
    
    // 2. Configure parameters
    filter.setBinSize(0.06f);
    filter.setMinDistBetweenMaxima(0.3f);
    
    // 3. Run the filter
    filter.setInput(cloud);
    filter.filter();
    
    // 4. Retrieve results
    std::vector<int>& indices = filter.getMaximaCloudIndicesFiltered();
    int count = filter.getMaximaNumberAfterFiltering();
  4. Configure HeightMap2D parameters

    master

    The HeightMap2D filter can be tuned using the following methods:

    • setGroundCoeffs(const Eigen::VectorXf &ground_coeffs): Sets the coefficients for the ground plane. The vector must have exactly 4 elements representing the plane equation $ax + by + cz + d = 0$. The first three elements are the normal vector $(a, b, c)$ and the fourth is the offset $d$.
    • setMinDistBetweenMaxima(const float &dist): Sets the minimum distance required between identified maxima. This is useful for separating distinct objects (e.g., human heads).
    • setBinSize(const float &value): Sets the size of the 2D grid bins used to discretize the point cloud.

    Getter methods getMinDistBetweenMaxima(), getBinSize(), and getMaximaNumberAfterFiltering() are available to retrieve current settings and results.