OpenCV
5.0.0pre
Open Source Computer Vision

#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 
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 Xaxis next to child 0
children[2]: origin == (0, 1, 0), size == 1, along Yaxis next to child 0
children[3]: origin == (1, 1, 0), size == 1, in XY plane
children[4]: origin == (0, 0, 1), size == 1, along Zaxis next to child 0
children[5]: origin == (1, 0, 1), size == 1, in XZ plane
children[6]: origin == (0, 1, 1), size == 1, in YZ plane
children[7]: origin == (1, 1, 1), size == 1, furthest from child 0
cv::Octree::Octree  (  ) 
Default constructor.

explicit 
cv::Octree::Octree  (  const std::vector< Point3f > &  pointCloud, 
int  maxDepth  
) 
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.
maxDepth  Max depth. 
size  Initial Cube size. 
origin  Initial center coordinate. 
cv::Octree::~Octree  (  ) 
Default destructor.
void cv::Octree::clear  (  ) 
Reset all octree parameter.
Clear all the nodes of the octree and initialize the parameters.
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.
pointCloud  PointCloud data. 
maxDepth  The max depth of the Octree. 
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.
point  The point coordinates. 
bool cv::Octree::empty  (  )  const 
returns true if the rootnode is NULL.
void cv::Octree::insertPoint  (  const Point3f &  point  ) 
Insert a point data to a OctreeNode.
point  The point data in Point3f format. 
bool cv::Octree::isPointInBound  (  const Point3f &  point  )  const 
Determine whether the point is within the space range of the specific cube.
point  The point coordinates. 
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.
query  Query point. 
K  
pointSet  Point output. Contains K points, arranged in order of distance from near to far. 
squareDistSet  Dist output. Contains K squared distance, arranged in order of distance from near to far. 
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.
query  Query point. 
radius  Retrieved radius value. 
pointSet  Point output. Contains searched points, and output vector is not in order. 
squareDistSet  Dist output. Contains searched squared distance, and output vector is not in order. 
void cv::Octree::setMaxDepth  (  int  maxDepth  ) 
Set MaxDepth for Octree.
void cv::Octree::setSize  (  double  size  ) 
Set Box Size for Octree.

protected 