One of the most effective local methods is the Extended Newton method. ...... Mark Theodore Draelos (2012) The Kinect Up Close: Modifications for Short-Range ...
e - publication, Wolfram Research, Wolfram Information Center, Mathematica Technology, Image Processing, http : // library.wolfram.com/infocenter/MathSource/8491 (2013)
Fitting sphere to quantized depth information B. Paláncz and B. Molnár Department of Photogrammetry and Geoinformatics, Budapest University of Technology and Economy 1521 Budapest, Hungary
Abstract This notebook presents different techniques to estimate radius and position of a sphere in case of quantized depth information obtained from low resolution sensors like Microsoft Kinect XBOX. First algebraic, geometric and directional least squares estimations were applied to the quantized data directly. Then two techniques SelfOrganizing Map (SOM) and RANdom SAmple Consensus (RANSAC) were employed as preprocessing methods to smooth and reduce quantized data. To solve the resulted nonlinear algebraic systems Gröbner basis with GaussJacobi method as global method as well as Newton method with pseudoinverse and direct minimization as local methods applying the result of the algebraic method as initial guess have been used. In order to decrease the computation time parallel computation on multi-core machine could be utilized . According to this case study all of these methods can be accepted from engineering point of view, although the geometrical approach with initial condition based on the solution of the algebraic method was proved to be the most effective.
1 - Introduction For understanding the geometry of an object as a function of its depth values relative to the sensor is vital to have both a smooth and accurate estimate of the depth map. Due to the limitations of the depth sensing technology used by inexpensive devices, a significant loss incurs when capturing depth information. Unlike depth measuring technologies, like laser based LIDAR or range finding cameras, theses sensors contains many missing data and is incapable of measuring depth for shiny objects or objects on certain orientation. On the flip side, traditional depth capturing devices cost in the order of a several thousand dollars, while low resolution sensors costs around $100-200. These sensors mainly are purposed for close distance human pose recognition, like Microsoft’s Kinect and is operated in an environment with a conspicuous foreground (human) and background (room), a clean and smooth depth map is not necessary. However, if the ability of such sensors is to be extended to a more general setting such as the inclusion in consumer laptops for human-computer interaction, robotics for robot motion planning, or graphics for environment reconstruction both smooth and complete depth information are essential.and it could significantly enhance the accuracy of object detection.
2 - Problem definition In our example the measurement has been carried out with Microsoft Kinect XBOX see Fig. 1 Microsoft’s Kinect contains a diverse set of sensors, most notably a depth camera based on PrimeSense’s infrared structured light technology. With a proper calibration of its color and depth cameras, the Kinect can capture detailed color point clouds at up to 30 frames per second. This capability uniquely positions the Kinect for use in fields such as robotics, natural user interfaces, and three-dimensional mapping, see i.e. Draelos (2012)
2
Kinect.nb
Fig .1 Microsoft Kinect XBOX
This device provides 2D RGB color image and the RGB data representing the depth - the distance of the object in 11 bits (0..2048). This low resolution causes discontinuities effect, which can be even 10 cm above 4 m object distance, and is about 2 cm in case when the object distance is less than 2.5 m. In our case a sphere object, having radius R = 0.152 m was placed in the real world position x = 0, y = 0 and the object distance z = 3 m. Since the intensity thresholds resolution is low, one may have quantized levels caused by round-off process. Fig.2. represents the quantized depth data points simulated as synthetic data for illustration.
Fig .2 Simulated synthetic quantized depth data points in case of a sphere from 3 different view points
Real measurements suffer not only from quantization but from random errors, too. Let us load a real measured data set adopted from Molnár, et al. (2012). dataQ = Import"E:\\f_03_05.dat" 1000;
The number of the data points is, n = Length[dataQ] 2710
The cloud of measured points are shown in Fig 3. p1 = ListPointPlot3D[dataQ, PlotStyle -> Directive[Blue, PointSize[0.006]], Axes False, Boxed -> False, PlotRange {{- 0.2, 0.2}, {- 0.2, 0.2}, {2.8, 3.2}}, BoxRatios {1, 1, 1}]; GraphicsGrid[{{p1, p1}}];
Kinect.nb
3
Fig . 3 Real measured data points from different view points
There are three basic approaches for estimating the position (a, b, c) and the radius (R) of a sphere from data point clouds, namely algebraic, geometric and directional least squares estimate i.e. Shah (2006).
3 - Algebraic least squares estimation when R is unknown In this case , we want to fit given n points to a sphere such that the sum of the squared algebraic distance is minimized, Then the local error is defined as δi = (xi - a)2 + (yi - b)2 + (zi - c)2 - R 2
where (xi , yi , zi ) are the coordinates of the measured point. First let us suppose that the position as well as the radius of the sphere are unknown. The parameters to be estimated are R, a, b and c. Let us introduce a new parameter, d = a 2 + b2 + c 2 - R 2 Then δi can be expressed as a b δi = (- 2 xi , - 2 yi, -2 zi , 1) + xi 2 + yi 2 + zi2 c d
Consequently the parameter estimation problem is linear, namely one should solve an overdetermined system. In matrix form Mp=h where -2 x1 -2 y1 - 2 z1 . . . M = -2 xi -2 yi - 2 zi . . . -2 xn -2 yn - 2 zn
1 . 1 , p = . 1
a b c d
- x1 2 + y1 2 + z1 2 . 2 and h = - xi + yi2 + zi2 . - xn 2 + yn 2 + zn 2
Then the solution in least square sense a b = ℳ-1 h c d
where ℳ-1 is the pseudoinverse of M. The attractive feature of the algebraic parameter estimation is that its formulation results in a linear least squares problem which has non-iterative closed -form solution. Therefore the algebraic distance based fitting can be used as a quick way to calculate approximate parameter values without requiring initial guess.
4
Kinect.nb
as a quick way to calculate approximate parameter values without requiring initial guess. First we create the M matrix. M = Map[{-2 #[[1]], - 2 #[[2]], - 2 #[[3]], 1} &, dataQ]; Dimensions[M] {2710, 4}
The right hand side vector is h = Map- #[[1]]2 + #[[2]]2 + #[[3]]2 &, dataQ;
Then we can compute the parameters a, b, c and d, {a, b, c, d} = PseudoInverse[M].h {- 0.0413512, - 0.00851136, 3.00166, 8.99215}
and the estimated radius of the sphere is R=
a2 + b2 + c2 - d
0.139948
Since we want to use these parameter values as initial values for other methods, we assigned them to the following variables, a0 = a; b0 = b; c0 = c; d0 = d; R0 = R;
Let us display this estimated sphere with the data points p2 = Graphics3D[{Specularity[White, 30], Orange, Opacity[0.1], Sphere[{a, b, c}, R ] /. {a a0, b b0, c c0, R R0}}, PlotRange {{- 0.2, 0.2}, {- 0.2, 0.2}, {2.8, 3.2}}, Axes False, BoxRatios {1, 1, 1}]; Show[{p1, p2}]
Fig. 4 The measured data with the estimated object
The disadvantages of this method that are its sensitivity for noise, outliers and partial occlusion, namely when the data points cover only a part of the surface of the sphere.
4 - Algebraic least squares estimation when R is known Sometimes the radius of sphere is known i.e. in case of calibration, and we want to find only the position of the sphere. Therefore there are 3 parameters a, b and c to be estimated. Now we have an overdetermined polynomial
Kinect.nb
5
sphere. Therefore there are 3 parameters a, b and c to be estimated. Now we have an overdetermined polynomial system to be solved, (xi - a)2 + (yi - b)2 + (zi - c)2 - R 2 = 0
i = 1, 2, ... n
The equations can be easily generated: Clear[a, b, c]; R = 0.152;
the prototype of the equation, G = (x - a)2 + (y - b)2 + (z - c)2 - R2;
Then the system can be created, eqs = Map[G /. {x #[[1]], y #[[2]], z #[[3]]} &, dataQ];
For example the first equation is, eqs[[1]] - 0.023104 + (- 0.1958 - a)2 + (-0.0309 - b)2 + (2.967 - c)2
The number of the equations is, Length[eqs] 2710
The solution of this problem is not unique since the reduced Gröbner basis for the determined polynomial subsystems (n = 3) are second order polynomials, see Appendix 1A. To solve the overdetermined system one can use local or global techniques. The local methods need initial guess for the parameter values, which can be the solution of the linear problem. One of the most effective local methods is the Extended Newton method. The Extended Newton method can handle nonlinear overdetermined systems since using pseudoinverse of the Jacobian, see Awange et al (2011). NewtonExtendedf_List, x_List, x0_List, eps_: 10-12, n_: 100 := With[{jac = N[Outer[D, f, x]]}, FixedPointList[(# + PseudoInverse[jac /. Thread[x N[#]]].(- f /. Thread[x N[#]])) &, N[x0], n, SameTest (Sqrt[Abs[(#1 - #2).(#1 - #2)]] < eps &)]] // Last
Let us employ the result of the algebraic solution as initial guess NewtonExtended[eqs, {a, b, c}, {a0, b0, c0}] {- 0.0403983, - 0.00727025, 3.0184}
Another local method is based on the direct minimization of the squares of the residuals of the equations, n
n
2
ρ = δi 2 = (xi - a)2 + (yi - b)2 + (zi - c)2 - R i=1
i=1
Now we employ local minimization with the initial guess again computed for the linear problem. The objective function is W = Apply[Plus, Map[#2 &, eqs]];
Then FindMinimum[W, {{a, a0}, {b, b0}, {c, c0}}] {0.0355584, {a - 0.0403983, b -0.00727025, c 3.0184}}
The solution of the two methods is the same, but the computation time of the local minimization is somewhat shortest.
6
Kinect.nb
shortest. Although as we mentioned, the reduced Gröbner basis of the determined system (n = 3) can be computed in symbolic form represented by second order polynomials, the high number of the subsystems, namely Binomial[n, 3] 3 313 414 020
hinders the realization of the Gauss-Jacobi combinatorial computation as a global method. However, later we shall demonstrate, that if one can represent the cloud of points with considerable less points, for example via SOM (Self Organizing Map), then the symbolic solution is reasonable alternative of the local methods.
5 - Geometric fitting when R is unknown In this case, we want to minimize the sum of squared geometric distances to the point set. Then the local error is defined as δi =
(xi - a)2 + (yi - b)2 + (zi - c)2 - R
Now we have an overdetermined nonlinear equation system to be solved for the parameter estimation problem even in case of unknown R. However in this case, the solution of the system is unique, since the Gröbner basis of the determined subsystems are first order polynomials. In general the use of geometric distance results in better solution compared to the algebraic distance. This is especially true in the presence of noise and small outliers. Similarly to the algebraic approach, local methods like Extended Newton method as well as direct local minimization can be employed. Let us create the system of the equations. First we reset a, b, c and R to be symbolic variables again, Clear[a, b, c, R]
The prototype of the equation, G=
(x - a)2 + (y - b)2 + (z - c)2 - R;
Then the system can be created as, eqs = Map[G /. {x #[[1]], y #[[2]], z #[[3]]} &, dataQ];
For example the first equation is eqs[[1]] √(- 0.1958 - a)2 + (-0.0309 - b)2 + (2.967 - c)2 - R
Let us employ the Extended Newton method with the result of the algebraic solution as initial guess NewtonExtended[eqs, {a, b, c, R}, {a0, b0, c0, R0}] {- 0.0411326, - 0.00844824, 3.01198, 0.145917}
Indeed, the geometric approach provides better estimation than algebraic one, however it needs a good initial guess. The other possible solution is minimization of the squares of the residuals of the equations, n
n
ρ = δi 2 = i=1
2
(xi - a)2 + (yi - b)2 + (zi - c)2 - R
i=1
Now again we can employ local minimization with the initial guess computed from the linear problem,
Kinect.nb
7
W = Apply[Plus, Map[#2 &, eqs]]; FindMinimum[W, {{a, a0}, {b, b0}, {c, c0}, {R, R0}}] {0.351, {a - 0.0411326, b - 0.00844824, c 3.01198, R 0.145917}}
Again this computation required less time than the Newton method.
6 - Geometric fitting when R is known Again one can use the Extended Newton method, NewtonExtended[eqs /. R 0.152, {a, b, c}, {a0, b0, c0}] {- 0.040658, - 0.00793428, 3.02032}
The solution with the direct local minimization FindMinimum[W /. R 0.152, {{a, a0}, {b, b0}, {c, c0}}] {0.360787, {a - 0.040658, b - 0.00793428, c 3.02032}}
In this case the nonlinear system has more solutions since the Gröbner basis of the determined subsystems are second order polynomials, see Appendix. A.2 Generally speaking, the algebraic as well as the geometric approach with known radius are always lead to nonlinear problems, where in case of geometric model the solution is not unique.
7 - Directional Fitting For directional fitting, the error function is based on the distance between the measured point Pi = P{xi , yi , zi} and its projection onto the surface of the sphere closer to the instrument along the direction of Pi , see Fig. 5
ri
Geometric fitting
(xi, yi, z i)
pi
Directional fitting
(xi, yi, zi) R
qi
Fig. 5 Comparison of the geometric and directional fitting
In Cartesian coordinates, the expressions for ri, pi and qi (see Fig. 5) can be written as, see i.e. Franaszek et al (2009)
ri =
(xc - xi)2 + (yc - yi )2 + (zc - zi)2 pi = a u i + b vi + c w i
8
Kinect.nb
and qi =
(vi c - wi b)2 + (wi a - ui c)2 + (ui b - vi a)2
where ui =
xi ri
, vi =
yi ri
and
wi =
zi ri
The system of the nonlinear equations are 2
pi -
R2 - q i 2 - ri
= 0 if qi < R
( pi - ri)2 + (qi - R)2 = 0 if qi ≥ R
In our case the camera is in the origo, xc = 0, yc = 0 and
zc = 0
This algorithm can be summarize in the following module, Res[a_, b_, c_, R_, data_] := Module{xc = 0, yc = 0, zc = 0, RR, P, Q, Z1, Z2, Z}, RR = Map[Norm[{xc, yc, zc} - #] &, data]; dataQN = MapThread[#1 / #2 &, {data, RR}]; P = Map[{a, b, c}.# &, dataQN]; Q = Map √ (#[[2]] c - #[[3]] b)2 + (#[[3]] a - #[[1]] c)2 + (#[[1]] b - #[[2]] a)2 &, dataQN; Z1 = MapThread #1 -
R2 - #22 - #3
2
&, {P, Q, RR};
Z2 = MapThread(#1 - #3)2 + (#2 - R)2 &, {P, Q, RR}; Z = MapThread[If[#1 < R, #2, #3] &, {Q, Z1, Z2}];
Now, let us create the nonlinear system of the problem, Eqs = Res[a, b, c, R, dataQ];
The number of equations are Length[Eqs] 2710
For example the first equation is, Eqs[[1]] If √(0.0103914 a - 0.0658458 b)2 + (- 0.997776 b - 0.0103914 c)2 + (0.997776 a + 0.0658458 c)2 < R, - 2.97361 - 0.0658458 a - 0.0103914 b + 0.997776 c - √- (0.0103914 a - 0.0658458 b)2 2
(- 0.997776 b - 0.0103914 c)2 - (0.997776 a + 0.0658458 c)2 + R2 , (- 2.97361 - 0.0658458 a - 0.0103914 b + 0.997776 c)2 + √(0.0103914 a - 0.0658458 b)2 + 2
(-0.997776 b - 0.0103914 c)2 + (0.997776 a + 0.0658458 c)2 - R
The Extended Newton method can not handle these equations properly because the derivatives can not compute symbolically, therefore local minimization is used. The objective function is the sum of the residual of the equations, W = Apply[Plus, Eqs];
Then the local minimization is employed with a derivative free method,
Kinect.nb
9
FindMinimum[W, {{a, a0}, {b, b0}, {c, c0}, {R, R0}}, Method "PrincipalAxis"] {1.56588, {a -0.036743, b - 0.00738915, c 3.00028, R 0.140142}}
Now, let us assume that R is known. Then we have the same equation system where R = 0.152. Then the local minimization gives FindMinimum[W /. R 0.152, {{a, a0}, {b, b0}, {c, c0}}, Method "PrincipalAxis"] {1.38047, {a -0.0369308, b - 0.00800386, c 3.0196}}
In the following sections we shall demonstrate two methods - the application of Self-Organizing Map (SOM) and that of RANdom SAmple Consensus (RANSAC) -t which can reduce the data points and open the way for the application of the Gauss-Jacobi combinatoric solution.
8 - Application Self-Organizing Map for reducing data The Self-Organizing Map (SOM) is a neural network algorithm, which uses a competitive learning technique to train itself in an unsupervised manner. SOMs are different from other artificial neural networks in the sense that they use a neighborhood function to preserve the topological properties of the input space and they have been used to create an ordered representation of multi-dimensional data which simplifies complexity and reveals meaningful relationships. In the last decade a lot of research has been done to develop surface reconstruction methods. A more recent approach to the problem of surface reconstruction is that of learning based methods. Learning algorithm are able to process very large and/or noisy data, such as point clouds obtained from 3D scanners and have been used to construct surfaces. Following this approach some studies have been employed SOM and their variants for surface reconstruction. SOM is suitable for this problem because it can form topological maps replicate the distribution of input data. In our case this mapping occurs from 3D space to 2D one i.e. DalleMole et al (2010) Therefore we try to represent this cloud of data points by considerably less points using Kohonen-map with a lattice of SOM (Self Organizing Map) of size 5 × 5 code-book vectors with symmetrical neighborhood. 0.000025 &]];
Generating a prototype for the equations of the subsets psi = Table[({ηi , ξi , χi }), {i, 1, 4}];
Substituting numerical values dataS = ParallelMap[ Flatten[MapThread[MapThread[#1 #2 &, {#1, #2}] &, {psi, #}]] &, dataSubS];
Then the number of the equations to be considered is
14
Kinect.nb
Length[dataS] 1150
instead of the 12 650. Employing the result of the Gröbner basis the parameter a is aS = ParallelMap[aG /. # &, dataS];
Then the average is aaS = Mean[aS] - 0.0399059
The parameters b and c can be computed in the same way bS = ParallelMap[bG /. # &, dataS]; bbS = Mean[bS] - 0.011016
and cS = ParallelMap[cG /. # &, dataS]; ccS = Mean[cS] 3.00621
Now employing these averages of computed parameters to compute the radius of the sphere eqsR = Parallelize[Map[proto /. #1 /. {a aaS, b bbS, c ccS} &, dataS]]; RS = Map[#[[1]][[1]] &, eqsR]; RRS = Mean[RS] 0.139364
11 - Application of RANdom SAmple Consensus (RANSAC) 11 - 1 RANSAC algorithm
In addition we investigated the application of the RANSAC method, i.e. Fischler and Bolles (1981), which is proved to be successful for detecting outliers. The basic RANSAC algorithm is the following: 1) Pick up a model type (ℳ) 2) Input data as - dataQ - data contaminated with outliers (cardinality (dataQ) = n) - s
- number of data elements required per subset
- - τ
- number of subsets draw from the data - threshold which defines if data element, di ∈ dataQ, agrees with the model ℳ
Remarks In general s can be the minimal number of the data which results a determined system for the unknown parameters of the model. The number of subsets draw from the data, is chosen high enough to ensure that the probability p (usually set to 0.99) that at least one of the subsets of the random examples does not include an outliers. Let u represent the probability that any selected data point is an inlier and v = 1 - u the probability of observing an outlier. Then the iterations can be computed as =
log (1 - p) log (1 - (1 - v)s )
Kinect.nb
15
3) maximalConsensusSet ← ∅ 4) Iterate times: a) consensusSet ← ∅ b) Randomly draw a subset containing s elements and estimate the parameters of the model ℳ c) For each data element, di ∈ dataQ: if Agree (di ,ℳ, τ), consensusSet ← di d) if cardinality (maximalConsensusSet) < cardinality(consensusSet), maximalConsensusSet ← consensusSet 5) Estimate model parameters using maximalConsensusSet 11 - 2 The model: algebraic least squares estimation when R is unknown In order to see how this data reduction technique can work in our case, let us select the most simple model, namely the algebraic least squares estimation when R is known. Now, number of data elements required per subset s is s = 4;
The solution of a subsystem of size s (which is a determined system) is -2 x1 -2 y1 - 2 z1 . . . M = -2 xi -2 yi - 2 zi . . . -2 xs -2 ys - 2 zs
1 . 1 , p = . 1
a b c d
- x1 2 + y1 2 + z1 2 . and h = - xi2 + yi2 + zi2 . 2 - xs + ys 2 + zs2
and Mp=h Remark Although it is a determined system, subsets representing ill-posed configuration can arise. Therefore the best way to avoid this situation to restrict the conditional number of M. Let say if this conditional number is higher than 1000 we leave out the computation of the subset and draw another one. Here we employ another less efficient method, namely we compute pseudoinverse. 11 - 3 Computation of the necessary number of the iterations
The total number of the data is, n 2710
Let p = 0.99;
In addition let us assume that the probability of observing outlier is v = 1 / 2;
Then the number of the necessary iterations is = Round[Log[1 - p] / Log[1 - (1 - v)s]] 71
Remark Higher this probability more the necessary iterations Thinking of Gauss- Jacobi technique, which can be also employed to kick out outliers the all possible subset of
16
Kinect.nb
Thinking of Gauss- Jacobi technique, which can be also employed to kick out outliers the all possible subset of which can be drawn from dataQ Binomial[n, s] 2 242 352 938 035
11 - 4 Computation of the threshold
Let the threshold τ τ = 1;
An element di∈ dataQ will be accepted if (xi - as )2 + (yi - bs )2 + (zi - cs )2 - Rs 2 < τ2
Remarks di is represented by the triplet (xi , yi , zi) and the parameters (as ,bs ,cs ,Rs ) computed from a subset of s elements. 11 - 5 The computation model step by step inliers = Table[{}, {}] (* the consensus sets, j = 1,2, ...*) {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}
Let us consider a subset (j = 1,2, ...). j = 2 (*second iteration means second subset*) 2 (*get four random points without replacement*) dataS = RandomSample[dataQ, 4] {{0.0664, 0.0307, 2.942}, {- 0.1482, - 0.0664, 2.942}, {0.0511, 0.0766, 2.942}, {-0.1064, - 0.0709, 2.917}} (*determine inliers for a subset*)
First we compute the parameters from this subset. Let us create the M matrix. M = Map[{-2 #[[1]], - 2 #[[2]], - 2 #[[3]], 1} &, dataS]; M // MatrixForm - 0.1328 - 0.0614 - 5.884 0.2964 0.1328 - 5.884 - 0.1022 - 0.1532 - 5.884 0.2128 0.1418 - 5.834
1 1 1 1
Dimensions[M] {4, 4}
The right hand side vector is h = Map- #[[1]]2 + #[[2]]2 + #[[3]]2 &, dataS;
Then we can compute the parameters a, b, c and d, P = {a, b, c, d} = PseudoInverse[M].h {- 0.0559519, 0.015416, 3.03366, 9.18287}
and the estimated radius of the sphere is R=
a2 + b2 + c2 - d
0.153641
Then check for all elements of dataQ (i = 1,2, ..., n) whether it can satisfy the threshold. Let
Kinect.nb
17
i = 3; dataQ[[i]] {- 0.1958, -0.0412, 2.967} Abs(dataQ[[i]][[1]] - a)2 + (dataQ[[i]][[2]] - b)2 + (dataQ[[i]][[3]] - c)2 - R2 0.00360118 IfAbs(dataQ[[i]][[1]] - a)2 + (dataQ[[i]][[2]] - b)2 + (dataQ[[i]][[3]] - c)2 - R2 < τ2 , inliers[[j]] = Append[inliers[[j]], dataQ[[i]]] {{-0.1958, - 0.0412, 2.967}} inliers {{}, {{-0.1958, - 0.0412, 2.967}}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}
If this double For cycle for j = 1, 2, ... for i = 1,2,...n is over we find out the maximal consensus set and using this set - whose size is between s and n, so mostly overdetermined - to compute the parameters. 11 - 6 The implementation of the computation model
Now let us use for threshold τ = 1.5 cm τ = 0.015;
Preparation of the sets of inliers for every iteration step - at the beginning they are empty sets: inliers = Table[{}, {}] (* the consensus sets, j = 1,2, ...*); Forj = 1, j ≤ , j ++, (*get four random points*) dataS = RandomSample[dataQ, 4]; (*determine model parameters*) M = Map[{- 2 #[[1]], -2 #[[2]], -2 #[[3]], 1} &, dataS]; h = Map- #[[1]]2 + #[[2]]2 + #[[3]]2 &, dataS; P = {a, b, c, d} = PseudoInverse[M].h; a2 + b2 + c2 - d ;
R=
(* determine inliers*) Fori = 1, i ≤ n, i ++, IfAbs(dataQ[[i]][[1]] - a)2 + (dataQ[[i]][[2]] - b)2 + (dataQ[[i]][[3]] - c)2 - R2 < τ2 , inliers[[j]] = Append[inliers[[j]], dataQ[[i]]]; ;;
Select the consensus set which has the highest number of inliers trimmeddata = inliers[[Ordering[inliers, - 1]]][[1]]; Length[trimmeddata] 196
As last step we apply algebraic least squares with the maximal consensus set
18
Kinect.nb
M = Map[{-2 #[[1]], - 2 #[[2]], - 2 #[[3]], 1} &, trimmeddata]; Dimensions[M] {196, 4}
The right hand side vector is h = Map- #[[1]]2 + #[[2]]2 + #[[3]]2 &, trimmeddata;
Then we can compute the parameters a, b, c and d, P = {a, b, c, d} = PseudoInverse[M].h {- 0.0413611, - 0.000842757, 3.00798, 9.02995}
and the estimated radius of the sphere is R=
a2 + b2 + c2 - d
0.140305
The selected points - the elements of the maximal consensus set - are close to the surface of the sphere, see Fig.8. p4 = Graphics3D[{Specularity[White, 30], Orange, Opacity[0.1], Sphere[{a, b, c}, R ]}, PlotRange {{- 0.2, 0.2}, {- 0.2, 0.2}, {2.8, 3.2}}, Axes False, BoxRatios {1, 1, 1}]; p5 = ListPointPlot3D[trimmeddata, PlotStyle Directive[Red], BoxRatios {1, 1, 1}]; Show[{p4, p5}]
Fig 8 Elements of the maximal consensus set
It seems better result, than direct algebraic approach without RANSAC and quite close to the result of the directional approach.
Conclusions To find the sphere parameters, different methods: algebraic, geometrical and directional method have been employed. The algebraic approach results a linear least square problem which does not require initial guess. The geometric as well as the directional approach lead to a nonlinear problem requires iteration with an initial guess. This initial guess can be the result of the algebraic method. One also may employ direct global minimization of the sum of the residual of the geometrical model equations, however, it may need restrictions for the search space. As an alternative method, Gauss-Jacobi combinatorial method based on Gröbner basis solution utilizing SOM representation of the measured data points has been demonstrated. This method similarly to the algebraic solution does not requires initial guess. Parallel computation on multi-cores machine can be utilized decreasing the computa-
Kinect.nb
19
does not requires initial guess. Parallel computation on multi-cores machine can be utilized decreasing the computation time considerably. The results of the different methods are in the following Tables. Table 1 Estimated parameters employing different methods (R is unknown)
Type of estimation Algebraic Geometric Directional Geometric based on SOM Directional based on SOM Gauss - Jacobi with Gröbner based on SOM RANSAC with Algebraic
a[mm] b [mm] c [mm] R [mm] -41.4 -8.5 300.2 140.0 -41.1 -8.5 301.2 145.9 -36.7 -7.4 300.0 140.1 -41.0 -7.9 300.6 140.0 -40.3 -9.1 301.1 142.8 -40.0 -11.0 300.6 140.0 -41.0 -8.4 300.8 140.3
Table 2 Estimated parameters employing different methods (R = 152 mm)
Type of estimation Algebraic Geometric Directional Geometric based on SOM Directional based on SOM
a[mm] b [mm] c [mm] -40.4 -7.5 301.8 -40.7 -7.9 302.0 -36.7 -7.4 302.0 -42.3 -9.6 302.4 -36.9 -8.0 302.0
References Awange et al. (2011) Algebraic Geodesy and Geoinformatics, Springer, Heidelberg, Berlin. Mark Theodore Draelos (2012) The Kinect Up Close: Modifications for Short-Range Depth Imaging, A thesis Master of Science, Electrical Engineering, Raleigh, North Carolina Marek Franaszek, Geraldine S. Cheok, Kamel S. Saidi, Christoph Witzgall (2009) Fitting Spheres to Range Data From 3-D Imaging Systems. IEEE T. Instrumentation and Measurement 58(10): 3544-3553 B. Molnár, C. K. Toth, A. Detrekõi (2012) Accuracy Test of Microsoft Kinect for Human Morphological Measurements, International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XXXIX-B3, 2012 XXII ISPRS Congress, 25 August - 01 September 2012, Melbourne, Australia Tahir Rabbani Shah (2006) Automatic Reconstruction of Industrial Installations Using Point Clouds and Images Publications on Geodesy 62, NCG Netherlands Commissie voor Geodesie Netherlands Geodetic Commission Delft, Vilson L. DalleMole, Renata L.M. E. do Rego and Aluizio F.R. Araujo (2010). The Self-Organizing Approach for Surface Reconstruction from Unstructured Point Clouds, p. 167-188. in Self-Organizing Maps, George K Matsopoulos (Ed.) INTECH, Rijeka, Croatia. Westfeld, P.; Mulsow, C.; Schulze, M. (2009): Photogrammetric calibration of range imaging sensors using intensity and range information simultaneously. Grün, A.; Kahmen H. (Eds.): Optical 3-D Measurement Techniques IX. Vol. II, pp. 129, Research Group Engineering Geodesy, Vienna University of Technology. Zhou Shijian, Guan Yunlan, Zhan Xinwu and Lu Tieding (2008) Robust Algorithm for fitting Sphere to 3D Point Clouds in Terrestrial Laser Scanning,The Int. Archives of Photogrammetry and Spatial Information Sci. Vol. XXXVII Part B5. Beijing. p. 519-522. Fischler M A, Bolles R C (1981) Random sample consensus: A paradigm for model fitting with applications to image analysis and automated cartography. CCommunications of theACM, 24 (6): 381-395 (document).
Appendix A1 - Algebraic approach: Computation of the Gröbber basis, when R is known
Would it be 3 exact noiseless measurement points, then prototype system for 3 points Clear[a, b, c, R];
The prototype of the equations,
20
Kinect.nb
G = (x - a)2 + (y - b)2 + (z - c)2 - R2; proto = Table[(G /. {x ηi , y ξi , z χi }), {i, 1, 3}] - R2 + (- a + η1 )2 + (-b + ξ1 )2 + (- c + χ1 )2, - R2 + (- a + η2)2 + (-b + ξ2 )2 + (- c + χ2 )2 , -R2 + (- a + η3 )2 + (- b + ξ3 )2 + (-c + χ3 )2
The polynomial for a is grba = GroebnerBasis[proto, {a, b, c}, {b, c}] // Simplify; Coefficient[grba, a, 2] // Simplify 4 η21 ξ22 - 2 η21 ξ2 ξ3 + η21 ξ23 + ξ22 χ21 - 2 ξ2 ξ3 χ21 + ξ23 χ21 + η23 ξ21 - 2 ξ1 ξ2 + ξ22 + (χ1 - χ2 )2 - 2 ξ1 ξ2 χ1 χ2 + 2 ξ1 ξ3 χ1 χ2 + 2 ξ2 ξ3 χ1 χ2 2 ξ23 χ1 χ2 + η21 χ22 + ξ21 χ22 - 2 ξ1 ξ3 χ22 + ξ23 χ22 + η22 ξ21 - 2 ξ1 ξ3 + ξ23 + (χ1 - χ3 )2 + 2 η1 η3 (- ξ22 + ξ1 (ξ2 - ξ3 ) + ξ2 ξ3 + (χ1 - χ2 ) (χ2 - χ3 )) + 2 ξ1 ξ2 χ1 χ3 - 2 ξ22 χ1 χ3 2 ξ1 ξ3 χ1 χ3 + 2 ξ2 ξ3 χ1 χ3 - 2 η21 χ2 χ3 - 2 ξ21 χ2 χ3 + 2 ξ1 ξ2 χ2 χ3 + 2 ξ1 ξ3 χ2 χ3 - 2 ξ2 ξ3 χ2 χ3 + η21 χ23 + ξ21 χ23 - 2 ξ1 ξ2 χ23 + ξ22 χ23 - 2 η2 (η3 (ξ21 + ξ2 ξ3 - ξ1 (ξ2 + ξ3 ) + (χ1 - χ2 ) (χ1 - χ3)) + η1 (ξ1 (ξ2 - ξ3) - ξ2 ξ3 + ξ23 + χ1 χ2 - χ1 χ3 - χ2 χ3 + χ23 )) Coefficient[grba, a, 3] // Simplify {0}
It means we have a second order polynomial indicating non-unique solution. A2 - Geometric approach: Computation of the Gröbner basis, when R is known
Would it be 3 exact noiseless measurement points, then prototype system for 3 points Clear[a, b, c, R];
The prototype of the equations, (x - a)2 + (y - b)2 + (z - c)2 - R;
G=
proto = Table[(G /. {x ηi , y ξi , z χi }), {i, 1, 3}] - R + -R +
(-a + η1 )2 + (- b + ξ1 )2 + (- c + χ1)2 , (-a + η2 )2 + (- b + ξ2 )2 + (- c + χ2 )2 , - R +
(-a + η3 )2 + (- b + ξ3 )2 + (-c + χ3 )2
The polynomial for a is grba = GroebnerBasis[proto, {a, b, c}, {b, c}] // Simplify; Length[grba] 14 ca2 = Coefficient[grba[[1]], a, 2] // Simplify 4 η21 ξ22 - 2 η21 ξ2 ξ3 + η21 ξ23 + ξ22 χ21 - 2 ξ2 ξ3 χ21 + ξ23 χ21 + η23 ξ21 - 2 ξ1 ξ2 + ξ22 + (χ1 - χ2 )2 - 2 ξ1 ξ2 χ1 χ2 + 2 ξ1 ξ3 χ1 χ2 + 2 ξ2 ξ3 χ1 χ2 2 ξ23 χ1 χ2 + η21 χ22 + ξ21 χ22 - 2 ξ1 ξ3 χ22 + ξ23 χ22 + η22 ξ21 - 2 ξ1 ξ3 + ξ23 + (χ1 - χ3 )2 + 2 η1 η3 (- ξ22 + ξ1 (ξ2 - ξ3 ) + ξ2 ξ3 + (χ1 - χ2) (χ2 - χ3 )) + 2 ξ1 ξ2 χ1 χ3 - 2 ξ22 χ1 χ3 2 ξ1 ξ3 χ1 χ3 + 2 ξ2 ξ3 χ1 χ3 - 2 η21 χ2 χ3 - 2 ξ21 χ2 χ3 + 2 ξ1 ξ2 χ2 χ3 + 2 ξ1 ξ3 χ2 χ3 - 2 ξ2 ξ3 χ2 χ3 + η21 χ23 + ξ21 χ23 - 2 ξ1 ξ2 χ23 + ξ22 χ23 - 2 η2 (η3 (ξ21 + ξ2 ξ3 - ξ1 (ξ2 + ξ3 ) + (χ1 - χ2 ) (χ1 - χ3 )) + η1 (ξ1 (ξ2 - ξ3 ) - ξ2 ξ3 + ξ23 + χ1 χ2 - χ1 χ3 - χ2 χ3 + χ23)) ca3 = Coefficient[grba[[1]], a, 3] // Simplify 0
Again, we have second order polynomial indicating non-unique solution.