Octree
import { Octree } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Native object: release it with using or delete(). Factories can return null; check before calling methods.
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
Constructors and members
static createWithDepth
Creates an empty Octree with given maximum depth
createWithDepth(maxDepth: number, size: number, origin: Point3f, withColors: boolean): Octree | null;3 available overloads
createWithDepth(maxDepth: number, size: number): Octree | null;createWithDepth(maxDepth: number, size: number, origin: Point3f): Octree | null;createWithDepth(maxDepth: number, size: number, origin: Point3f, withColors: boolean): Octree | null;maxDepthThe max depth of the Octree
sizebounding box size for the Octree
originInitial center coordinate
withColorsWhether to keep per-point colors or not
resulting Octree
static createWithDepth1
Create an Octree from the PointCloud data with the specific maxDepth
createWithDepth1(maxDepth: number, pointCloud: Mat, colors: Mat): Octree | null;2 available overloads
createWithDepth1(maxDepth: number, pointCloud: Mat): Octree | null;createWithDepth1(maxDepth: number, pointCloud: Mat, colors: Mat): Octree | null;maxDepthMax depth of the octree
pointCloudpoint cloud data, should be 3-channel float array
colorscolor attribute of point cloud in the same 3-channel float format
resulting Octree
static createWithResolution
Creates an empty Octree with given resolution
createWithResolution(resolution: number, size: number, origin: Point3f, withColors: boolean): Octree | null;3 available overloads
createWithResolution(resolution: number, size: number): Octree | null;createWithResolution(resolution: number, size: number, origin: Point3f): Octree | null;createWithResolution(resolution: number, size: number, origin: Point3f, withColors: boolean): Octree | null;resolutionThe size of the octree leaf node
sizebounding box size for the Octree
originInitial center coordinate
withColorsWhether to keep per-point colors or not
resulting Octree
static createWithResolution1
Create an Octree from the PointCloud data with the specific resolution
createWithResolution1(resolution: number, pointCloud: Mat, colors: Mat): Octree | null;2 available overloads
createWithResolution1(resolution: number, pointCloud: Mat): Octree | null;createWithResolution1(resolution: number, pointCloud: Mat, colors: Mat): Octree | null;resolutionThe size of the octree leaf node
pointCloudpoint cloud data, should be 3-channel float array
colorscolor attribute of point cloud in the same 3-channel float format
resulting octree
clone
Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.
clone(): this;The this result.
insertPoint
Insert a point data with color to a OctreeNode.
insertPoint(point: Point3f, color: Point3f): boolean;2 available overloads
insertPoint(point: Point3f): boolean;insertPoint(point: Point3f, color: Point3f): boolean;pointThe point data in Point3f format.
colorThe color attribute of point in Point3f format.
Returns whether the insertion is successful.
isPointInBound
Determine whether the point is within the space range of the specific cube.
isPointInBound(point: Point3f): boolean;pointThe point coordinates.
If point is in bound, return ture. Otherwise, false.
empty
returns true if the rootnode is NULL.
empty(): boolean;The boolean result.
clear
Reset all octree parameter.
Clear all the nodes of the octree and initialize the parameters.
clear(): void;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.
deletePoint(point: Point3f): boolean;pointThe point coordinates, comparison is epsilon-based
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.
getPointCloudByOctree(restoredPointCloud: Mat, restoredColor: Mat): void;2 available overloads
getPointCloudByOctree(restoredPointCloud: Mat): void;getPointCloudByOctree(restoredPointCloud: Mat, restoredColor: Mat): void;restoredPointCloudOutput destination, filled by the native operation. The output point cloud data, can be replaced by noArray() if not needed
restoredColorOutput destination, filled by the native operation. The color attribute of point cloud data, can be omitted 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.
radiusNNSearch(query: Point3f, radius: number, points: Mat, squareDists: Mat): number;2 available overloads
radiusNNSearch(query: Point3f, radius: number, points: Mat): number;radiusNNSearch(query: Point3f, radius: number, points: Mat, squareDists: Mat): number;queryQuery point.
radiusRetrieved radius value.
pointsOutput destination, filled by the native operation. Point output. Contains searched points in 3-float format, and output vector is not in order, can be replaced by noArray() if not needed
squareDistsOutput destination, filled by the native operation. Dist output. Contains searched squared distance in floats, and output vector is not in order, can be omitted if not needed
the number of searched points.
radiusNNSearch1
Radius Nearest Neighbor Search in Octree.
Search all points that are less than or equal to radius. And return the number of searched points.
radiusNNSearch1(query: Point3f, radius: number, points: Mat, colors: Mat, squareDists: Mat): number;queryQuery point.
radiusRetrieved radius value.
pointsOutput destination, filled by the native operation. Point output. Contains searched points in 3-float format, and output vector is not in order, can be replaced by noArray() if not needed
colorsOutput destination, filled by the native operation. Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not needed
squareDistsOutput destination, filled by the native operation. Dist output. Contains searched squared distance in floats, and output vector is not in order, can be replaced by noArray() if not needed
the number of searched points.
KNNSearch
K Nearest Neighbor Search in Octree.
Find the K nearest neighbors to the query point.
KNNSearch(query: Point3f, K: number, points: Mat, squareDists: Mat): void;2 available overloads
KNNSearch(query: Point3f, K: number, points: Mat): void;KNNSearch(query: Point3f, K: number, points: Mat, squareDists: Mat): void;queryQuery point.
Kamount of nearest neighbors to find
pointsOutput destination, filled by the native operation. 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
squareDistsOutput destination, filled by the native operation. Dist output. Contains K squared distance in floats, arranged in order of distance from near to far, can be omitted if not needed
KNNSearch1
K Nearest Neighbor Search in Octree.
Find the K nearest neighbors to the query point.
KNNSearch1(query: Point3f, K: number, points: Mat, colors: Mat, squareDists: Mat): void;queryQuery point.
Kamount of nearest neighbors to find
pointsOutput destination, filled by the native operation. 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
colorsOutput destination, filled by the native operation. Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not needed
squareDistsOutput destination, filled by the native operation. 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
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.