Point Clouds

A LiDAR sweep is a list of x, y, z points in no order. You can list sixty-four points in about 1.3 × 1089 orders, and a network must give the same answer for all of them. A shared MLP followed by a max does.

Pick a shape, then press Shuffle rows. The grey model reads the points as one long list. The warm model scores each point alone and keeps the largest value of each feature. Then drop points with the slider. After that we build, piece by piece, the scan, the voxel grid, neighbours, normals, PointNet, PointNet++ and registration.

You need Python with numpy arrays and what a dot product is. We build the rest from zero.

Shuffle the rows, keep the shape

64

Illustrative toy. Both models are nearest-template classifiers on hand-made shapes, not trained networks. The grey one compares row i with template row i. The warm one uses PointNet's form: the same 24 features on every point, a max over points, then a comparison of the 24 maxima.

Chapter 0

No Grid, No Order

See why a list of points breaks the tools that work on images

A car's LiDAR spins ten times a second. Each turn returns about 100,000 dots, each one a place where a laser hit something. You store them as an array with one row per dot. That array is a point cloud: a set of N points, each an (x, y, z) position. Some clouds add numbers, such as the strength of each echo.

An image is a grid, so every pixel has a fixed neighbour to its right. A convolution slides a small filter over that grid. A point cloud has no grid. Point 7 has no "point to the right".

The rows also have no order. The sensor writes them in firing order, but a shuffled array is the same cloud. So a network that reads the array as one long vector sees a new input after every shuffle. It must give the same answer for all N! orders (N factorial: N × (N − 1) × … × 1).

Shuffle the array, keep the cloud

Each point shows its row number. Press Shuffle: the rows move, the dots do not. Raise N and watch the count of orders explode.

6

Made-up points. The count of orders is exact: N! for N different points.

Work the number. With 6 points there are 6! = 720 orders. With 10 there are 3,628,800. With 1,024 points, the size PointNet used, the count has 2,640 digits. No training set can show a network every order.

The obvious fix is to drop the points into a 3D grid of small cubes and run a 3D convolution. That works, but most cubes are empty, because a scan only touches surfaces. Chapter 2 uses a grid for a different job: to thin the cloud.

The failure, as symptom, measurement and fix

The symptom is a model that is right in testing and wrong in use, after a new driver writes the points in another order. To measure it, run the model on the same cloud ten times, shuffled each time, and compare the outputs. The fix is an architecture whose output cannot depend on order (Chapter 5).

The road

  1. From a scan to points: angles and a range become x, y, z.
  2. The voxel grid: thin the cloud, one point per cube.
  3. Neighbours: the ball query, k nearest and the k-d tree.
  4. Normals from PCA: which way a surface faces.
  5. Symmetric functions: the reason the hero's warm model ignores order.
  6. PointNet: shapes, weights and critical points.
  7. Local structure: farthest point sampling, PointNet++ and point transformers.
  8. Registration: point-to-plane ICP, live.
  9. The field guide: terms, numbers, code and links.
Why can a plain MLP on the flattened N × 3 array not handle point clouds well?

Chapter 1

From a Scan to Points

Turn two angles and a range into x, y, z, and see why far surfaces get few points

A spinning LiDAR has a column of lasers, each at a fixed angle above or below the horizon. The column spins and each laser fires many times per turn. Every echo gives a range: how far the light went.

The KITTI driving dataset used a Velodyne HDL-64E: 64 lasers, 10 turns a second, about 100,000 points per turn. So each laser fires about 100,000 / 64 = 1,562 times per turn, one shot every 360 / 1,562 = 0.23°.

Each echo arrives as three numbers. Call the range r, the turn angle around the vertical axis the azimuth θ (theta), and the laser's angle above the horizon the elevation φ (phi). A point below the horizon has a negative φ.

Say it aloud

x equals r cos phi cos theta; y equals r cos phi sin theta; z equals r sin phi.

x
x forward, along the sensor's zero direction, in metres. The sensor is at the origin.
y
y sideways, to the left of the sensor's zero direction.
z
z height above the sensor, in metres.
r
r the range: the distance the light travelled to the surface.
cos φ
cos phi the share of the range that lies flat. Steep beams have less.
sin φ
sin phi the share of the range that goes up or down.
cos θ
cos theta splits the flat part onto the x axis.
sin θ
sin theta splits the flat part onto the y axis.
In plain words

Split the range r into a flat part, r cos phi, and a height, r sin phi. Then split the flat part between x and y by the azimuth theta.

With numbers

With made-up numbers: r = 20 m, θ = 30°, φ = −10°. The flat part is 20 × 0.985 = 19.70 m.

x = 19.70 × 0.866 = 17.06 m. y = 19.70 × 0.5 = 9.85 m. z = 20 × (−0.174) = −3.47 m: 3.47 m below the sensor.

Count the rings on the road

Each line is one laser seen from the side. Its dot is where it hits the road. Pick the number of lasers, then slide the distance and read the gap between rings there.

12 m

Illustrative layout: the sensor sits 1.7 m above a flat road and its lasers are spread evenly from +2° to −24.8°. Real sensors space their lasers unevenly. The 0.23° shot spacing follows from the KITTI figures above.

Work the rings with the device's spacing: 64 lasers over 26.8° sit 0.43° apart. A laser at −8° hits the road at 1.7 / tan 8° = 12.1 m. The next laser, 0.43° lower, hits at 11.5 m: a gap of 0.6 m. Near the horizon, lasers at −2.00° and −2.43° hit at 48.7 m and 40.1 m: a gap of 8.5 m. Along each ring, shots 0.23° apart sit 0.05 m apart at 12 m and 0.20 m apart at 49 m.

So density falls with range: a near car gets many points, the same car far away a few. Every method here must cope with that.

The failure, as symptom, measurement and fix

The symptom is a detector that finds near cars and misses far ones. To measure it, plot recall against distance in 10 m bins. The fix starts with the data: train on far examples too, and use neighbourhoods measured in metres, not in point counts (Chapter 3).

A beam has range 10 m and elevation 0°, azimuth 90°. Where is the point?

Chapter 2

The Voxel Grid: One Point per Cube

Thin a cloud by cutting space into cubes and keeping one average point in each

The road near the car holds thousands of points in a few square metres. Far walls hold a handful. Most later steps cost time per point, so the dense patch wastes work and also outvotes the rest.

A voxel is a small cube of space, a 3D pixel. A voxel grid filter cuts space into cubes of side s and replaces all the points in each cube with their average, the centroid. Dense patches shrink a lot. Sparse ones barely change.

To find a point's cube, divide each coordinate by s and round down. Call the point (x, y, z) and its cube's integer label (i, j, k).

Say it aloud

i, j, k equals the floor of x over s, the floor of y over s, and the floor of z over s.

i, j, k
i, j, k the cube's label: three whole numbers. Points with the same label share a cube.
x, y, z
x, y, z the point's position, in metres.
s
s the voxel size: the side of each cube, in metres.
⌊ ⌋
the floor of round down to the whole number below. The floor of 1.24 is 1; the floor of −0.3 is −1.
In plain words

Divide x, y and z by the voxel size s and round each down. Group the points by the three labels i, j, k. Replace each group by its average point.

With numbers

With made-up points and s = 0.25 m: (0.12, 0.31, 0.05) and (0.18, 0.27, 0.09) both get label (0, 1, 0). Their centroid is (0.15, 0.29, 0.07). In the table below, 5 points become 3.

Pointx, y, z (m)Label i, j, kCentroid of its cube
10.12, 0.31, 0.050, 1, 00.15, 0.29, 0.07
20.18, 0.27, 0.090, 1, 00.15, 0.29, 0.07
30.45, 0.05, 0.021, 0, 00.43, 0.08, 0.04
40.41, 0.11, 0.061, 0, 00.43, 0.08, 0.04
50.30, 0.30, 0.041, 1, 00.30, 0.30, 0.04

Thin one sweep

Blue dots are one sweep seen from above; the sensor is the yellow ring. Slide the voxel size and watch the warm centroids. Find where the pillar by the top wall merges with it. Where the cube edges fall matters too.

0.30 m

Illustrative 2D sweep: one shot every 1° in a 10 m by 6 m room with a 0.15 m pillar near the top wall. The 3D filter works the same way with cubes.

In code, the labels become a key and one group-by does the rest: keys = np.floor(P / s), then average the rows that share a key. It costs one pass over the points, so it runs on every sweep.

The failure, as symptom, measurement and fix

The symptom is a pole or a thin person that vanishes from the thinned cloud. The cube is larger than the object, so the object's few points merge with the ground. To measure it, overlay the thinned cloud on the raw one at the smallest object you care about. The fix is a voxel smaller than that object.

With s = 0.5 m, which cube label does the point (1.2, −0.3, 0.7) get?

Chapter 3

Neighbours: Ball or k Nearest

Gather the points near a query, by distance or by count, and find them fast

A single point says nothing about shape. Is it on a flat road, a curb or a pole? You can only tell from the points around it. Normals, PointNet++ and ICP all start by asking: which points are near this one?

There are two ways to ask. The ball query returns every point within a radius r of the query point q. The k nearest neighbours (kNN) query returns the k closest points, near or far. Call the cloud's points pj, numbered by j.

Say it aloud

N-r of q equals the set of all j such that the length of p-j minus q is at most r.

Nr(q)
N-r of q the neighbourhood: the list of point numbers inside the ball.
j
j a point's row number in the cloud.
pj
p-j point number j, an (x, y, z) position.
q
q the query point: where we stand.
‖ · ‖
the length of the straight-line distance: the square root of dx squared plus dy squared plus dz squared.
r
r the radius of the ball, in metres.
In plain words

For each point p-j, measure its distance to q. Keep j if the distance is at most r. To compare, you can skip the square root and test the squared distance against r squared.

With numbers

With made-up points around q = (0, 0, 0) and r = 0.3 m: the distances are 0.224, 0.332, 0.250, 0.500 and 0.245 m. Points 1, 3 and 5 pass. Nr(q) has 3 members.

Ask for neighbours near and far

Tap anywhere to move the yellow query. Compare the ball with k nearest, first near the sensor, then at the far wall.

0.30 m
10

The same illustrative sweep as Chapter 2, without thinning.

Near the sensor, a 0.3 m ball holds about 20 points. At the far wall it holds two. kNN always returns k points, but far away they can span most of a metre and mix two surfaces. PointNet++ chose the ball because its size in metres stays fixed everywhere.

Speed matters. Checking every point for every query costs N × N distance tests: 1010 for 100,000 points. A k-d tree splits space in half again and again, along x, then y, then z. A query then walks about log2 N levels, about 17 for 100,000 points. All queries together cost about N log2 N = 1.7 million steps, roughly 6,000 times fewer.

The failure, as symptom, measurement and fix

The symptom is normals and features that look fine nearby and noisy far away. To measure it, histogram the neighbour count per point against range. The fix is a ball radius sized for the far points, a minimum count, or both.

At the far wall a 0.3 m ball finds 2 points, and k = 10 reaches 1.2 m. What does that tell you?

Chapter 4

Normals From PCA

Find which way a surface faces from the spread of a point's neighbours

Where is the road flat, and where does a curb rise? Each point needs a normal: the direction straight out of the surface. Road normals point up; a curb face's point sideways.

On a flat patch, a point's neighbours spread wide in two directions and hardly at all in the third. That thin direction is the normal. PCA (principal component analysis) finds it from a 3 × 3 table of spreads, the covariance matrix.

Call the k neighbours pj and their average p̄ (p-bar). Call the covariance matrix C.

Say it aloud

C equals one over k times the sum over j of, p-j minus p-bar, times p-j minus p-bar transposed.

C
C the covariance matrix: a 3 by 3 table of how the neighbours spread along each pair of axes.
k
k the number of neighbours.
Σj
the sum over j add one term for each neighbour.
pj
p-j neighbour number j, a column of three numbers.
p̄
p-bar the average of the neighbours.
⊤
transposed lay the column on its side as a row, so column times row makes a 3 by 3 table.
In plain words

Subtract p-bar from each neighbour p-j. Multiply each result, as a column, by itself as a row. Add the k tables and divide by k. That average table is C.

With numbers

With made-up neighbours on a gentle slope: (0, 0, 0), (1, 0, 0.1), (0, 1, 0), (1, 1, 0.1), (0.5, 0.5, 0.05). Then p̄ = (0.5, 0.5, 0.05). C = [[0.2, 0, 0.02], [0, 0.2, 0], [0.02, 0, 0.002]].

The directions of spread are C's eigenvectors v, each with an eigenvalue λ (lambda): the spread along it. Number them from small to large: λ0 ≤ λ1 ≤ λ2. The normal n is the eigenvector of the smallest, and the surface variation σ (sigma) says how far the patch is from flat.

Say it aloud

C times v equals lambda times v; n equals v-zero; sigma equals lambda-zero over lambda-zero plus lambda-one plus lambda-two.

C
C the covariance matrix from above.
v
v an eigenvector: a direction that C does not turn, only stretches.
λ
lambda an eigenvalue: the spread of the neighbours along v, in square metres.
n
n the normal: a direction of length 1 out of the surface.
v0
v-zero the eigenvector with the smallest eigenvalue: the thinnest direction.
σ
sigma the surface variation: 0 for a perfect plane, up to one third for a blob.
λ0
lambda-zero the smallest spread.
In plain words

Ask numpy for the eigenvectors and eigenvalues of C. The eigenvector with the smallest eigenvalue, lambda-zero, is the normal n. Divide lambda-zero by the sum of all three to get sigma.

With numbers

For the C above: λ = 0, 0.200, 0.202. So n = (−0.0995, 0, 0.995), the slope's true normal (−0.1, 0, 1) scaled to length 1, and σ = 0. Lift the middle point to z = 0.25: λ0 = 0.0063 and σ = 0.0155. The bump shows.

Estimate a normal by hand

Tap a point. The purple ellipse shows the neighbours' spread; the arrow is the thin direction. Try the step corner, then raise the noise and the radius.

0.30 m
0.010 m

Illustrative 2D profile, so C is 2 by 2 and σ runs from 0 to one half. We flip normals to face the sensor, which sits above the scene.

PCA gives a direction, not a side: v and −v are both eigenvectors. Flip each normal to face the sensor, which saw that side.

The failure, as symptom, measurement and fix

The symptom is normals that lean at every edge, so a curb looks like a ramp. The neighbourhood straddles two surfaces. To measure it, map σ: edges light up. The fix is a smaller radius at edges, or to trust only normals with a small σ.

A point's neighbours give eigenvalues 0.0001, 0.05 and 0.06. What do you know?

Chapter 5

Symmetric Functions Ignore Order

Score each point with the same small network, then combine with an operation that cannot see order

We want a network whose answer survives any shuffle of the rows. Some operations already behave that way. 3 + 5 + 2 is 2 + 3 + 5, and the largest of (3, 5, 2) is the largest of (2, 3, 5).

A symmetric function gives the same output for any order of its inputs. Sum, mean and max are symmetric. Gluing the inputs end to end, called concatenation, is not.

The recipe has two steps. First run the same small network on every point alone. Call it h, the shared MLP: it turns one point xi into a feature vector. Then take the largest value of each feature over all points, a max-pool. A last network γ (gamma) reads that summary. Call the whole cloud S and the output f(S).

Say it aloud

f of S equals gamma of, the max over i of h of x-i.

f(S)
f of S the network's output for the cloud S, for example class scores.
γ
gamma a final MLP that reads the pooled vector.
maxi
the max over i for each feature, keep the largest value over all points. One number per feature survives.
h
h the shared MLP: the same weights on every point.
xi
x-i point number i, its (x, y, z).
In plain words

Run h on each point x-i to get a row of features. Stack the rows. Take the largest value in each column. Feed that one row to gamma. Shuffling the points shuffles the rows but not the column maxima.

With numbers

With made-up weights: h(x) = ReLU of (x1, x2, x1 − x2). Points (0.2, 0.9), (0.7, 0.1), (0.5, 0.5) give rows (0.2, 0.9, 0), (0.7, 0.1, 0.6), (0.5, 0.5, 0). The column maxima are (0.7, 0.9, 0.6), in every order.

Shuffle, then combine

Each row holds one point's three features. Pick how to combine the rows, then press Shuffle. Red marks every output slot that changed.

The three points and weights are the made-up numbers above.

Why max and not sum? A sum grows with the number of points, so a dense scan of a chair looks unlike a sparse one. A max acts as a detector: each feature reports the one point that shows it most. The PointNet authors compared max, average and an attention-weighted sum, and max won by a wide margin.

The PointNet paper also proves that this form is enough. Take any continuous function of a set: one that changes little when the points move a little. Some γ of a max of h comes as close to it as you like, given enough features.

The failure, as symptom, measurement and fix

The symptom is a model whose output shifts when you resample the same object with more points. A mean or a sum crept in where a max belonged, or batch statistics mix points across clouds. To measure it, score one object at 512, 1,024 and 2,048 points. The fix is a max, or a mean if density truly carries meaning.

Which combination of per-point feature rows gives an output that cannot change when the points are shuffled?

Chapter 6

PointNet: Shapes, Weights and Critical Points

Follow the tensor shapes through PointNet and find the few points that decide its answer

PointNet (Qi, Su, Mo and Guibas, 2017) is the recipe of Chapter 5 at full size. The table follows one cloud of N points through the classification network. N can change from cloud to cloud; no weight depends on it.

StepWhat it doesOutput shape
InputN points, x, y, z eachN × 3
Input T-Neta small network predicts a 3 × 3 matrix that turns the cloud to a standard poseN × 3
Shared MLP (64, 64)the same two layers on every pointN × 64
Feature T-Neta 64 × 64 matrix aligns the featuresN × 64
Shared MLP (64, 128, 1024)three more layers per pointN × 1024
Max-poolthe largest of each column1024
MLP (512, 256, k)γ: class scoresk

For segmentation, a label for every point, PointNet glues the 1,024 global numbers onto each point's 64 local features. Each point then sees itself and the whole shape: N × 1088. More shared layers end in one label per point.

Count the weights of the shared layers. A layer from din to dout numbers has (din + 1) × dout weights, counting one bias per output. The five layers, 3→64→64→64→128→1024, hold 256 + 4,160 + 4,160 + 8,320 + 132,096 = 148,992 weights. That is the same for 100 points or 100,000. A flattening MLP's first layer, from 1,024 points to 64 units, needs (3,072 + 1) × 64 = 196,672 weights. It accepts only 1,024 points in one order.

Critical points

Each of the 1,024 columns keeps one winner. So at most 1,024 points decide the global feature, whatever N is. The paper calls them the critical point set: delete any other point and the output does not move. The number of features, the bottleneck dimension, caps its size.

Find the points that decide

Each feature probes one direction; its winner is a warm dot. Slide the feature count. Then delete everything else, or drop a random half, and read how far the global feature moves.

16

Illustrative: our features are straight-line probes, so the winners sit on the outer edge. PointNet's learned features also pick inner points; its Figure 7 shows critical sets that trace a skeleton of each shape.

This explains PointNet's robustness. On ModelNet40 (12,311 CAD models in 40 classes, 1,024 points each) it reached 89.2% accuracy. With half the points missing, accuracy fell by only 2.4 points with farthest-point sampling and 3.8 points with random sampling. The input T-Net added 0.8 points over no alignment.

The failure, as symptom, measurement and fix

The symptom is a model that is confident on whole objects and fooled by a few stray points far from the object. A stray point can win a column. To measure it, add 10 random outlier points and watch the scores. The fix is to clean outliers first, by removing points with too few neighbours.

A PointNet has a 1,024-wide max-pool and reads a cloud of 5,000 points. At most how many points decide its global feature?

Chapter 7

Local Structure: PointNet++ and Point Transformers

Pick spread-out centres, run a small PointNet on each neighbourhood, and repeat

A CNN sees an edge, then a corner, then a wheel, then a car. Each layer looks at a small patch of the layer below. PointNet jumps from single points to the whole cloud in one max. It never sees a corner as a corner.

PointNet++ (Qi, Yi, Su and Guibas, 2017) adds patches. One set abstraction level does three things:

  1. Sample a few centres, spread over the cloud.
  2. Group the points within a ball around each centre, and rewrite their positions relative to that centre.
  3. Summarise each group with a small PointNet. Each centre now carries a feature for its patch.

The next level repeats on the centres with a larger ball. The classification network uses 512 centres with radius 0.2, then 128 centres with radius 0.4, on clouds scaled into a unit ball.

Random centres bunch up in dense regions. Farthest point sampling (FPS) picks each new centre as far as possible from those already chosen. Call the chosen centres c1 to cm.

Say it aloud

c m-plus-one equals the argmax over j of, the min over i up to m of the length of p-j minus c-i.

cm+1
c m-plus-one the next centre to pick.
argmaxj
the argmax over j try every point j and keep the one with the largest value.
mini ≤ m
the min over i up to m the distance to the nearest centre chosen so far.
pj
p-j a candidate point of the cloud.
ci
c-i centre number i, already chosen.
‖ · ‖
the length of the straight-line distance.
In plain words

For each point p-j, find its distance to the nearest centre c-i chosen so far. Pick the point where that distance is largest. Add it as the next centre and repeat.

With numbers

With made-up points (0, 0), (1, 0), (4, 0), (5, 0), (2, 3), start at c1 = (0, 0). The distances are 0, 1, 4, 5, 3.61, so c2 = (5, 0). Nearest-centre distances become 0, 1, 1, 0, 3.61, so c3 = (2, 3).

Pick centres two ways

Warm dots are centres, yellow rings their balls. Compare farthest point with random, and count the blue points no ball reaches.

12
0.15

Illustrative cloud of 400 points in a unit square: 250 in a dense cluster, 150 spread thin. Random centres use a fixed seed.

PointNet++ raised ModelNet40 accuracy from PointNet's 89.2% to 90.7%, and to 91.9% when it also read surface normals and used 5,000 points.

Point transformers

Inside each patch, PointNet++ still pools with a max. A point transformer (Zhao, Jiang, Jia, Torr and Koltun, 2021) replaces the max with attention. Each point weighs its neighbours by their features and by their offset in space. On the S3DIS indoor scene benchmark it reached 70.4% mean intersection over union on Area 5.

ModelNeighbourhoodHow it combines a patch
PointNetthe whole cloudone max over all points
PointNet++a ball around each FPS centrea small PointNet, max inside the ball
Point transformereach point's nearest neighboursa weighted sum, weights from features and relative position

The failure, as symptom, measurement and fix

The symptom is a model that does well on evenly sampled CAD shapes and poorly on real scans, which are dense near the sensor. To measure it, test on clouds thinned unevenly by range. The fix in PointNet++ is to group at several radii and let the network weigh them.

Why does PointNet++ pick centres by farthest point sampling and not at random?

Chapter 8

Registration: Point-to-Plane ICP

Align a new scan to a known one, and let points slide along walls

A robot drives a metre and scans again. The new scan shows the same walls, turned and shifted. Registration finds the rotation R and shift t that lay the new scan, the source, onto the old one, the target.

Iterative closest point (ICP; Besl and McKay, 1992) repeats two steps. Pair each source point with its nearest target point. Then find the R and t that best close the pairs, apply them, and repeat. AA 274A Lesson 7 works the classic version by hand with the SVD.

The classic point-to-point error has a flaw. Two scans hit a wall at different spots, so even at the true pose each pair has a sideways gap. ICP tries to close it and creeps. Point-to-plane ICP (Chen and Medioni, 1991) measures only the gap along the target's normal ni (Chapter 4). Call source point i pi, its partner qi, and the total error E.

Say it aloud

E of R and t equals the sum over i of, R p-i plus t minus q-i, dot n-i, all squared.

E(R, t)
E of R and t the total error for one guess, in square metres.
Σi
the sum over i add one term for each pair.
R
R the rotation we solve for.
pi
p-i source point i, from the new scan.
t
t the shift we solve for, in metres.
qi
q-i its nearest target point.
·
dot the dot product: the part of the gap along n-i.
ni
n-i the target surface's normal at q-i, length 1.
In plain words

Move source point p-i by R and t. Take its gap to q-i, keep only the part along n-i, and square it. Add over all pairs. Choose R and t to make E smallest.

With numbers

With made-up numbers: a moved point at (1.3, 2.1), its partner at (1.0, 2.0) on a floor with n = (0, 1). The gap is (0.3, 0.1). Point-to-point counts 0.09 + 0.01 = 0.10. Point-to-plane counts 0.1 squared = 0.01: the slide along the floor is free.

For a small turn, E becomes a least-squares problem in three numbers: the angle and the two parts of t. One np.linalg.lstsq call solves it.

Register two scans

Pick a method and press Run. The plot shows the angle error per iteration for both methods. Then raise the starting turn until one of them locks on wrong.

20°
0.010 m

Illustrative 2D scans of a 4 m by 2.4 m L-shaped room. The target has a point every 0.1 m; the source is 100 points at random spots, so no pair matches exactly. Normals come from PCA on 6 neighbours. The start shift grows with the turn.

We ran this toy on ten random scans. From a 20° start, point-to-plane came within 0.1° in 3 or 4 iterations; point-to-point needed 9 to 16 to reach 1°. From 60° on, point-to-point locked on wrong every time, point-to-plane once.

The failure, as symptom, measurement and fix

The symptom is a confident wrong pose. ICP finds the best pose near its start; in a corridor, sliding is free, so the position along it is unknown. Compare the result with odometry. The fix is a good starting guess and walls in more than one direction.

Two scans of a flat floor sample it at different spots. Why does point-to-plane ICP settle faster than point-to-point?

Chapter 9

Field Guide

Keep the terms, the numbers, the code and the next steps in one place

A point cloud is an unordered set of positions on surfaces, dense near the sensor and sparse far away. Thin it with a voxel grid, find neighbours with a ball or kNN, and read surface direction from PCA. Learn on it with a shared per-point network and a symmetric pool, then add locality. Align two clouds with ICP, and use the normals to let points slide.

TermMeaningNumber to remember
Scan to pointx = r cos φ cos θ, y = r cos φ sin θ, z = r sin φ20 m, 30°, −10°: (17.06, 9.85, −3.47)
KITTI LiDARVelodyne HDL-64E64 lasers, 10 Hz, about 100,000 points per turn
Voxel label⌊x / s⌋ per axis, then average5 points, s = 0.25 m: 3 centroids
Ball queryall points within r of qk-d tree: about 17 levels for 100,000 points
Normaleigenvector of the smallest eigenvalue of Cslope (−0.1, 0, 1): n = (−0.0995, 0, 0.995)
Symmetric poolf(S) = γ(maxi h(xi))rows→column maxima (0.7, 0.9, 0.6) in any order
PointNetshared MLP, max-pool, MLP148,992 shared weights; ModelNet40 89.2%
Critical pointsthe winners of the max-poolat most K, the pool width (1,024)
PointNet++FPS centres, ball groups, mini PointNets90.7%; 91.9% with normals
Point transformerlocal attention with relative positionS3DIS Area 5: 70.4% mIoU
Point-to-plane ICPminimise Σ ((R p + t − q) · n)2gap (0.3, 0.1) on a floor: 0.01, not 0.10

Which 3D form to use

FormWhat it storesGood forCost
Point cloudsurface samplesraw sensor data, detection, registrationneeds set networks; no surface
Voxel gridoccupied cubes3D convolution, mappingmemory grows with volume; most cubes empty
Meshvertices and trianglesgraphics, simulationhard to get from noisy scans
Gaussians or a neural fielda learned scenephotoreal new viewstraining per scene

Checklist for a point-cloud pipeline

The core, in code

python
import numpy as np

def voxel_down(P, s):                       # P: N x 3, s: voxel size in m
    keys = np.floor(P / s).astype(np.int64)      # N x 3 cube labels
    _, inv = np.unique(keys, axis=0, return_inverse=True)
    inv = inv.ravel()
    sums = np.zeros((inv.max() + 1, 3)); np.add.at(sums, inv, P)
    return sums / np.bincount(inv)[:, None]   # M x 3 centroids

def normal(nbrs):                            # nbrs: k x 3
    d = nbrs - nbrs.mean(0)
    C = d.T @ d / len(nbrs)                      # 3 x 3 covariance
    lam, V = np.linalg.eigh(C)                   # eigenvalues small to large
    return V[:, 0], lam[0] / lam.sum()          # normal, surface variation

def pointnet_feature(P, layers):             # layers: list of (W, b)
    h = P                                        # N x 3
    for W, b in layers:                          # the same weights on every row
        h = np.maximum(0, h @ W + b)             # N x d_out
    return h.max(0)                             # K numbers: any row order gives the same

def fps(P, m):                                # farthest point sampling, m centres
    idx = [0]; d = np.linalg.norm(P - P[0], axis=1)
    for _ in range(m - 1):
        j = int(d.argmax()); idx.append(j)
        d = np.minimum(d, np.linalg.norm(P - P[j], axis=1))
    return P[idx]

Keep going

Sources: Qi et al., PointNet (CVPR 2017); Qi et al., PointNet++ (NeurIPS 2017); Zhao et al., Point Transformer (ICCV 2021); the KITTI sensor setup.

The takeaway. A point cloud has no grid and no order. Respect both: measure neighbourhoods in metres, pool with a function that cannot see order, and let normals carry the surface.

Now press Present or Teach. Explain from memory: the scan, the voxel label, the ball query, the normal, why a max ignores order, critical points, FPS and point-to-plane ICP. Then go back to the shapes, shuffle the rows, and say why only one model stays put.

Point Clouds · Deep Learning on 3D Sets
Back to Gleams