OpenCV  5.0.0-pre
Open Source Computer Vision
Public Member Functions | Protected Attributes | List of all members
cv::Octree Class Reference

Octree for 3D vision. More...

#include <opencv2/3d.hpp>

Public Member Functions

 Octree ()
 Default constructor. More...
 
 Octree (int maxDepth)
 Create an empty Octree and set the maximum depth. More...
 
 Octree (const std::vector< Point3f > &pointCloud, int maxDepth)
 Create an Octree from the PointCloud data with the specific max depth. More...
 
 Octree (int maxDepth, double size, const Point3f &origin)
 Create an empty Octree. More...
 
 ~Octree ()
 Default destructor. More...
 
void clear ()
 Reset all octree parameter. More...
 
bool create (const std::vector< Point3f > &pointCloud, int maxDepth=-1)
 Read point cloud data and create OctreeNode. More...
 
bool deletePoint (const Point3f &point)
 Delete a given point from the Octree. More...
 
bool empty () const
 returns true if the rootnode is NULL. More...
 
void insertPoint (const Point3f &point)
 Insert a point data to a OctreeNode. More...
 
bool isPointInBound (const Point3f &point) const
 Determine whether the point is within the space range of the specific cube. More...
 
void KNNSearch (const Point3f &query, const int K, std::vector< Point3f > &pointSet, std::vector< float > &squareDistSet) const
 K Nearest Neighbor Search in Octree. More...
 
int radiusNNSearch (const Point3f &query, float radius, std::vector< Point3f > &pointSet, std::vector< float > &squareDistSet) const
 Radius Nearest Neighbor Search in Octree. More...
 
void setMaxDepth (int maxDepth)
 Set MaxDepth for Octree. More...
 
void setOrigin (const Point3f &origin)
 Set Origin coordinates for Octree. More...
 
void setSize (double size)
 Set Box Size for Octree. More...
 

Protected Attributes

Ptr< Impl > p
 

Detailed Description

Octree for 3D vision.

In 3D vision filed, the Octree is used to process and accelerate the pointcloud data. The class Octree represents the Octree data structure. Each Octree will have a fixed depth. The depth of Octree refers to the distance from the root node to the leaf node.All OctreeNodes will not exceed this depth.Increasing the depth will increase the amount of calculation exponentially. And the small number of depth refers low resolution of Octree. Each node contains 8 children, which are used to divide the space cube into eight parts. Each octree node represents a cube. And these eight children will have a fixed order, the order is described as follows:

For illustration, assume,

rootNode: origin == (0, 0, 0), size == 2

Then,

children[0]: origin == (0, 0, 0), size == 1

children[1]: origin == (1, 0, 0), size == 1, along X-axis next to child 0

children[2]: origin == (0, 1, 0), size == 1, along Y-axis next to child 0

children[3]: origin == (1, 1, 0), size == 1, in X-Y plane

children[4]: origin == (0, 0, 1), size == 1, along Z-axis next to child 0

children[5]: origin == (1, 0, 1), size == 1, in X-Z plane

children[6]: origin == (0, 1, 1), size == 1, in Y-Z plane

children[7]: origin == (1, 1, 1), size == 1, furthest from child 0

Constructor & Destructor Documentation

◆ Octree() [1/4]

cv::Octree::Octree ( )

Default constructor.

◆ Octree() [2/4]

cv::Octree::Octree ( int  maxDepth)
explicit

Create an empty Octree and set the maximum depth.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
maxDepthThe max depth of the Octree. The maxDepth > -1.

◆ Octree() [3/4]

cv::Octree::Octree ( const std::vector< Point3f > &  pointCloud,
int  maxDepth 
)

Create an Octree from the PointCloud data with the specific max depth.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
pointCloudPoint cloud data.
maxDepthThe max depth of the Octree.

◆ Octree() [4/4]

cv::Octree::Octree ( int  maxDepth,
double  size,
const Point3f origin 
)

Create an empty Octree.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
maxDepthMax depth.
sizeInitial Cube size.
originInitial center coordinate.

◆ ~Octree()

cv::Octree::~Octree ( )

Default destructor.

Member Function Documentation

◆ clear()

void cv::Octree::clear ( )

Reset all octree parameter.

Clear all the nodes of the octree and initialize the parameters.

◆ create()

bool cv::Octree::create ( const std::vector< Point3f > &  pointCloud,
int  maxDepth = -1 
)

Read point cloud data and create OctreeNode.

This function is only called when the octree is being created.

Parameters
pointCloudPointCloud data.
maxDepthThe max depth of the Octree.
Returns
Returns whether the creation is successful.

◆ deletePoint()

bool cv::Octree::deletePoint ( const Point3f point)

Delete a given point from the Octree.

Delete the corresponding element from the pointList in the corresponding leaf node. If the leaf node does not contain other points after deletion, this node will be deleted. In the same way, its parent node may also be deleted if its last child is deleted.

Parameters
pointThe point coordinates.
Returns
return ture if the point is deleted successfully.

◆ empty()

bool cv::Octree::empty ( ) const

returns true if the rootnode is NULL.

◆ insertPoint()

void cv::Octree::insertPoint ( const Point3f point)

Insert a point data to a OctreeNode.

Parameters
pointThe point data in Point3f format.

◆ isPointInBound()

bool cv::Octree::isPointInBound ( const Point3f point) const

Determine whether the point is within the space range of the specific cube.

Parameters
pointThe point coordinates.
Returns
If point is in bound, return ture. Otherwise, false.

◆ KNNSearch()

void cv::Octree::KNNSearch ( const Point3f query,
const int  K,
std::vector< Point3f > &  pointSet,
std::vector< float > &  squareDistSet 
) const

K Nearest Neighbor Search in Octree.

Find the K nearest neighbors to the query point.

Parameters
queryQuery point.
K
pointSetPoint output. Contains K points, arranged in order of distance from near to far.
squareDistSetDist output. Contains K squared distance, arranged in order of distance from near to far.

◆ radiusNNSearch()

int cv::Octree::radiusNNSearch ( const Point3f query,
float  radius,
std::vector< Point3f > &  pointSet,
std::vector< float > &  squareDistSet 
) const

Radius Nearest Neighbor Search in Octree.

Search all points that are less than or equal to radius. And return the number of searched points.

Parameters
queryQuery point.
radiusRetrieved radius value.
pointSetPoint output. Contains searched points, and output vector is not in order.
squareDistSetDist output. Contains searched squared distance, and output vector is not in order.
Returns
the number of searched points.

◆ setMaxDepth()

void cv::Octree::setMaxDepth ( int  maxDepth)

Set MaxDepth for Octree.

◆ setOrigin()

void cv::Octree::setOrigin ( const Point3f origin)

Set Origin coordinates for Octree.

◆ setSize()

void cv::Octree::setSize ( double  size)

Set Box Size for Octree.

Member Data Documentation

◆ p

Ptr<Impl> cv::Octree::p
protected

The documentation for this class was generated from the following file: