Point-cloud sampling and segmentation#
Detailed Description#
Classes#
Name |
Description |
|---|---|
|
Region Growing algorithm in 3D point cloud. View details |
|
Sample Consensus algorithm segmentation of 3D point cloud model. View details |
Enumerations#
enum cv::SacMethod {
cv::SAC_METHOD_RANSAC
}type of the robust estimation algorithm View details
Enumeration Type Documentation#
SacMethod#
enum cv::SacMethod
#include <opencv2/geometry/segment.hpp>
type of the robust estimation algorithm
Enumerator:
|
The RANSAC algorithm described in [104]. |
SacModelType#
enum cv::SacModelType
#include <opencv2/geometry/segment.hpp>
Enumerator:
|
The 3D PLANE model coefficients in list [a, b, c, d], corresponding to the coefficients of equation \( ax + by + cz + d = 0 \). |
|
The 3D SPHERE model coefficients in list [center_x, center_y, center_z, radius], corresponding to the coefficients of equation \( (x - center\_x)^2 + (y - center\_y)^2 + (z - center\_z)^2 = radius^2 \). |
Function Documentation#
farthestPointSampling()#
int cv::farthestPointSampling(
OutputArray sampled_point_flags,
InputArray input_pts,
float sampled_scale,
float dist_lower_limit = 0,
RNG * rng = nullptr )
#include <opencv2/geometry/segment.hpp>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameters
sampled_point_flags— Flags of the sampled point, (pass in std::vectoror std::vector etc.) sampled_point_flags[i] is 1 means i-th point selected, 0 means it is not selected. input_pts— Original point cloud, vector of Point3 or Mat of size Nx3/3xN.sampled_scale— Range (0, 1), the percentage of the sampled point cloud to the original size, that is, sampled size = original size * sampled_scale.dist_lower_limit— Sampling is terminated early if the distance from the farthest point to S is less than dist_lower_limit, default 0.rng— Optional random number generator used for selecting seed point for FPS; if it is nullptr, theRNG () is used instead.
Returns
The number of points actually sampled.
farthestPointSampling()#
int cv::farthestPointSampling(
OutputArray sampled_point_flags,
InputArray input_pts,
int sampled_pts_size,
float dist_lower_limit = 0,
RNG * rng = nullptr )
#include <opencv2/geometry/segment.hpp>
Point cloud sampling by Farthest Point Sampling(FPS).
FPS Algorithm:
Input: Point cloud C, sampled_pts_size, dist_lower_limit
Initialize: Set sampled point cloud S to the empty set
Step:
Randomly take a seed point from C and take it from C to S;
Find a point in C that is the farthest away from S and take it from C to S; (The distance from point to set S is the smallest distance from point to all points in S)
Repeat step 2 until the farthest distance of the point in C from S is less than dist_lower_limit, or the size of S is equal to sampled_pts_size.
Output: Sampled point cloud S
Parameters
sampled_point_flags— Flags of the sampled point, (pass in std::vectoror std::vector etc.) sampled_point_flags[i] is 1 means i-th point selected, 0 means it is not selected. input_pts— Original point cloud, vector of Point3 or Mat of size Nx3/3xN.sampled_pts_size— The desired point cloud size after sampling.dist_lower_limit— Sampling is terminated early if the distance from the farthest point to S is less than dist_lower_limit, default 0.rng— Optional random number generator used for selecting seed point for FPS; if it is nullptr, theRNG () is used instead.
Returns
The number of points actually sampled.
normalEstimate()#
void cv::normalEstimate(
OutputArray normals,
OutputArray curvatures,
InputArray input_pts,
InputArrayOfArrays nn_idx,
int max_neighbor_num = 0 )
#include <opencv2/geometry/segment.hpp>
Estimate the normal and curvature of each point in point cloud from NN results.
Normal estimation by PCA:
Input: Nearest neighbor points of a specific point: \( pt\_set \)
Step:
Calculate the \( mean(\bar{x},\bar{y},\bar{z}) \) of \( pt\_set \);
A 3x3 covariance matrix \( cov \) is obtained by \( mean^T \cdot mean \);
Calculate the eigenvalues( \( λ_2 \ge λ_1 \ge λ_0 \)) and corresponding eigenvectors( \( v_2, v_1, v_0 \)) of \( cov \);
\( v0 \) is the normal of the specific point, \( \frac{λ_0}{λ_0 + λ_1 + λ_2} \) is the curvature of the specific point;
Output: Normal and curvature of the specific point.
Parameters
normals— Normal of each point, support vectorand Mat of size Nx3. curvatures— Curvature of each point, support vectorand Mat. input_pts— Original point cloud, support vectorand Mat of size Nx3/3xN. nn_idx— Index information of nearest neighbors of all points. The first nearest neighbor of each point is itself. Support vector<vector>, vector and Mat of size NxK. If the information in a row is [0, 2, 1, -5, -1, 4, 7 … negative number], it will use only non-negative indexes until it meets a negative number or bound of this row i.e. [0, 2, 1]. max_neighbor_num— The maximum number of neighbors want to use including itself. Setting to a non-positive number or default will use the information from nn_idx.
randomSampling()#
void cv::randomSampling(
OutputArray sampled_pts,
InputArray input_pts,
float sampled_scale,
RNG * rng = nullptr )
#include <opencv2/geometry/segment.hpp>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameters
sampled_pts— Point cloud after sampling. Support cv::Mat(size * sampled_scale, 3, CV_32F), std::vector<cv::Point3f>.input_pts— Original point cloud, vector of Point3 or Mat of size Nx3/3xN.sampled_scale— Range (0, 1), the percentage of the sampled point cloud to the original size, that is, sampled size = original size * sampled_scale.rng— Optional random number generator used for cv::randShuffle; if it is nullptr, theRNG () is used instead.
randomSampling()#
void cv::randomSampling(
OutputArray sampled_pts,
InputArray input_pts,
int sampled_pts_size,
RNG * rng = nullptr )
#include <opencv2/geometry/segment.hpp>
Point cloud sampling by randomly select points.
Use cv::randShuffle to shuffle the point index list, then take the points corresponding to the front part of the list.
Parameters
sampled_pts— Point cloud after sampling. Support cv::Mat(sampled_pts_size, 3, CV_32F), std::vector<cv::Point3f>.input_pts— Original point cloud, vector of Point3 or Mat of size Nx3/3xN.sampled_pts_size— The desired point cloud size after sampling.rng— Optional random number generator used for cv::randShuffle; if it is nullptr, theRNG () is used instead.
voxelGridSampling()#
int cv::voxelGridSampling(
OutputArray sampled_point_flags,
InputArray input_pts,
float length,
float width,
float height )
#include <opencv2/geometry/segment.hpp>
Point cloud sampling by Voxel Grid filter downsampling.
Creates a 3D voxel grid (a set of tiny 3D boxes in space) over the input point cloud data, in each voxel (i.e., 3D box), all the points present will be approximated (i.e., downsampled) with the point closest to their centroid.
Parameters
sampled_point_flags— Flags of the sampled point, (pass in std::vectoror std::vector etc.) sampled_point_flags[i] is 1 means i-th point selected, 0 means it is not selected. input_pts— Original point cloud, vector of Point3 or Mat of size Nx3/3xN.length— Grid length.width— Grid width.height— Grid height.
Returns
The number of points actually sampled.