How to implement the hidden point removal algorithm of Open3D? Point Cloud Hidden Point Removal Algorithm——A Super-Detailed Implementation of the Underlying Algorithm [In-depth understanding of the essence of the algorithm]

written in front

The hidden point removal algorithm (Hidden Point Removal) in Open3D is used to remove points in the background that are not occluded by other points when rendering a point cloud from a given viewpoint, thereby improving the visualization of the point cloud. A hidden point removal method based on the approximate calculation of point cloud visibility proposed by [Katz2007] is implemented in the Open3D library. This method does not require surface reconstruction or normal vector estimation, and directly uses point cloud data to calculate the visibility of points.
When using the Open3D library we only need one line
_, pt_map = pcd.hidden_point_removal(camera, radius)
to get from the original point cloud

1

Get the point cloud after removing hidden points

2

But how does this algorithm achieve occluded point removal in point clouds where point occlusions are almost non-existent?
I found this document Direct Visibility of Point Sets to understand the underlying logic of the code. Later, many people optimized this article on the basis of it, but it remains the same. The algorithm of the article will be explained below.

Interpretation of the article

introduce

The paper introduces a new approach - extracting visibility information directly from point clouds. Point cloud is a set of sampling points containing 3D position information, which is simpler and more flexible than traditional grid representation. By extracting the visibility information in the point cloud, it is possible to realize the visualization of point sets, view-dependent fast reconstruction and real-time shadow casting. The method proposed in this paper is simple and fast, does not depend on screen resolution and mesh topology, and is applicable to point clouds of various dimensions. In addition, the algorithm is proved theoretically, and the experimental results and application examples are given.

Algorithm implementation

Given a point set P = { pi ∣ 1 ≤ i ≤ n } ⊂ ℜ DP = \{p_{i}|1\le{i}\le{n}\}\sub{\Re^{D}}P={ pi∣1in}D , these points are on a continuous surfaceSSS upsampled. and a viewpointCCC. _ Our goal is to findallAll point sets PPthat can be seen on Cpoints in P.

This kind of problem is that almost all points are visible due to the sparsity of the point cloud, so the simple line visibility judgment cannot be applied to all situations. So there must be a new point cloud visibility definition method. If a point is within radius ρ \rhoρ 's open ball

In mathematics, a point pprrof pr radius open sphereB r ( p ) B_r(p)Br( p ) means inppp is the center of the sphere,rrA sphere of radius r , but not containing any points on the surface of the sphere. That is,B r ( p ) B_r(p)Br( p ) contains all distancesppp is less thanrrr , but not points on the surface of the sphere.

A small disturbance at any position within will not be occluded by other points, then this point is visible.
Clearly, a reasonable criterion for visibility must be related to sampling density. Suppose PPP is planeSSAρ − \rho- of Sρ sampling, that is, if we use a radius ofρ \rhoρ 's open sphere to enclose each sampling pointpi p_ipiThen surface SSS will be completely contained within the union of these spheres. If we perturb pi p_ianywhere on the ballpiThe positions of which are not blocked by other points, then pi p_ipiJust visible. But this algorithm works well only when the line of sight is perpendicular to the surface, and does not perform well when the plane is inclined. But we also have to avoid computing surface normals.
To solve this problem, the authors propose an operator named Hidden Point Removal (HPR), which has the characteristics of correctness, suitability for inclined surfaces and reasonable time complexity. This operator consists of two steps: Inversion and Convex Hull Construction.

inversion (point transformation)

Given the point set PPP andCCC , we willPPP is associated with a coordinate system, letCCC is placed at the origin. Then we need to find a function that will pointpi p_ipimap to CC alongC topi p_ipion the ray, and at ∥ pi ∥ \|p_i\|pi is monotonically decreasing. where∥ ⋅ ∥ \|{\cdot}\| is a norm. This paper introduces an inversion method called Spherical Flipping, which converts a D-dimensional sphere with radiusRRR center is atCCThe spheres of C are connected, and this sphere containsPPAll points of P. Use the following formula topi p_ipiMake a mirror reflection.
p ^ i = f ( pi ) = pi + 2 ( R − ∥ pi ∥ ) pi ∥ pi ∥ \hat{p}_{i}=f(p_i)=p_{i}+2(R-\|p_i \|)\frac{p_i}{\|p_i\|}p^i=f(pi)=pi+2(Rpi)pipi
The schematic diagram of mirror reflection is as follows. This formula realizes the mirror reflection of the blue cat from the green sphere to the red cat in the outer circle.
1

The author hinted that there are more than one inversion function, such as f ~ ( pi ) = pi ∥ pi ∥ γ \tilde{f}(p_i)=\frac{p_i}{\|p_i\|\gamma}f~(pi)=piγpiThis formula can also achieve a similar effect.

Convex hull structure

The convex hull of a point cloud is the smallest convex set that contains all points. Open3D includes methods for computing the convex hull of point clouds. The implementation is based on Qhull. Using the function compute_convex_hull, you can get the visual convex hull of the following figure:
2
But how is this convex hull constructed?
Through the point transformation in the previous step, we can get the transformed point cloud P ^ \hat{P}P^ , the convex hull we want to calculate is the transformed point cloudP ^ \hat{P}P^ and center pointCCThe union of C.
The main result in the article is to extract the location atP ^ ∪ { C } \hat{P}\cup\{C\}P^{ C } convex hull to be equivalent to visible points. CChereThe introduction of C is necessary, because if C is outside the point cloud, the points on the back of the object will be on the convex hull.
We can thus derive a definition:

If point pi p_ipiThe reflection point pi ^ \hat{p_i}pi^at P ^ ∪ { C } \hat{P}\cup\{C\}P^On the convex hull of { C } , then pointpi p_ipiis marked as from CCC is visible.

The HPR operator can be applied to any dimension and is easier to understand in two-dimensional space. When we consider a two-dimensional point set pi ∈ P p_i\in{P}piP. _ Without loss of generality,pi p_ipiplaced on the X-axis. Use the polar coordinate system ( r , θ ) (r, \theta)(r,θ ) , we can putP i P_iPiMapping pi = ( ri , 0 ) p_{i}=(r_i,0)pi=(ri,0 ) . ri r_iin thatriis pi p_ipito CCThe distance between C and the angle with the X axis is 0. Consider passing throughpi ^ \hat{p_i}pi^and forms an angle β \beta with the X axisThe straight line L ^ \hat{L}of βL^ , as shown in the figure below:
3
we want to findL ^ \hat{L}L^ The line L corresponding to spherical flipping= ( r ( α ) , α ) L=(r(\alpha),\alpha)L=( r ( a ) ,α ) , using the law of sines we can get:
2 R − ri sin ⁡ ( π − α − β ) = R − r ( α ) sin ⁡ β \frac{2R-r_i}{\sin(\pi-\alpha- \beta)}=\frac{Rr(\alpha)}{\sin{\beta}}sin ( pab )2 Rri=sinbRr ( a )
thus we get
L = ( r ( α ) , α ) = ( 2 R + ( ri − 2 R ) sin ⁡ β sin ⁡ ( α + β ) , α ) L=(r(\alpha),\alpha)=( 2R+\frac{(r_{i}-2R)\sin{\beta}}{\sin(\alpha+\beta)},\alpha)L=( r ( a ) ,a )=( 2 R+sin ( a+b )(ri2R ) _sinb,α )
CurveLLL passes throughpi p_ipiand CCC , needs to be represented by a quartic polynomial of x and y in the Cartesian coordinate system.
The figure below illustratesthe LLHow does the shape of L vary with the angleβ \betaβ changes.

4
LLThe L and X axes define the pointspi p_ipiassociated white space. pi p_ipiVisibility depends on the size of the area. The larger the area is, pi p_ipimore visible. The important property of HPR is that this size is given by pi p_ipiThe surrounding points are adaptively determined as follows:
For all given points pi p_ipi, P P There are always two special pointspj p_j on both sides of Ppj p k ∈ P p_k\in{P} pkP , their corresponding curveL j = ( rj ( α j ) , α j ) L_j=(r_{j}(\alpha_j),\alpha_j)Lj=(rj( aj),aj)L k = ( rk ( α k ) , α k ) L_k = (r_{k}(\alpha_k),\alpha_k)Lk=(rk( ak),ak) , the area between them is the largest possible blank area, as shown in the figure below:

p i p_i piwhen visible
5
when pi p_ipiWhen invisible
6
From the formula of the curve, it can be deduced that the largest area corresponds to the smallest β \betabeta . This means that forpi p_ipi
In terms of β j \beta_j corresponding to the largest possible blank areabjand β k \beta_kbkthe smallest.
β j \beta_jbjand β k \beta_kbkAvailable from LLExtracted from the equation of L. For visiblepi p_ipi β j \beta_j bjand β k \beta_kbkThe sum of should satisfy β j + β k ≤ const \beta_j+\beta_k\le{const}bj+bkcon s t . _
setconst = π const = \piconst=π means that it is computationally unnecessary to find the adjacent pointspj, pk p_j, p_kpjpkup. Instead, computing P ^ ∪ { C } \hat{P}\cup\{C\}P^The convex hull of { C } is sufficient. This is because if and only ifP ^ ∪ { C } \hat{P}\cup\{C\}P^{ C } All points located bypi ^ , pj ^ ˉ \bar{\hat{p_i},\hat{p_j}}pi^,pj^ˉand pi ^ , pk ^ ˉ \bar{\hat{p_i},\hat{p_k}}pi^,pk^ˉWhen defining one side of the half-space, the point pi ^ \hat{p_i}pi^Only at P ^ ∪ { C } \hat{P}\cup\{C\}P^On the convex hull of { C } . In the case of the text, sinceL j L_jLjand L k L_kLkThe area between is empty (the gray area in the figure), so L j ^ \hat{L_j}Lj^and L k ^ \hat{L_k}Lk^The far field must be empty.
This observation is computationally important and is the reason why the HPR operator is so efficient, if you don't compute the convex hull you have to find pj p_jpjand pk p_kpkMake the algorithm quadratic (or even cubic in 3D). Instead, if all that needs to be done is to compute the convex hull and consider if pi ^ \hat{p_i}pi^at P ^ \hat{P}PPointpi p_i on the convex hull of ^piis visible on it. The HPR operator thus defines the shape and size of the empty region.
The above description can be extended to 3D, in which case the empty regions are not defined by curves but by surfaces. Also, instead of two neighbors in 3D, at least three neighbors define the surface that encloses the empty volume, but the idea of ​​this convex hull solution is the same.
It is worth noting that even if we define π \piπ is a constant threshold, and the visibility threshold can also be modified indirectly by changing the radius of the sphere,RRLarger R has a larger visible range, but the above explanation will remain the same when using a different inversion function but LLThe shape of the L will change.

Guess you like

Origin blog.csdn.net/qq_45912037/article/details/129866960