Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5c0ac37

Browse files
committed
add Octree to 3d module of next branch.
1 parent958d3e8 commit5c0ac37

File tree

4 files changed

+903
-0
lines changed

4 files changed

+903
-0
lines changed

‎modules/3d/include/opencv2/3d.hpp‎

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,151 @@ void undistortPoints(InputArray src, OutputArray dst,
23742374
InputArray R = noArray(), InputArray P = noArray(),
23752375
TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER,5,0.01));
23762376

2377+
2378+
/** @brief Octree for 3D vision.
2379+
*
2380+
* In 3D vision filed, the Octree is used to process and accelerate the pointcloud data. The class Octree represents
2381+
* the Octree data structure. Each Octree will have a fixed depth. The depth of Octree refers to the distance from
2382+
* the root node to the leaf node.All OctreeNodes will not exceed this depth.Increasing the depth will increase
2383+
* the amount of calculation exponentially. And the small number of depth refers low resolution of Octree.
2384+
* Each node contains 8 children, which are used to divide the space cube into eight parts. Each octree node represents
2385+
* a cube. And these eight children will have a fixed order, the order is described as follows:
2386+
*
2387+
* For illustration, assume,
2388+
*
2389+
* rootNode: origin == (0, 0, 0), size == 2
2390+
*
2391+
* Then,
2392+
*
2393+
* children[0]: origin == (0, 0, 0), size == 1
2394+
*
2395+
* children[1]: origin == (1, 0, 0), size == 1, along X-axis next to child 0
2396+
*
2397+
* children[2]: origin == (0, 1, 0), size == 1, along Y-axis next to child 0
2398+
*
2399+
* children[3]: origin == (1, 1, 0), size == 1, in X-Y plane
2400+
*
2401+
* children[4]: origin == (0, 0, 1), size == 1, along Z-axis next to child 0
2402+
*
2403+
* children[5]: origin == (1, 0, 1), size == 1, in X-Z plane
2404+
*
2405+
* children[6]: origin == (0, 1, 1), size == 1, in Y-Z plane
2406+
*
2407+
* children[7]: origin == (1, 1, 1), size == 1, furthest from child 0
2408+
*/
2409+
2410+
classCV_EXPORTS Octree {
2411+
2412+
public:
2413+
2414+
//! Default constructor.
2415+
Octree();
2416+
2417+
/** @overload
2418+
* @brief Create an empty Octree and set the maximum depth.
2419+
*
2420+
* @param maxDepth The max depth of the Octree. The maxDepth > -1.
2421+
*/
2422+
explicitOctree(int maxDepth);
2423+
2424+
/** @overload
2425+
* @brief Create an Octree from the PointCloud data with the specific max depth.
2426+
*
2427+
* @param pointCloud Point cloud data.
2428+
* @param maxDepth The max depth of the Octree.
2429+
*/
2430+
Octree(const std::vector<Point3f> &pointCloud,int maxDepth);
2431+
2432+
/** @overload
2433+
* @brief Create an empty Octree.
2434+
*
2435+
* @param maxDepth Max depth.
2436+
* @param size Initial Cube size.
2437+
* @param origin Initial center coordinate.
2438+
*/
2439+
Octree(int maxDepth,double size,const Point3f& origin);
2440+
2441+
//! Default destructor
2442+
~Octree();
2443+
2444+
/** @brief Insert a point data to a OctreeNode.
2445+
*
2446+
* @param point The point data in Point3f format.
2447+
*/
2448+
voidinsertPoint(const Point3f& point);
2449+
2450+
/** @brief Read point cloud data and create OctreeNode.
2451+
*
2452+
* This function is only called when the octree is being created.
2453+
* @param pointCloud PointCloud data.
2454+
* @param maxDepth The max depth of the Octree.
2455+
* @return Returns whether the creation is successful.
2456+
*/
2457+
boolcreate(const std::vector<Point3f> &pointCloud,int maxDepth = -1);
2458+
2459+
/** @brief Determine whether the point is within the space range of the specific cube.
2460+
*
2461+
* @param point The point coordinates.
2462+
* @return If point is in bound, return ture. Otherwise, false.
2463+
*/
2464+
boolisPointInBound(const Point3f& point)const;
2465+
2466+
//! Set MaxDepth for Octree.
2467+
voidsetMaxDepth(int maxDepth);
2468+
2469+
//! Set Box Size for Octree.
2470+
voidsetSize(double size);
2471+
2472+
//! Set Origin coordinates for Octree.
2473+
voidsetOrigin(const Point3f& origin);
2474+
2475+
//! returns true if the rootnode is NULL.
2476+
boolempty()const;
2477+
2478+
/** @brief Reset all octree parameter.
2479+
*
2480+
* Clear all the nodes of the octree and initialize the parameters.
2481+
*/
2482+
voidclear();
2483+
2484+
/** @brief Delete a given point from the Octree.
2485+
*
2486+
* Delete the corresponding element from the pointList in the corresponding leaf node. If the leaf node
2487+
* does not contain other points after deletion, this node will be deleted. In the same way,
2488+
* its parent node may also be deleted if its last child is deleted.
2489+
* @param point The point coordinates.
2490+
* @return return ture if the point is deleted successfully.
2491+
*/
2492+
booldeletePoint(const Point3f& point);
2493+
2494+
/** @brief Radius Nearest Neighbor Search in Octree
2495+
*
2496+
* Search all points that are less than or equal to radius.
2497+
* And return the number of searched points.
2498+
* @param query Query point.
2499+
* @param radius Retrieved radius value.
2500+
* @param pointSet Point output. Contains searched points, and output vector is not in order.
2501+
* @param squareDistSet Dist output. Contains searched squared distance, and output vector is not in order.
2502+
* @return the number of searched points.
2503+
*/
2504+
intradiusNNSearch(const Point3f& query,float radius, std::vector<Point3f> &pointSet, std::vector<float> &squareDistSet)const;
2505+
2506+
/** @brief K Nearest Neighbor Search in Octree.
2507+
*
2508+
* Find the K nearest neighbors to the query point.
2509+
* @param query Query point.
2510+
* @param K
2511+
* @param pointSet Point output. Contains K points, arranged in order of distance from near to far.
2512+
* @param squareDistSet Dist output. Contains K squared distance, arranged in order of distance from near to far.
2513+
*/
2514+
voidKNNSearch(const Point3f& query,constint K, std::vector<Point3f> &pointSet, std::vector<float> &squareDistSet)const;
2515+
2516+
protected:
2517+
structImpl;
2518+
Ptr<Impl> p;
2519+
2520+
};
2521+
23772522
//! @} _3d
23782523
}//end namespace cv
23792524

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp