Class Octree
java.lang.Object
org.opencv.ptcloud.Octree
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
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Octree__fromPtr__(long addr) voidclear()Reset all octree parameter.static OctreecreateWithDepth(int maxDepth, double size) Creates an empty Octree with given maximum depthstatic OctreecreateWithDepth(int maxDepth, double size, Point3 origin) Creates an empty Octree with given maximum depthstatic OctreecreateWithDepth(int maxDepth, double size, Point3 origin, boolean withColors) Creates an empty Octree with given maximum depthstatic OctreecreateWithDepth(int maxDepth, Mat pointCloud) Create an Octree from the PointCloud data with the specific maxDepthstatic OctreecreateWithDepth(int maxDepth, Mat pointCloud, Mat colors) Create an Octree from the PointCloud data with the specific maxDepthstatic OctreecreateWithResolution(double resolution, double size) Creates an empty Octree with given resolutionstatic OctreecreateWithResolution(double resolution, double size, Point3 origin) Creates an empty Octree with given resolutionstatic OctreecreateWithResolution(double resolution, double size, Point3 origin, boolean withColors) Creates an empty Octree with given resolutionstatic OctreecreateWithResolution(double resolution, Mat pointCloud) Create an Octree from the PointCloud data with the specific resolutionstatic OctreecreateWithResolution(double resolution, Mat pointCloud, Mat colors) Create an Octree from the PointCloud data with the specific resolutionbooleandeletePoint(Point3 point) Delete a given point from the Octree.booleanempty()longvoidgetPointCloudByOctree(Mat restoredPointCloud) restore point cloud data from Octree.voidgetPointCloudByOctree(Mat restoredPointCloud, Mat restoredColor) restore point cloud data from Octree.booleaninsertPoint(Point3 point) Insert a point data with color to a OctreeNode.booleaninsertPoint(Point3 point, Point3 color) Insert a point data with color to a OctreeNode.booleanisPointInBound(Point3 point) Determine whether the point is within the space range of the specific cube.voidK Nearest Neighbor Search in Octree.voidK Nearest Neighbor Search in Octree.voidK Nearest Neighbor Search in Octree.intradiusNNSearch(Point3 query, float radius, Mat points) Radius Nearest Neighbor Search in Octree.intradiusNNSearch(Point3 query, float radius, Mat points, Mat squareDists) Radius Nearest Neighbor Search in Octree.intradiusNNSearch(Point3 query, float radius, Mat points, Mat colors, Mat squareDists) Radius Nearest Neighbor Search in Octree.
-
Field Details
-
nativeObj
protected final long nativeObj
-
-
Constructor Details
-
Octree
protected Octree(long addr)
-
-
Method Details
-
getNativeObjAddr
public long getNativeObjAddr() -
__fromPtr__
-
createWithDepth
Creates an empty Octree with given maximum depth- Parameters:
maxDepth- The max depth of the Octreesize- bounding box size for the Octreeorigin- Initial center coordinatewithColors- Whether to keep per-point colors or not- Returns:
- resulting Octree
-
createWithDepth
-
createWithDepth
Creates an empty Octree with given maximum depth- Parameters:
maxDepth- The max depth of the Octreesize- bounding box size for the Octree- Returns:
- resulting Octree
-
createWithDepth
Create an Octree from the PointCloud data with the specific maxDepth- Parameters:
maxDepth- Max depth of the octreepointCloud- point cloud data, should be 3-channel float arraycolors- color attribute of point cloud in the same 3-channel float format- Returns:
- resulting Octree
-
createWithDepth
-
createWithResolution
public static Octree createWithResolution(double resolution, double size, Point3 origin, boolean withColors) Creates an empty Octree with given resolution- Parameters:
resolution- The size of the octree leaf nodesize- bounding box size for the Octreeorigin- Initial center coordinatewithColors- Whether to keep per-point colors or not- Returns:
- resulting Octree
-
createWithResolution
-
createWithResolution
Creates an empty Octree with given resolution- Parameters:
resolution- The size of the octree leaf nodesize- bounding box size for the Octree- Returns:
- resulting Octree
-
createWithResolution
Create an Octree from the PointCloud data with the specific resolution- Parameters:
resolution- The size of the octree leaf nodepointCloud- point cloud data, should be 3-channel float arraycolors- color attribute of point cloud in the same 3-channel float format- Returns:
- resulting octree
-
createWithResolution
-
insertPoint
-
insertPoint
Insert a point data with color to a OctreeNode.- Parameters:
point- The point data in Point3f format.- Returns:
- Returns whether the insertion is successful.
-
isPointInBound
Determine whether the point is within the space range of the specific cube.- Parameters:
point- The point coordinates.- Returns:
- If point is in bound, return ture. Otherwise, false.
-
empty
public boolean empty() -
clear
public void clear()Reset all octree parameter. Clear all the nodes of the octree and initialize the parameters. -
deletePoint
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:
point- The point coordinates, comparison is epsilon-based- Returns:
- return ture if the point is deleted successfully.
-
getPointCloudByOctree
restore point cloud data from Octree. Restore the point cloud data from existing octree. The points in same leaf node will be seen as the same point. This point is the center of the leaf node. If the resolution is small, it will work as a downSampling function.- Parameters:
restoredPointCloud- The output point cloud data, can be replaced by noArray() if not neededrestoredColor- The color attribute of point cloud data, can be omitted if not needed
-
getPointCloudByOctree
restore point cloud data from Octree. Restore the point cloud data from existing octree. The points in same leaf node will be seen as the same point. This point is the center of the leaf node. If the resolution is small, it will work as a downSampling function.- Parameters:
restoredPointCloud- The output point cloud data, can be replaced by noArray() if not needed
-
radiusNNSearch
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:
query- Query point.radius- Retrieved radius value.points- Point output. Contains searched points in 3-float format, and output vector is not in order, can be replaced by noArray() if not neededsquareDists- Dist output. Contains searched squared distance in floats, and output vector is not in order, can be omitted if not needed- Returns:
- the number of searched points.
-
radiusNNSearch
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:
query- Query point.radius- Retrieved radius value.points- Point output. Contains searched points in 3-float format, and output vector is not in order, can be replaced by noArray() if not needed can be omitted if not needed- Returns:
- the number of searched points.
-
radiusNNSearch
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:
query- Query point.radius- Retrieved radius value.points- Point output. Contains searched points in 3-float format, and output vector is not in order, can be replaced by noArray() if not neededcolors- Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not neededsquareDists- Dist output. Contains searched squared distance in floats, and output vector is not in order, can be replaced by noArray() if not needed- Returns:
- the number of searched points.
-
KNNSearch
K Nearest Neighbor Search in Octree. Find the K nearest neighbors to the query point.- Parameters:
query- Query point.K- amount of nearest neighbors to findpoints- Point output. Contains K points in 3-float format, arranged in order of distance from near to far, can be replaced by noArray() if not neededsquareDists- Dist output. Contains K squared distance in floats, arranged in order of distance from near to far, can be omitted if not needed
-
KNNSearch
K Nearest Neighbor Search in Octree. Find the K nearest neighbors to the query point.- Parameters:
query- Query point.K- amount of nearest neighbors to findpoints- Point output. Contains K points in 3-float format, arranged in order of distance from near to far, can be replaced by noArray() if not needed can be omitted if not needed
-
KNNSearch
K Nearest Neighbor Search in Octree. Find the K nearest neighbors to the query point.- Parameters:
query- Query point.K- amount of nearest neighbors to findpoints- Point output. Contains K points in 3-float format, arranged in order of distance from near to far, can be replaced by noArray() if not neededcolors- Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not neededsquareDists- Dist output. Contains K squared distance in floats, arranged in order of distance from near to far, can be replaced by noArray() if not needed
-