The subject matter herein generally relates to point clouds, and more particularly to an electronic device and a method for reducing a point cloud.
When scanning surfaces of an object, a plurality of scanned points of the surfaces can form a point cloud. The plurality of scanned points can be saved in the form of a mesh point cloud for further processing. Some of the scanned points may be deleted while still precisely representing the object to facilitate further processing of the mesh point cloud.
Implementations of the present technology will now be described, by way of example only, with reference to the attached figures.
It will be appreciated that for simplicity and clarity of illustration, where appropriate, reference numerals have been repeated among the different figures to indicate corresponding or analogous elements. In addition, numerous specific details are set forth in order to provide a thorough understanding of the embodiments described herein. However, it will be understood by those of ordinary skill in the art that the embodiments described herein can be practiced without these specific details. In other instances, methods, procedures and components have not been described in detail so as not to obscure the related relevant feature being described. The drawings are not necessarily to scale and the proportions of certain parts may be exaggerated to better illustrate details and features. The description is not to be considered as limiting the scope of the embodiments described herein.
Several definitions that apply throughout this disclosure will now be presented.
The term “comprising” means “including, but not necessarily limited to”; it specifically indicates open-ended inclusion or membership in a so-described combination, group, series and the like.
In general, the word “module” as used hereinafter refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language such as, for example, Java, C, or assembly. One or more software instructions in the modules may be embedded in firmware such as in an erasable-programmable read-only memory (EPROM). It will be appreciated that the modules may comprise connected logic units, such as gates and flip-flops, and may comprise programmable units, such as programmable gate arrays or processors. The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of computer-readable medium or other computer storage device.
Referring to
The obtaining module 100 can obtain a mesh point cloud file uploaded by a user to the electronic device 1, and obtain a plurality of data points and information of the point cloud from the mesh point cloud file. In at least one embodiment, the data points of the point cloud form a plurality of triangles. Information of the point cloud can include three-dimensional coordinates of the vertices of each of the triangles, and three-dimensional coordinates of a unit normal vector of each of the triangles.
The calculating module 101 can calculate the bounding box of the point cloud. In detail, the calculating module 101 can determine maximum X, Y, and Z coordinate values of the point cloud, and determine minimum X, Y, and Z coordinate values of the point cloud. Boundaries of the bounding box along the X, Y, and Z axes are bound by the maximum and minimum X, Y, and Z coordinate values, respectively.
The calculating module can divide the bounding box into the plurality of cubes according to the following formula:
wherein:
M, N, and W are numbers of the cubes along the X, Y, and Z axes, respectively;
Δ x is a difference between an average distance between adjacent points along the X axis and a smallest distance between the adjacent points along the X axis;
Δ y is a difference between an average distance between adjacent points along the Y axis and a smallest distance between the adjacent points along the Y axis;
Δ z is a difference between an average distance between adjacent points along the Z axis and a smallest distance between the adjacent points along the Z axis; and
L is a predetermined length.
The calculating module 101 can save a serial number of each of the cubes and of each of the data points of each cube to the storage device 11. The serial number of each cube can be linked to the serial number of each of the data points of the cube in a linked array. The calculating module 101 can determine which of the cubes are effective cubes. In at least one embodiment, each cube that has at least one data point is an effective cube. The calculating module 101 can save a serial number of each effective cube and of each of the data points of each effective cube to the storage device 11. The serial number of each effective cube can be linked to the serial number of each of the data points of the effective cube in a linked array.
The calculating module 101 can calculate the average curvature of each effective cube by determining a plurality of neighboring data points of each data point of the effective cube, calculating an average curvature of the effective cube at each data point according to the neighboring data points, and calculating an average of the average curvatures at all of the data points of the effective cube. The average curvature of the effective cube is equal to the average of the average curvatures at all of the data points of the effective cube.
The calculating module 101 can determine the plurality of neighboring data points of each data point of the effective cube by searching the serial number of the effective cube in the corresponding linked array to determine the data points of the effective cube, calculating a distance between the data point and each of six surfaces of the effective cube, determining which of the distances between the data point and each of the six surfaces is a minimum distance “dmin”, calculating a distance between the data point and each of the rest of the data points of the effective cube, and selecting a predetermined number “k” of the rest of the data points located farthest away from the data point. In at least one embodiment, the predetermined number “k” is eight. The calculating module 101 can determine whether a distance between the data point and each of the “k” data points is greater than the minimum distance “dmin”. If at least one of the “k” data points is located closer to the data point than the minimum distance “dmin”, the calculating module 101 selects data points from outside of the effective cube until the calculating module 101 obtains the predetermined number “k” of data points each located farther away from the data point than the minimum distance “dmin”.
The calculating module 101 can calculate the average curvature of the effective cube at each data point of the effective cube by calculating a plane of best fit at each point according to the neighboring data points, calculating a unit normal vector of the plane of best fit, calculating a tangent plane at the data point according to the unit normal vector, calculating a coordinate value of each of a plurality of projection points of the plurality of neighboring data points on the tangent plane, calculating a local parameterized coordinate of each of the neighboring data points according to the coordinate values of the plurality of projection points, calculating a parabola fitted to the plurality of neighboring data points according to the local parameterized coordinates, calculating coefficients of the parabola fitted to the plurality of neighboring data points, and calculating the average curvature at the data point according to the coefficients of the parabola.
In at least one embodiment, the plane of best fit is a least square plane. The calculating module 101 can calculate the plane of best fit according to the function: Ax=0; wherein:
x=(a, b, c)
P is the data point;
Qi is a center point of the plurality of adjacent data points;
an eigenvalue and a plurality of eigenvectors “xi(i=1, . . . , n) is calculated from a matrix (ATA);
a smallest eigenvector xi for the eigenvalue is the least square solution for the parameters (a, b, c) of the least square plane;
the least square solution for the parameters (a, b, c) of the least square plane is a starting value of the parameters (a, b, c);
the starting value of the parameters (a, b, c) of the least square plane is used to normalize a plurality of normal vectors N(a, b, c); and
the unit normal vector is equal to the normalized plurality of normal vectors N(a, b, c).
The calculating module 101 can calculate the tangent plane at the data point according to the equation:
N
i×(Pj−P)=Ax+By+Cz+D=0; wherein:
Ni is the unit normal vector;
P is the data point; and
Pj is a neighboring data point of the data point P.
The calculating module 101 can calculate a distance of the neighboring data point Pj from the tangent plane according to the equation: dj=Axj+Byj+Czj+D.
The calculating module 101 can calculate the coordinate value of the projection point of the neighboring data point Pj on the tangent plane according to the equation: PjP=Pj−djNi.
The calculating module 101 can calculate the local parameterized coordinate of each of the neighboring data points according to the Darboux frame. A neighboring point set is calculated by the following equation: (uj,vj,dj)=((PjP−PiP)×u, (PjP−PiP)×(v,dj)); wherein:
u=g/|g|, v=Ni×u;
g=Pj+1P−PjP; and
P is the origin point of the Darboux frame.
The calculating module 101 can calculate the parabola according to the equation: S(u,v)=(u,v,h(u,v))=(u,v,au2+buv+v2). The parabola is fitted to the neighboring points by calculating a smallest value of the equation:
wherein:
(a, b, c) are the coefficients of the parabolic equation, and (u, v, h) are the local parameterized coordinates of the fitted data points. A parabolic coefficient matrix X=[a,b,c]T=(ATA)−1ATB is a final solution of the parameters (a, b, c) of the least square plane; wherein:
The calculating module 101 can calculate the average curvature at the data point according to the equations:
wherein:
H is the average curvature at the data point;
K is the Gaussian curvature at the data point;
K1 is a smallest curvature at the data point, and m1 is a direction of K1;
K2 is a largest curvature at the data point, and m2 is a direction of K2;
The determining module 102 can determine the type of the effective cube according to the average curvature of the effective cube. In at least one embodiment, each effective cube can be a curved surface type or a flat surface type. The flat surface type has an average curvature less than a predetermined value. The curved surface type has an average curvature greater not less than the predetermined value.
The reducing module 103 can reduce each effective cube according to a reduction ratio uploaded to the electronic device 1. The reduction ratio represents a ratio of a number of data points of the post-reduction cube to a number of data points of the effective cube according to whether the effective cube is the curved surface type or the flat surface type. For example, in at least one embodiment, the curved surface type of the effective cubes has a ratio of 1:2, and the flat surface type of the effective cubes has a ratio of 1:8. Thus, for the curved surface type, for every two data points of the effective cube, one data point is used in the post-reduction cube, and for the flat surface type, for every eight data points of the effective cube, one data point is used in the post-reduction cube. After each of the effective cubes is reduced, the reducing module 103 combines the post-reduction cubes together to obtain the post-reduction point cloud.
Referring to
At block 20, the electronic device can obtain a mesh point cloud file uploaded by a user and obtain a plurality of data points and information of the point cloud from the mesh point cloud file. In at least one embodiment, the data points of the point cloud form a plurality of triangles. Information of the point cloud can include three-dimensional coordinates of the vertices of each of the triangles, and three-dimensional coordinates of a unit normal vector of each of the triangles.
At block 21, the electronic device can calculate a bounding box from the information, divide the bounding box into a plurality of cubes, and select effective cubes of the plurality of cubes.
To calculate the bounding box, the electronic device can determine maximum X, Y, and Z coordinate values of the point cloud, and determine minimum X, Y, and Z coordinate values of the point cloud. Boundaries of the bounding box along the X, Y, and Z axes are bound by the maximum and minimum X, Y, and Z coordinate values, respectively.
The electronic divide can divide the bounding box into the plurality of cubes according to the following formula:
wherein:
M, N, and W are numbers of the cubes along the X, Y, and Z axes, respectively;
Δ x is a difference between an average distance between adjacent points along the X axis and a smallest distance between the adjacent points along the X axis;
Δ y is a difference between an average distance between adjacent points along the Y axis and a smallest distance between the adjacent points along the Y axis;
Δ z is a difference between an average distance between adjacent points along the Z axis and a smallest distance between the adjacent points along the Z axis; and
L is a predetermined length.
The electronic device can save a serial number of each of the cubes and of each of the data points of each cube. The serial number of each cube can be linked to the serial number of each of the data points of the cube in a linked array. The electronic device can determine which of the cubes are effective cubes. In at least one embodiment, each cube that has at least one data point is an effective cube. The electronic device can save a serial number of each effective cube and of each of the data points of each effective cube to the storage device 11. The serial number of each effective cube can be linked to the serial number of each of the data points of the effective cube in a linked array.
At block 22, the electronic device can calculate an average curvature of each effective cube by determining a plurality of neighboring data points of each data point of the effective cube, calculating an average curvature of the effective cube at each data point according to the neighboring data points, and calculating an average of the average curvatures at all of the data points of the effective cube. The average curvature of the effective cube is equal to the average of the average curvatures at all of the data points of the effective cube.
At block 23, the electronic device can determine the type of the effective cube according to the average curvature of the effective cube. In at least one embodiment, each effective cube can be a curved surface type or a flat surface type. The flat surface type has an average curvature less than a predetermined value. The curved surface type has an average curvature greater not less than the predetermined value.
At block 24, the electronic device can reduce each effective cube according to a reduction ratio uploaded to the electronic device 1. The reduction ratio represents a ratio of a number of data points of the post-reduction cube to a number of data points of the effective cube according to whether the effective cube is the curved surface type or the flat surface type. For example, in at least one embodiment, the curved surface type of the effective cubes has a ratio of 1:2, and the flat surface type of the effective cubes has a ratio of 1:8. Thus, for the curved surface type, for every two data points of the effective cube, one data point is used in the post-reduction cube, and for the flat surface type, for every eight data points of the effective cube, one data point is used in the post-reduction cube. After each of the effective cubes is reduced, the electronic device combines the post-reduction cubes together to obtain the post-reduction point cloud.
At block 25, the electronic device can restore a mesh point cloud from the post-reduction point cloud. In detail, in a clockwise direction, for every three data points of the post-reduction point cloud, a first data point of the three data points is connected to a third data point of the three data points to form a triangle. Thus, a triangularly gridded structure of the point cloud is restored, and a total number of the data points of the point cloud is reduced.
At block 220, the electronic device can calculate a plurality of neighboring points of each point of the effective cube. The electronic device can calculate the plurality of neighboring data points of each data point of the effective cube by searching the serial number of the effective cube in the corresponding linked array to determine the data points of the effective cube, calculating a distance between the data point and each of six surfaces of the effective cube, determining which of the distances between the data point and each of the six surfaces is a minimum distance “dmin”, calculating a distance between the data point and each of the rest of the data points of the effective cube, and selecting a predetermined number “k” of the rest of the data points located farthest away from the data point. In at least one embodiment, the predetermined number “k” is eight. The electronic device can determine whether a distance between the data point and each of the “k” data points is greater than the minimum distance “dmin”. If at least one of the “k” data points is located closer to the data point than the minimum distance “dmin”, the electronic device selects data points from outside of the effective cube until the electronic device obtains the predetermined number “k” of data points each located farther away from the data point than the minimum distance “dmin”.
At block 221, the electronic device can calculate an average curvature of the effective cube at each data point of the effective cube by calculating a plane of best fit at each point according to the neighboring data points, calculating a unit normal vector of the plane of best fit, calculating a tangent plane at the data point according to the unit normal vector, calculating a coordinate value of each of a plurality of projection points of the plurality of neighboring data points on the tangent plane, calculating a local parameterized coordinate of each of the neighboring data points according to the coordinate values of the plurality of projection points, calculating a parabola fitted to the plurality of neighboring data points according to the local parameterized coordinates, calculating coefficients of the parabola fitted to the plurality of neighboring data points, and calculating the average curvature at the data point according to the coefficients of the parabola.
In at least one embodiment, the plane of best fit is a least square plane. The electronic device can calculate the plane of best fit according to the function: Ax=0; wherein:
x=(a, b, c)
P is the data point;
Qi is a center point of the plurality of adjacent data points;
an eigenvalue and a plurality of eigenvectors “xi(i=1, . . . , n) is calculated from a matrix (ATA);
a smallest eigenvector xi for the eigenvalue is the least square solution for the parameters (a, b, c) of the least square plane;
the least square solution for the parameters (a, b, c) of the least square plane is a starting value of the parameters (a, b, c);
the starting value of the parameters (a, b, c) of the least square plane is used to normalize a plurality of normal vectors N(a, b, c); and
the unit normal vector is equal to the normalized plurality of normal vectors N(a, b, c).
The electronic device can calculate the tangent plane at the data point according to the equation:
N
i×(Pj−P)=Ax+By+Cz+D=0; wherein:
Ni is the unit normal vector;
P is the data point; and
Pj is a neighboring data point of the data point P.
The electronic device can calculate a distance of the neighboring data point Pj from the tangent plane according to the equation: dj=Axj+Byj+Czj+D.
The electronic device can calculate the coordinate value of the projection point of the neighboring data point Pj on the tangent plane according to the equation: PjP−Pj−djNi.
The electronic device can calculate the local parameterized coordinate of each of the neighboring data points according to the Darboux frame. A neighboring point set is calculated by the following equation: (uj,vj,dj)=((PjP−PiP)×u, (PjP−PiP)×(v,dj)); wherein:
u=g/|g|, v=Ni×u;
g=Pj+1P−PjP; and
P is the origin point of the Darboux frame.
The electronic device can calculate the parabola according to the equation: S(u,v)=(u,v,h(u,v))=(u,v,au2+buv+v2). The parabola is fitted to the neighboring points by calculating a smallest value of the equation:
wherein:
(a, b, c) are the coefficients of the parabolic equation, and (u, v, h) are the local parameterized coordinates of the fitted data points. A parabolic coefficient matrix X=[a,b,c]T=(ATA)−1ATB is a final solution of the parameters (a, b, c) of the least square plane; wherein:
The electronic device can calculate the average curvature at the data point according to the equations:
wherein:
H is the average curvature at the data point;
K is the Gaussian curvature at the data point;
K1 is a smallest curvature at the data point, and m1 is a direction of K1;
K2 is a largest curvature at the data point, and m2 is a direction of K2;
At block 222, the electronic device can calculate the mean curvature of the effective cube by calculating an average of the mean curvatures at all of the data points of the effective cube. The mean curvature of the effective cube is equal to the average of the mean curvatures at all of the data points of the effective cube.
The embodiments shown and described above are only examples. Even though numerous characteristics and advantages of the present technology have been set forth in the foregoing description, together with details of the structure and function of the present disclosure, the disclosure is illustrative only, and changes may be made in the detail, including in matters of shape, size and arrangement of the parts within the principles of the present disclosure up to, and including, the full extent established by the broad general meaning of the terms used in the claims.
Number | Date | Country | Kind |
---|---|---|---|
201410710183.6 | Nov 2014 | CN | national |