3d icp-based scan matcher implementationais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf ·...

30
Zhongjie Cai, Shou-Yu Chao March 5 2010 3D ICP-BASED SCAN MATCHER IMPLEMENTATION 1

Upload: others

Post on 29-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Zhongjie Cai, Shou-Yu Chao March 5 2010

3D ICP-BASED SCAN MATCHER IMPLEMENTATION

1

Page 2: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Outline

Concept of ICP

Our Task

System Overview

Point matching using ICP algorithm

Visualization

Performance and difficulty

Conclusion and Outlook

Reference

2

Page 3: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Concept of ICP

ICP stand for: Iterative Closest Point

First proposed by Besl et. al. on “A method for registration of 3D shapes”

A general purpose, representation independent algorithm for matching point sets, line segments…etc

Suitable from simple 2D shape to large 3D surface reconstruction

Usually used in Real-Time manner

3

Page 4: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Our Task

Implement an ICP scan matcher which accept :

Two or more VRML point clouds from SICK laser range scanner mounted on a robot.

The output shall be a rotation and translation matrix between the two point clouds which minimizes their overlap.

Extra: An OpenGL based visualization interface to render the final result.

4

Page 5: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

System Overview

Code is written in C++

We separate our program into two parts: ICP Calculation:

The code could be both compiled under Linux and Windows.

Output: A rotation and transformation matrix, generate a .dat file for GNUPlot or for following part

Visualization Render the result from previous part.

Require hardware 3D acceleration support.

MFC only. Possible to port to QT or X11.

5

Page 6: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

VRML file structure

Our instructor provide us 131 VRML files containing laser scan from SICK range scanner around the building 079.

Each scan contains 150,000 to 200,000 points.

Point axis is stored as: Double(x) Double(y) Double(z) format:

0.353173 -2.390132 0.705018

Each 3D points require 24 bytes

The header contains following data from robot’s internal movement sensor: An estimated rotation – require converting to matrix

representation. See next page

An estimated translation – no conversion required

6

Page 7: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

VRML file structure

The estimated rotation is stored as following format:

x y z θ:

-0.834774 -0.550554 -0.00660719 0.0287507

We need to convert to rotation matrix using following formula:

Q (θ) =

7

Page 8: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

ICP registration of all VRMLs

8

Page 9: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Point matching using ICP algorithm

We separated our ICP implementation into following steps: Phase 0: Apply initial transformation to the target

cloud

Phase 1: Find the Approximate Nearest Neighbor.

Phase 2: Find the geometric centroid of the accepted point pair.

Phase 3: Apply Singular Value Decomposition(SVD).

Phase 4: Find out rotation matrix and translation matrix based on the result from SVD.

Phase 5: Calculate new average distance

9

Page 10: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 0: Apply initial transformation to the target cloud

ICP algorithm proposed by [Bsel et. al 1992] require a explicitly defined initial guess with reasonable accuracy.

We will need to apply the rotation matrix and translation matrix to every points in target cloud using following equation: Tn = R × To + T

Tn: 1 by 3 matrix. Shifted new axis.

R: 3 by 3 matrix. Rotation matrix.

To: 1 by 3 matrix. Original axis.

T: 1 by 3 matrix. Translation matrix.

10

Page 11: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 1: Find the Approximate Nearest Neighbor

The most important step in the ICP algorithm

For each point in the target cloud, find a point which has minimum Euclidean distance.

Brute-force approach: Relatively trivial with just 2 nested for loops

O(n2) running time

150,000 point in each VRML file.

22.5 billion loops to match a cloud!

Unacceptable in a productionenvironment

11

Page 12: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 1: Find the Approximate Nearest Neighbor

We use “ANN”: A LGPL library from University of Maryland was designed to solve Approximate Nearest Neighbor problem.

The algorithm can be ~100 times faster than brute-force approach.

ANN store points as KD-tree internally

Require one time initialization. O(n log2 n) running time

Each query of nearest point took O(n1-1/k +m)

Allow user to specify a maximum error bond and distance

12

Page 13: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 2: Find the geometric centroid

We will need to find out the geometric centroid of the matched base cloud and target cloud using the following equation, respectively.

Where x denote the base cloud and p denote the target cloud

13

Page 14: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 3: Apply Singular Value Decomposition(SVD)

We need to calculate the rotation and translation matrix in this phase.

There exist several proposal for doing this: Quaternions [Horn, 1987]

Orthonormal matrices [Horn et al., 1988]

Dual quaternious [Walker et al., 1991]

SVD [Bsel and McKay, 1992]

Bsel suggest that using Singular Value decomposition is more robust and easier to implement.

SVD is frequently used in radio signal and image processing

14

Page 15: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 3: Apply Singular Value Decomposition(SVD)

Given:

A: m * n, the shifted match point set from previous step

We could find out:

U: m * m unitary matrix UUT=I

Σ: m * n diagonal matrix

VT: n* n unitary matrix VVT=I

In our 3D case m and n will be both 3.

The result might not be unique.

15

Page 16: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 3: Apply Singular Value Decomposition(SVD)

We use the following pseudo code to generate A

FOR ALL matched point pair AS i:

A’ = A + (#i point in base cloud – geometric center of base cloud) *(#i point in target cloud - geometric center of target cloud)

Notice all operation above is matrix operation.

By applying SVD to matrix A, we shall be able to find out U, Σ and VT , which will be used in the following step.

16

Page 17: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 4: Find out rotation and translation matrix

We receive U, Σ and VT from the SVD library.

We can find the Rotation Matrix by: R = U VT

R will be a 3 by 3 matrix in our case

And the translation matrix could be find out by: T = Bc - Tc × R

Where Bc and Tc is the matrix representation of the geometric center of base cloud and target cloud, respectively.

T will be 1 by 3 in our case

17

Page 18: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 5: Calculate new average distance

In this step, we will try to find out the new average distance between base cloud and transformed target cloud.

New target can be calculated by applying the following formula to all points in the target cloud:

TPCn = R * TPCo + T

Where TPCn and TPCo are the matrix representation of the new and old point cloud respectively

18

Page 19: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 5: Calculate new average distance

We shall sum up all Euclidean distance of matched point pairs of base cloud and transformed target cloud using:

If the result is smaller than 0.0012, two point cloud will shows a reasonable match. Other wise if the loop counter is smaller than 20, go back to phase 1.

The following slide shows that after 20 time of iterative process, the improvement where almose unobserable

19

Page 20: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Phase 5: Calculate new average distance

20

Page 21: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Visualization

The previous step calculated the transformed new target cloud .

A good user interface is vital for demonstrating the correctness of our program as well as helping us to debug.

Each result contains ~400,000 points

We evaluated two virtualization interface: GNUPlot and SoWin

Due to performance consideration we decided to use the later one.

21

Page 22: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Visualization

GNUPlot: GPL

Cross platform

Based on X11

No OpenGL or 3D accelerator support

Very easy to render: splot "pcplot.dat" with

dots

Each rotation and zooming took 5 second

22

Page 23: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Visualization

SoWin from Coin3D: GPL

Written in C++

MFC only, but offer SoQtand SoXt with similar interface

Support OpenGL with hardware acceleration

Offer convenient user interface

Complicated API structure.

23

Page 24: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Performance and difficulty:ICP stuck in local optimize dilemma

Bsel mentioned that ICP requires a reasonable initial estimation.

ICP only finds local optimal instead of global optimization

Running large amount of iterative process does not help.

24

Page 25: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Performance and difficulty:Code complexity

C++ did not define a standardized representation of matrix data structure

Different libraries use their own ways to store matrix and are usually not interchangeable.

A significant portion of our code are related to matrix data conversion and manipulation.

Using scripting language such as Matlab might simplify our code but degrade the performance.

25

Page 26: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Performance and difficulty:Performance issue under different platform

We observe an interest fact that our program runs 2x faster under Linux

Due to heavy relies on 8 bytes floating point operation, compiling using SSE2, SSE3 optimizing or under x64 environment might benefit to the performance.

Matching pc_vrml000.rml and pc_vrml001.rml

OS Total run time ANN Other code

Windows 1265.132ms 1100.756ms 164.376ms

Linux 603.925ms 548.639ms 55.286ms

26

Page 27: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Conclusion

ICP is one of the most popular 3D matching algorithm for real-time purpose.

We demonstrated that ICP algorithm can correctly estimated the rotation and translation if : Initial guess is reasonable accurate

The ICP algorithm are only able to finds local optimum.

The ANN library provides a reasonable runtime and memory consumption for calculation nearest neighbor problem.

27

Page 28: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Outlook

Consider that a laser range scanner mounted on a Google Street View Car

It might be difficult to give an accuracy estimated transformation.

What if…

we have inaccurate or no estimated translation?

[Rusinkiewicz et al., 2002] and [Turk and Levoy, 1994] provide feasible alternative to the ICP algorithm

ICP could also being applied to line segment, triangle, curves and surface as well.

28

Page 29: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Reference

[Besl and McKay, 1992] Paul J. Besl and Neil D. McKay. A method for registration of 3-d shapes. IEEE Trans. Pattern Anal. Mach. Intell., 14(2):239–256, 1992.

[Rusinkiewicz et al., 2002] Szymon Rusinkiewicz, Olaf Hall-Holt, and Marc Levoy. Real-time 3d model acquisition, 2002.

[Turk and Levoy, 1994] Greg Turk and Marc Levoy. Zippered polygon meshes from range images. In SIGGRAPH ’94: Proceedings of the 21st annual conference on Computer graphics and interactive techniques, pages 311–318, New York, NY, USA, 1994. ACM.

29

Page 30: 3D ICP-BASED SCAN MATCHER IMPLEMENTATIONais.informatik.uni-freiburg.de/.../mr2-p7-slides.pdf · VRML file structure Our instructor provide us 131 VRML files containing laser scan

Reference

[Horn, 1987] Berthold K. P. Horn. Closed-form solution of absolute orientation using unit quaternions. Journal of the Optical Society of America A, 4(4):629–642, 1987.

[Horn et al., 1988] Berthold K. P. Horn, H.M. Hilden, and Shariar Negahdaripour. Closed-form solution of absolute orientation using orthonormal matrices. JOURNAL OF THE OPTICAL SOCIETY AMERICA, 5(7):1127–1135, 1988.

[Walker et al., 1991] Michael W. Walker, Lejun Shao, and Richard A. Volz. Estimating 3-d location parameters using dual number quaternions. CVGIP: Image Underst., 54(3):358–367, 1991.

30