Search

Search papers and lessons

Point Cloud

Level 2 · 10 min read

A point cloud is a set of 3D points sampled from the surfaces of a scene, usually produced by a lidar or a depth camera, with no grid or connections between them.

On this page

  • Colour = topic mix
  • Linear algebra
  • Computer vision
  • Discrete math
  • Perception
  • Sign in to see your progress

TL;DR

A point cloud is a list of 3D points, each with an x, y and z coordinate, sampled from the surfaces of objects around a sensor. Nothing says which point is next to which. The sensor only reports where it hit something. Robots use point clouds because a laser scanner or depth camera gives them the shape of a scene directly, and the points can be moved, merged and compared with simple arithmetic.

Where you'll see it: the raw output of lidar sensors on self-driving cars and mobile robots, the depth data from RGB-D cameras used for grasping, and the map that a robot builds while it moves through a building.

Intuition

A scene as a pile of dots

Imagine lighting up a room with a flashlight that blinks at thousands of random spots, and at each blink you record the spot's position in space. After a few seconds you have a cloud of dots that outlines the walls, the table and the chair. You cannot see the surfaces as solid shapes, but you can see the shape of the room in the arrangement of the dots.

That is a point cloud. A lidar does almost exactly this. It fires laser pulses in many directions, measures how long each pulse takes to come back, and turns each measurement into one 3D point. A depth camera does the same with an image grid, giving each pixel a distance and then converting it into a point.

Why not use a picture?

A depth image is a grid, and grids are easy to store. But a depth image only describes what the camera sees from one place. A point cloud can be moved into any coordinate frame, joined with points from another sensor position, and cut or filtered by position without caring about the camera that made it. Robots need the scene in the world frame, not in the camera frame, so the point cloud is the more natural format once data from several viewpoints must be combined.

A point cloud also drops information. It has no notion of a surface, a color unless you add one, or which points belong to the same object. Those things must be recovered from the points, and much of the work in robot perception is recovering them.

The math

The point set

A point cloud is a finite set

P={p1,p2,…,pN},pi=(xiyizi)∈R3,\mathcal{P} = \{\mathbf{p}_1, \mathbf{p}_2, \dots, \mathbf{p}_N\}, \qquad \mathbf{p}_i = \begin{pmatrix} x_i \\ y_i \\ z_i \end{pmatrix} \in \mathbb{R}^3,

where NN is the number of points. Here pi\mathbf{p}_i is the position of point ii in some coordinate frame, and R3\mathbb{R}^3 is the set of all 3D vectors. Often each point also carries extra values, such as a color (ri,gi,bi)(r_i, g_i, b_i), a reflected-light intensity, or a surface normal. Those are extra columns attached to each point, and the position is still the part that defines the geometry.

Two properties follow from the definition of a set. The order of the points carries no meaning, so reordering the list gives the same cloud. And there are no edges, so any structure between points, such as which ones lie on the same surface, is not stored.

From a depth pixel to a 3D point

The sensor gives a depth ZZ for each pixel (u,v)(u, v), meaning the distance along the camera's optical axis. The pinhole camera model relates pixels to 3D points. With focal lengths fxf_x and fyf_y in pixels, and a principal point (cx,cy)(c_x, c_y) where the optical axis meets the image, the 3D point in the camera frame is

X=(u−cx) Zfx,Y=(v−cy) Zfy,Z=Z.X = \frac{(u - c_x)\, Z}{f_x}, \qquad Y = \frac{(v - c_y)\, Z}{f_y}, \qquad Z = Z.

The first two equations come from similar triangles. A pixel that lies u−cxu - c_x pixels to the right of the centre corresponds to a sideways offset of (u−cx)/fx(u - c_x)/f_x at unit depth, scaled by the actual depth ZZ. Applying this to every pixel with a valid depth turns a depth image into a point cloud.

Moving clouds between frames

A point in the camera frame becomes a point in the world frame by a rigid transformation: a rotation R\mathbf{R}, which is a rotation matrix, followed by a translation t\mathbf{t}:

pworld=R pcam+t.\mathbf{p}^{\text{world}} = \mathbf{R}\, \mathbf{p}^{\text{cam}} + \mathbf{t}.

The same formula is applied to every point, so a whole cloud moves as one body. This is why point clouds from several sensor positions can be merged once each cloud's pose is known.

Distances between points

Many operations need the distance between two points. For a,b∈R3\mathbf{a}, \mathbf{b} \in \mathbb{R}^3 this is the Euclidean distance

∥a−b∥=(ax−bx)2+(ay−by)2+(az−bz)2.\lVert \mathbf{a} - \mathbf{b} \rVert = \sqrt{(a_x - b_x)^2 + (a_y - b_y)^2 + (a_z - b_z)^2}.

Finding the closest point in a large cloud to a query point is a nearest-neighbour search. Brute force costs NN distance computations per query. Spatial data structures reduce that, and approximate nearest neighbour search trades a few missed matches for a large speedup.

Worked examples

Example
Depth pixel to 3D point

A depth camera has focal lengths fx=fy=500f_x = f_y = 500 pixels and principal point (cx,cy)=(320,240)(c_x, c_y) = (320, 240). A pixel at (u,v)=(400,300)(u, v) = (400, 300) has depth Z=2.0Z = 2.0 m.

  1. Horizontal offset from the centre: u−cx=400−320=80u - c_x = 400 - 320 = 80 pixels.
  2. Vertical offset: v−cy=300−240=60v - c_y = 300 - 240 = 60 pixels.
  3. X=80×2.0/500=0.32X = 80 \times 2.0 / 500 = 0.32 m.
  4. Y=60×2.0/500=0.24Y = 60 \times 2.0 / 500 = 0.24 m.
  5. The camera-frame point is (0.32,0.24,2.0)(0.32, 0.24, 2.0) m.

The point lies a third of a metre to the right, a quarter of a metre below, and two metres ahead. Doubling the depth doubles XX and YY, which matches the picture of a ray that spreads out as it travels.

Example
Moving a point into the world frame

Continue with the point pcam=(0.32,0.24,2.0)\mathbf{p}^{\text{cam}} = (0.32, 0.24, 2.0). Suppose the camera is rotated by 90∘90^\circ about the vertical zz axis and sits at t=(1,0,0.5)\mathbf{t} = (1, 0, 0.5) m in the world frame. The rotation is

R=(0−10100001).\mathbf{R} = \begin{pmatrix} 0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{pmatrix}.
  1. Rotate: R pcam=(0⋅0.32−1⋅0.24,  1⋅0.32+0⋅0.24,  2.0)=(−0.24,0.32,2.0)\mathbf{R}\,\mathbf{p}^{\text{cam}} = (0 \cdot 0.32 - 1 \cdot 0.24,\; 1 \cdot 0.32 + 0 \cdot 0.24,\; 2.0) = (-0.24, 0.32, 2.0).
  2. Translate: add (1,0,0.5)(1, 0, 0.5) to get (0.76,0.32,2.5)(0.76, 0.32, 2.5).

The point is now at (0.76,0.32,2.5)(0.76, 0.32, 2.5) m in the world frame. Every other point of the cloud goes through the same two steps, so the whole cloud has moved with the camera.

Example
Nearest neighbour by brute force

Two points are a=(0,0,0)\mathbf{a} = (0, 0, 0) and b=(0.3,0.4,0)\mathbf{b} = (0.3, 0.4, 0) m. The distance is 0.32+0.42+02=0.09+0.16=0.25=0.5\sqrt{0.3^2 + 0.4^2 + 0^2} = \sqrt{0.09 + 0.16} = \sqrt{0.25} = 0.5 m.

For a query point q=(0.2,0.2,0)\mathbf{q} = (0.2, 0.2, 0), compare it with a\mathbf{a} and b\mathbf{b}. The distance to a\mathbf{a} is 0.04+0.04≈0.283\sqrt{0.04 + 0.04} \approx 0.283 m, and the distance to b\mathbf{b} is 0.01+0.04≈0.224\sqrt{0.01 + 0.04} \approx 0.224 m. So b\mathbf{b} is the nearer point. With N=1,000,000N = 1{,}000{,}000 points, this comparison would be repeated a million times per query, which is why large clouds need an index.

Tradeoffs and failure modes

Point clouds are simple, general and close to what sensors measure, but they have real costs.

SituationProblemBetter choice
Needs surfaces or watertight shapesA cloud has no surfaces or inside/outsideMeshes, signed distance fields or implicit surfaces
Huge cloud from a dense lidarMemory and nearest-neighbour queries are slowVoxel-grid downsampling, then an index such as a k-d tree
Sensor noise and outliersStray points distort normals and alignmentStatistical outlier removal before matching
Points not uniformly spacedDensity is high near the sensor and low far awayWeight points by local density, or resample by voxel
Needs to know which points are neighbours on a surfaceThe cloud stores no connectivityReconstruct a mesh, or use a structure that keeps the sensor's scan order
Moving sceneClouds from different times do not line upEstimate the sensor motion and transform the clouds before merging

A common failure is to merge clouds with a pose that is slightly wrong. The points then appear twice, or the walls look thick. Checking alignment by eye on a dense scene is a quick way to catch this.

History

The idea of recording a scene as a set of measured points long predates the name. Early range scanners and coordinate-measuring machines produced clouds of points on objects in manufacturing. As laser scanners and computer graphics matured in the 1980s and 1990s, point clouds became a common raw format for modelling real objects, and "point cloud" became the usual term.

For robotics the key step was algorithmic. Besl and McKay's 1992 iterative closest point method gave a way to align two clouds by repeatedly matching each point to its nearest neighbour in the other cloud and solving for the best rigid transformation. That loop, alternating matching and motion estimation, is still the basis of many registration systems. Its success made the point cloud a practical map format, and modern lidar and depth-camera pipelines are built around it.

Check yourself

QuestionWhy does a point cloud carry no notion of which point is next to which, and what does that cost?Show answer

A point cloud is stored as an unordered set of positions. The sensor reports where each return hit, not how the points connect. The cost is that surfaces, normals and object boundaries must be inferred from the points, and operations that depend on neighbours need a search structure. The benefit is that the cloud can be merged and moved without any change to its structure.

QuestionA depth pixel at (u, v) = (300, 250) has depth Z = 1.5 m. The focal length is 600 pixels and the principal point is (320, 240). What is the camera-frame point?Show answer

The horizontal offset is 300−320=−20300 - 320 = -20 pixels, and the vertical offset is 250−240=10250 - 240 = 10 pixels. Then X=−20×1.5/600=−0.05X = -20 \times 1.5 / 600 = -0.05 m and Y=10×1.5/600=0.025Y = 10 \times 1.5 / 600 = 0.025 m. The point is (−0.05,0.025,1.5)(-0.05, 0.025, 1.5) m: slightly to the left, slightly below the axis, and 1.5 metres ahead.

QuestionTwo clouds are taken from one scene by a sensor that moved. Why can the clouds be merged after a rigid transformation, but not after a general linear transformation that stretches the scene?Show answer

A rigid transformation preserves distances between points, so a correctly placed cloud describes the same surfaces in the new frame. A stretch changes distances and so distorts the scene: a wall would appear longer or shorter than it is, and matching points from different scans would be wrong. The sensor's motion is a rotation and a translation, so only rigid transformations are needed.

QuestionA cloud has one million points and a query takes a brute-force search of every point. Roughly how many distance computations are needed for 10,000 queries, and why might an approximate index be worth it?Show answer

Each query compares the query point with all N=1,000,000N = 1{,}000{,}000 points, so each query needs about one million distance computations. For 10,000 queries that is about 101010^{10} distance computations. An approximate index visits only a small part of the cloud for each query, which can cut the work by orders of magnitude at the cost of occasionally returning a near-neighbour instead of the exact nearest point. For matching in a robot's loop, that trade is usually acceptable.

Sources