OpenCV 5.0.0
Open Source Computer Vision
Loading...
Searching...
No Matches
_3d

Detailed Description

Classes

class  cv::RegionGrowing3D
 Region Growing algorithm in 3D point cloud. More...
class  cv::SACSegmentation
 Sample Consensus algorithm segmentation of 3D point cloud model. More...

Enumerations

enum  cv::SacMethod { cv::SAC_METHOD_RANSAC }
 type of the robust estimation algorithm More...
enum  cv::SacModelType {
  cv::SAC_MODEL_PLANE ,
  cv::SAC_MODEL_SPHERE
}

Functions

int cv::farthestPointSampling (OutputArray sampled_point_flags, InputArray input_pts, float sampled_scale, float dist_lower_limit=0, RNG *rng=nullptr)
int cv::farthestPointSampling (OutputArray sampled_point_flags, InputArray input_pts, int sampled_pts_size, float dist_lower_limit=0, RNG *rng=nullptr)
 Point cloud sampling by Farthest Point Sampling(FPS).
void cv::normalEstimate (OutputArray normals, OutputArray curvatures, InputArray input_pts, InputArrayOfArrays nn_idx, int max_neighbor_num=0)
 Estimate the normal and curvature of each point in point cloud from NN results.
void cv::randomSampling (OutputArray sampled_pts, InputArray input_pts, float sampled_scale, RNG *rng=nullptr)
void cv::randomSampling (OutputArray sampled_pts, InputArray input_pts, int sampled_pts_size, RNG *rng=nullptr)
 Point cloud sampling by randomly select points.
int cv::voxelGridSampling (OutputArray sampled_point_flags, InputArray input_pts, float length, float width, float height)
 Point cloud sampling by Voxel Grid filter downsampling.

Enumeration Type Documentation

◆ SacMethod

#include <opencv2/geometry/segment.hpp>

type of the robust estimation algorithm

Enumerator
SAC_METHOD_RANSAC 
Python: cv.SAC_METHOD_RANSAC

The RANSAC algorithm described in [fischler1981random].

◆ SacModelType

#include <opencv2/geometry/segment.hpp>

Enumerator
SAC_MODEL_PLANE 
Python: cv.SAC_MODEL_PLANE

The 3D PLANE model coefficients in list [a, b, c, d], corresponding to the coefficients of equation \( ax + by + cz + d = 0 \).

SAC_MODEL_SPHERE 
Python: cv.SAC_MODEL_SPHERE

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() [1/2]

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
[out]sampled_point_flagsFlags of the sampled point, (pass in std::vector<int> or std::vector<char> etc.) sampled_point_flags[i] is 1 means i-th point selected, 0 means it is not selected.
input_ptsOriginal point cloud, vector of Point3 or Mat of size Nx3/3xN.
sampled_scaleRange (0, 1), the percentage of the sampled point cloud to the original size, that is, sampled size = original size * sampled_scale.
dist_lower_limitSampling is terminated early if the distance from the farthest point to S is less than dist_lower_limit, default 0.
rngOptional 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() [2/2]

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:
    1. Randomly take a seed point from C and take it from C to S;
    2. 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)
    3. 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
[out]sampled_point_flagsFlags of the sampled point, (pass in std::vector<int> or std::vector<char> etc.) sampled_point_flags[i] is 1 means i-th point selected, 0 means it is not selected.
input_ptsOriginal point cloud, vector of Point3 or Mat of size Nx3/3xN.
sampled_pts_sizeThe desired point cloud size after sampling.
dist_lower_limitSampling is terminated early if the distance from the farthest point to S is less than dist_lower_limit, default 0.
rngOptional 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:
    1. Calculate the \( mean(\bar{x},\bar{y},\bar{z}) \) of \( pt\_set \);
    2. A 3x3 covariance matrix \( cov \) is obtained by \( mean^T \cdot mean \);
    3. Calculate the eigenvalues( \( λ_2 \ge λ_1 \ge λ_0 \)) and corresponding eigenvectors( \( v_2, v_1, v_0 \)) of \( cov \);
    4. \( 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
[out]normalsNormal of each point, support vector<Point3f> and Mat of size Nx3.
[out]curvaturesCurvature of each point, support vector<float> and Mat.
input_ptsOriginal point cloud, support vector<Point3f> and Mat of size Nx3/3xN.
nn_idxIndex information of nearest neighbors of all points. The first nearest neighbor of each point is itself. Support vector<vector<int>>, vector<Mat> 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_numThe 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() [1/2]

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_ptsPoint cloud after sampling. Support cv::Mat(size * sampled_scale, 3, CV_32F), std::vector<cv::Point3f>.
input_ptsOriginal point cloud, vector of Point3 or Mat of size Nx3/3xN.
sampled_scaleRange (0, 1), the percentage of the sampled point cloud to the original size, that is, sampled size = original size * sampled_scale.
rngOptional random number generator used for cv::randShuffle; if it is nullptr, theRNG () is used instead.

◆ randomSampling() [2/2]

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_ptsPoint cloud after sampling. Support cv::Mat(sampled_pts_size, 3, CV_32F), std::vector<cv::Point3f>.
input_ptsOriginal point cloud, vector of Point3 or Mat of size Nx3/3xN.
sampled_pts_sizeThe desired point cloud size after sampling.
rngOptional 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
[out]sampled_point_flagsFlags of the sampled point, (pass in std::vector<int> or std::vector<char> etc.) sampled_point_flags[i] is 1 means i-th point selected, 0 means it is not selected.
input_ptsOriginal point cloud, vector of Point3 or Mat of size Nx3/3xN.
lengthGrid length.
widthGrid width.
heightGrid height.
Returns
The number of points actually sampled.