RGB-D Scene Classification

A colour photo of a hotel room and a colour photo of a bedroom can look the same. A depth camera measures the room in metres, and the tie breaks.

Pick what the classifier may see: colour, depth, or both. Then press Next room. Then we build, piece by piece, the metres, the height and angle channels, the two networks, the fusion rule, the sensor's failures and the honest score.

You need what a probability is and a little Python. It helps to know that a network can output one label for a whole image. We build the rest from zero.

Part of the Scene Classification family. It builds on Visual Scene Classification, which classifies rooms from colour alone.

Break the bedroom and hotel tie

Illustrative toy. We made up the room sizes and the two networks' probabilities. The colour + depth answer multiplies the two votes and rescales them, the late fusion rule of Chapter 6.

Chapter 0

A Bedroom or a Hotel Room?

See why a bigger colour model cannot split two rooms that only differ in size

A service robot rolls through a doorway. Its scene classifier must name the room in one word. A bedroom is private: knock and wait. A hotel room has other rules. The colour classifier says bedroom 0.49, hotel room 0.46.

Look at the photo and you see why. Designers make a hotel room look like a bedroom: the same bed, lamp and beige walls. Worse, a small room and a large room with larger furniture can give the same photo. Colour has no units, so it cannot tell them apart.

Compare two rooms, colour then depth

Room B is room A made 1.44 times bigger in every direction. Switch from the colour view to the depth view.

Illustrative toy. In the depth view, brighter blue means nearer. The same camera sees both rooms from the doorway.

A depth camera reports, for each pixel, the distance to the surface in metres. Its output is a depth map: an image the same size as the photo, with a distance in each pixel. RGB-D scene classification names the room from both: the three colour channels (RGB) and the depth map (D).

The failure, as symptom, measurement and fix

The symptom: a colour model splits close to 50/50 between two room types, and a bigger colour model does not help. To measure it, read the confusion matrix and find the pairs that swap most. The fix is a sensor that measures what differs between them. For bedroom and hotel room, that is size.

The road

  1. The task and its data: one label from a colour image plus a depth map, and how little data there is.
  2. Depth turns pixels into metres: back-projection, the first equation.
  3. Height above the floor: the strongest layout cue.
  4. HHA: disparity, height and angle as three image channels.
  5. Two streams: one network per sensor, and why depth learns from scratch.
  6. Fusion: early, late and attention; the log-probability sum.
  7. Holes and noise: what a real depth sensor gets wrong.
  8. Showcase: the full classifier; fuse depth, then break it.
  9. The depth gain: mean class accuracy and per-class gain.
  10. Field guide: terms, numbers, code and links.
A colour classifier gives bedroom 0.49 and hotel room 0.46. Why can a depth camera fix this when a bigger colour model cannot?

Chapter 1

The Task and Its Data

State the input and output, then count how few training images each room type gets

The input is a pair. The colour image has shape (3, H, W). The depth map has shape (1, H, W). The output is a probability for each of K room types. The prediction is the most probable type.

The pair must be registered: pixel (i, j) shows the same point in both images. The two sensors sit a few centimetres apart, so software warps one stream onto the other. The public datasets ship registered.

Two datasets define the field. NYU Depth v2 (Silberman, Hoiem, Kohli and Fergus, 2012) has 1,449 labelled pairs from a Microsoft Kinect, in 464 scenes from 3 cities. SUN RGB-D (Song, Lichtenberg and Xiao, 2015) has 10,335 pairs from four different depth sensors.

DatasetPairsScene splitTrain / test
NYU Depth v21,449, one Kinect27 types, grouped into 10 classes (9 common + other)795 / 654
SUN RGB-D10,335, four sensorsthe 19 most common types4,845 / 4,659

Count the training images per class. SUN RGB-D gives 4,845 / 19 = about 255. NYU Depth v2 gives 795 / 10 = about 80. ImageNet, the usual pretraining set, gives 1,281,167 / 1,000 = about 1,281. RGB-D work lives in a small-data regime.

Count the images each class gets

Each dot is 10 training images of one class. Pick a dataset and compare it with ImageNet.

Counts from the dataset pages and the standard splits (as used by Song, Herranz and Jiang, 2018). Per-class values are averages; real classes are unbalanced.

The failure, as symptom, measurement and fix

The symptom: training accuracy near 100 percent, test accuracy far lower. That is overfitting, and 255 images per class invite it. Measure the gap between train and test accuracy. The fix is to spend data wisely. Pretrain where it transfers, hand the network ready-made geometry (Chapter 4), and keep the model small.

SUN RGB-D's scene split has 4,845 training images over 19 classes. About how many per class, and what follows?

Chapter 2

Depth Turns Pixels into Metres

Back-project a pixel with its depth and read off where it sits in the room

A colour pixel says only "something is in this direction". It could be a near toy or a far wall. Depth adds the distance, so the pixel becomes a point in metres. Then you can measure the room.

Use a pinhole camera model: every ray passes through one point, the camera centre. Call the distance from the centre to the image plane, in pixels, the focal length f. Call a pixel's offset from the image centre, in pixels, u. Call the depth the sensor reports there Z, in metres, measured along the camera's viewing axis. We want the sideways position X of that point, in metres.

Say it aloud

Capital X equals capital Z times u, divided by f.

X
capital X the point's sideways offset from the viewing axis, in metres. Right is positive.
Z
capital Z the depth at this pixel, in metres, from the depth map.
u
u the pixel's column offset from the image centre, in pixels.
f
f the focal length in pixels, a fixed number for the camera.
In plain words

Divide the pixel offset u by f. That is the slope of the ray. Walk out along the ray to depth Z. The sideways distance you reach is X. The same rule with the row offset gives the vertical position.

With numbers

With made-up numbers: u = 200 px, Z = 3.0 m, f = 500 px. X = 3.0 × 200 / 500 = 1.2 m right of the axis. A wall pixel at −2.0 m and another at +2.0 m mean the room is 4.0 m wide.

The two triangles from the camera centre (one to the pixel, one to the point) have the same shape, so X / Z = u / f. That is the whole derivation. Without Z, every point on the ray fits the pixel. Try it below.

Back-project one pixel

The teal camera looks up the page. Slide the pixel and the depth. Then switch on the millimetre bug.

200 px
3.0 m

Illustrative camera: f = 500 px, an image 640 px wide. Many sensors store depth as whole millimetres in 16-bit integers.

The failure, as symptom, measurement and fix

The symptom: a room comes out 4,000 m wide. The sensor stored millimetres and the code read metres. To measure it, back-project two wall pixels and check the width against a tape measure. The fix: convert units once, at load time, and assert that depths fall between 0.3 m and 10 m.

A pixel sits u = 150 px from the centre. The depth there is Z = 2.0 m, and f = 600 px. What is X?

Chapter 3

Height Above the Floor

Turn each pixel's depth into its height, and read a room's layout from the heights

A kitchen has a counter at about 0.9 m. A dining room has a table at about 0.75 m. Every room has a floor at 0 m and a ceiling at 2.4 to 3 m. If each pixel knew its height, the layout would be plain to see.

Mount the camera level, at height c above the floor. Call a pixel's row offset below the image centre v, in pixels (rows above the centre are negative). With depth Z and focal length f, Chapter 2's rule gives the drop below the camera: Z · v / f. Call the pixel's height above the floor h.

Say it aloud

h equals c minus capital Z times v, divided by f.

h
h the height of the surface at this pixel above the floor, in metres.
c
c the camera's height above the floor, in metres.
Z
capital Z the depth at this pixel, in metres.
v
v the pixel's row offset below the image centre, in pixels. Negative above the centre.
f
f the focal length in pixels.
In plain words

Find how far the point sits below the camera: Z times v, divided by f. Subtract that drop from the camera height c. The result is h. A point above the camera has negative v, so its drop is negative and h comes out larger than c.

With numbers

With made-up numbers: c = 1.2 m, f = 500 px. A pixel at v = 150 with Z = 4.0 m: h = 1.2 − 4.0 × 150 / 500 = 0.0 m, the floor. At v = 90, Z = 2.5 m: h = 0.75 m, a table. At v = −140, Z = 5.0 m: h = 2.6 m, the ceiling.

Compute heights row by row

The teal camera looks right. Slide the row to aim the ray at the floor, the table or the ceiling. Then tilt the camera and leave the formula as it is.

90 px
0°

Illustrative room: camera 1.2 m up, f = 500 px. Table top 0.75 m high, 2.0 m to 2.8 m away. Ceiling 2.6 m, back wall 5.5 m away.

The failure, as symptom, measurement and fix

The symptom: the floor reads 0.4 m high near the back of the room. The camera tilts down, but the formula assumes it is level. To measure it, check that floor pixels give h near 0 at every distance. The fix is to find the true "up" direction first. HHA estimates it from the depth map by looking for the many floor and wall normals that line up (Chapter 4).

A histogram of all pixel heights is already a layout fingerprint: a big floor peak, a table peak, a ceiling peak. Build one below.

The camera is level at c = 1.2 m and f = 500 px. A pixel at v = 100 has depth Z = 3.0 m. What is its height?

Chapter 4

HHA: Three Geometric Channels

Turn one depth channel into disparity, height and angle, so the network does not have to learn geometry

A network fed raw depth must learn "this pixel is floor" from about 255 images per class. HHA (Gupta, Girshick, Arbeláez and Malik, 2014) computes the geometry first: Horizontal disparity, Height above ground and Angle with gravity. It scales each channel to 0 to 255, so the result looks like a colour image.

Two viewpoints a distance b apart (the baseline) see a point shifted sideways. Call that shift the disparity d, in pixels. With focal length f and depth Z:

Say it aloud

d equals f times b, divided by capital Z.

d
d the disparity: how far the point shifts between the two views, in pixels.
f
f the focal length in pixels.
b
b the baseline: the distance between the two viewpoints, in metres.
Z
capital Z the depth of the point, in metres.
In plain words

Multiply f by the baseline b. Divide by the depth Z. Near points shift a lot, far points shift a little. So the disparity channel is bright near the camera and dark far away.

With numbers

With Kinect-like numbers (illustrative): f = 580 px, b = 0.075 m, so f · b = 43.5. At Z = 1 m, d = 43.5 px. At Z = 4 m, d = 10.9 px. Four times farther, a quarter of the shift.

The second channel is the height h from Chapter 3. For the third, fit a tiny plane to each pixel's neighbouring 3D points. Call the unit arrow sticking straight out of that plane the surface normal n. Call the unit arrow pointing up, against gravity, g. Call the angle between them θ.

Say it aloud

Theta equals the arc cosine of n dot g.

θ
theta the angle between the surface normal and up, from 0° to 180°.
arccos
arc cosine the angle whose cosine is the given number.
n
n the surface normal at this pixel: a length-1 arrow out of the surface.
·
dot the dot product: multiply matching parts of two arrows and add. For length-1 arrows it is the cosine of the angle between them.
g
g the up direction, against gravity, as a length-1 arrow.
In plain words

Take the dot product of the normal n and the up arrow g. That is the cosine of the angle. Undo the cosine to get theta. Floors give 0°, walls 90°, ceilings 180°.

With numbers

Write arrows as (sideways, up, forward), so g = (0, 1, 0). A floor has n = (0, 1, 0): n · g = 1, θ = 0°. A wall has n = (1, 0, 0): n · g = 0, θ = 90°. A ramp with n = (0, 0.94, 0.34) gives n · g = 0.94 and θ = about 20°.

See one room four ways

Pick a channel. Then tap any pixel to read its depth, disparity, height and angle.

Illustrative room, ray-cast at 64 by 48 pixels. Camera 1.2 m up and level; ceiling 2.6 m; back wall 5.5 m away; two side walls and a table. The HHA view puts disparity, height and angle in the red, green and blue channels.

In the height view the table and the floor separate at once. In the angle view the table's top and front split; raw depth shows one smooth blob.

The failure, as symptom, measurement and fix

The symptom: the angle channel looks like static, because normals from single pixels amplify depth noise. Measure the spread of θ on a flat floor patch. The fix: fit each normal over several pixels, and fill holes first (Chapter 7).

Why does HHA usually beat feeding raw depth to a network trained on a small RGB-D set?

Chapter 5

Two Streams, One per Sensor

Give colour and depth their own networks, and see that the gain comes from different mistakes

Colour reads materials and objects. Depth reads shape and size. Their pixels have different statistics: depth has edges and smooth slopes, and no texture. So most RGB-D classifiers use a two-stream network. One encoder reads colour, a second reads depth (often as HHA), and a fusion step joins them.

Follow the shapes. The colour image (3, 224, 224) goes through the colour encoder, which averages it down to a descriptor, a vector (512,). The HHA image (3, 224, 224) goes through the depth encoder to its own (512,). Fusion combines the two, and a final layer outputs K probabilities.

Depth learns better from scratch

The usual move is to start the depth encoder from a network pretrained on colour images, then fine-tune it. Song, Herranz and Jiang (AAAI 2017) found a better way on NYU Depth v2 and SUN RGB-D. They trained a smaller depth network from scratch: first on small patches, then on whole images. Its depth features scored higher than fine-tuned colour features, and added more to the colour stream.

Their explanation: the colour network's first layers detect textures and fine patterns that HHA images do not have. Fine-tuning with little data barely changes those first layers. The lesson is general: pretraining helps when its data looks like yours.

The gain lives in different mistakes

Take 100 test images. The colour stream is right on 70. Suppose depth is right on 20 of the 30 that colour gets wrong: the size-decided ones. A perfect fusion could then reach 70 + 20 = 90. If depth failed only where colour fails, the ceiling would stay at 70.

Count who rescues whom

Each square is one test image. Set each stream's accuracy and how much their mistakes overlap.

0.70
0.65
0.00

Illustrative counts. Overlap 0 means the mistakes are independent; overlap 1 means depth is right only where colour is right too. "Best fusion" counts images at least one stream gets right, an upper bound.

With independent mistakes, both streams are wrong on 0.30 × 0.35 = 0.105 of the images, so the ceiling is 89.5 percent. Slide the overlap to 1 and the depth stream adds nothing.

The failure, as symptom, measurement and fix

The symptom: the two-stream model scores no higher than colour alone. To measure it, count the test images where depth is right and colour is wrong. If that set is tiny, the streams learned the same cues. The fix: give the depth stream its own input form (HHA) and its own training, not copied colour weights.

Colour is right on 70 of 100 images. Depth is right on 20 of the 30 colour misses. What is the most a fusion can reach?

Chapter 6

Fusion: Early, Late and Attention

Choose where the two streams meet, then fuse two votes by adding log-probabilities

The streams must meet somewhere. Where they meet is the fusion strategy. There are three main choices.

StrategyWhere they meetGood whenRisk
EarlyAt the input: stack colour and depth, one networkThe channels align well and low-level mixes matterShared first filters suit neither sensor
LateAt the end: two full networks, two votesLittle data; you want it simple and robustMisses cues that need both at once
AttentionIn the middle: each stream's features attend to the other'sMuch data; joint cues matterMany weights; overfits small sets

Late fusion is the first thing to try. Each stream keeps its own best training, and a dead sensor leaves the other vote standing. How should two votes combine? Call the colour stream's probability for room type k prgb(k) and the depth stream's pdep(k). Call the fused score s(k).

Say it aloud

s of k equals log of p-rgb of k, plus log of p-dep of k.

s(k)
s of k the fused score for room type k. The largest score wins.
log
log the natural logarithm. It turns multiplying into adding, and keeps tiny numbers readable.
prgb(k)
p-rgb of k the colour stream's probability that the room is type k.
pdep(k)
p-dep of k the depth stream's probability that the room is type k.
In plain words

Take the log of each stream's probability for room type k and add them. Do this for every type. The type with the largest s wins. Adding logs is the same as multiplying probabilities, so a type wins only if both streams find it plausible.

With numbers

With made-up numbers for (bedroom, hotel, kitchen): prgb = (0.50, 0.45, 0.05) and pdep = (0.20, 0.70, 0.10). Bedroom: −0.693 + (−1.609) = −2.303. Hotel: −0.799 + (−0.357) = −1.155. Kitchen: −2.996 + (−2.303) = −5.298. Hotel wins. Rescaled to sum to 1, the fused vote is (0.24, 0.75, 0.01).

Why multiply and not average? If the streams err independently, multiplying is how probability combines two pieces of evidence. It also lets one stream veto a type. Colour (kitchen 0.70, bedroom 0.25, hotel 0.05) and depth (kitchen 0.02, bedroom 0.48, hotel 0.50) average to a near three-way tie. The product picks bedroom at 0.75.

Fuse two votes three ways

Set how sure each stream is of "hotel". Compare the average with the log sum. The weight tilts the log sum toward depth.

0.45
0.70
0.50

Illustrative votes. Colour keeps kitchen at 0.05 and depth keeps it at 0.10; bedroom takes the rest. The weighted rule is 2(1 − w) log prgb + 2w log pdep, rescaled to sum to 1. At w = 0.5 it is the plain sum.

The failure, as symptom, measurement and fix

The symptom: the fused model is wrong with 99 percent confidence. One stream gave a near-zero probability to the true type and vetoed it. To measure it, list test images where the true type got under 1 percent from either stream. The fix: clip each probability to a small floor, such as 0.01, or learn the weight w on held-out data.

Colour gives (bedroom 0.50, hotel 0.45). Depth gives (bedroom 0.18, hotel 0.70). Under the log sum, which wins?

Chapter 7

Holes and Noise in Real Depth

Mark missing pixels as missing, and see why depth error grows with the square of distance

A real depth map has gaps. Glass, mirrors, shiny metal and black screens send back no usable signal. Surfaces past the sensor's range do the same. The sensor writes a 0 in those pixels. That 0 means no measurement, not "a surface at 0 m". Call these pixels holes.

Where a value exists, it is noisier far away. Many depth sensors find depth from a disparity, as in Chapter 4: Z = f · b / d. Call the sensor's error in disparity σd, in pixels. Call the resulting error in depth σZ. Differentiate Z with respect to d and replace d with f · b / Z:

Say it aloud

Sigma-Z equals capital Z squared times sigma-d, divided by f times b.

σZ
sigma-Z the typical depth error at this distance, in metres.
Z2
capital Z squared the depth times itself. Double the distance, four times the error.
σd
sigma-d the typical error in the measured disparity, in pixels.
f
f the focal length in pixels.
b
b the baseline in metres.
In plain words

Square the depth Z. Multiply by the disparity error sigma-d. Divide by f times b. Far points have a small disparity, so the same pixel error moves them much more.

With numbers

With illustrative Kinect-like numbers: f · b = 43.5 and σd = 0.1 px. At Z = 1 m, σZ = 1 × 0.1 / 43.5 = 2.3 mm. At Z = 4 m, σZ = 16 × 0.1 / 43.5 = 3.7 cm. Four times farther, sixteen times the error.

The Kinect's useful range is about 0.5 m to 5.5 m, with accuracy falling with distance (Song, Herranz and Jiang, 2018). So the far wall of a big room is the least trustworthy part of the map. Yet it is the cue that tells a hall from a bedroom.

Read one noisy scan line

Pink is the true depth across one image row: a near side wall, a table, a back wall with a window. Blue dots are measurements. Add noise and holes, then choose how to treat the holes.

0.50 px
10%

Illustrative scan line with f · b = 43.5. The window always returns holes. "Mask and fill" draws a straight line between the nearest valid neighbours; real pipelines use smarter fills.

Repair comes before geometry. NYU Depth v2 ships depth maps with holes filled by the colorization method of Levin and colleagues. The colour image guides which neighbours to borrow from. A learned depth-completion network does the same job with more skill.

The failure, as symptom, measurement and fix

The symptom: the height channel shows a patch at 1.2 m, the camera's own height, right where the window is. A hole read as Z = 0 gives h = c − 0 = c. To measure it, count pixels with Z = 0 before you compute anything. The fix: keep a validity mask, fill the holes, and pass the mask to the network as an extra input.

With f · b = 43.5 and σd = 0.1 px, what is the depth error at 2 m?

Chapter 8

Showcase: Fuse Depth, Then Break It

Drive a toy two-stream classifier, watch depth settle the tie, then corrupt the depth

Here is the whole pipeline as a toy. The colour stream reads three object cues: a bed, cooking surfaces, a desk. The depth stream reads two size cues: room scale and ceiling height. Each stream turns its cues into five probabilities. Late fusion adds their logs.

Drive the classifier

Start from a preset. Switch depth on and off. Then raise the depth noise and watch the gain melt.

Colour cues

0.80
0.05
0.10

Depth cues

0.15
0.20
0.00

Illustrative toy: each stream is a hand-set linear score per room type, then a softmax. Noise adds random scores to the depth stream, scaled by the noise slider.

Three things to try:

  1. Press Bed, size unknown with depth off. Bedroom and hotel room tie, as in Chapter 0.
  2. Press Small room. The depth stream votes hotel, and the fused bar settles it.
  3. Raise the noise to 1. The depth vote turns random. Sometimes it drags the answer to a wrong type.

The pattern to take away: depth helps exactly where size decides the room, and only as much as the depth can be trusted. A kitchen barely moves when depth turns on, because the colour stream already sees the stove.

The failure, as symptom, measurement and fix

The symptom: a robot's RGB-D model beats colour alone in the lab and loses to it in a glass-walled office. To measure it, score the model on test images grouped by their hole rate. The fix: give the fusion a per-image trust signal, such as the share of valid depth pixels, and lower the depth weight when it drops.

In the toy, why does a kitchen barely change when depth is switched on?

Chapter 9

Measuring the Depth Gain

Score each class equally, then report where depth helped and where it did not

RGB-D datasets are unbalanced: many bedrooms, few bathrooms. Overall accuracy, the share of all test images that are right, lets the big classes hide a broken small one. So RGB-D papers on SUN RGB-D report mean class accuracy: the accuracy within each class, averaged with equal weight.

Call the number of room types K. For class k, call the number of test images nk and the number classified right ck. Call the mean class accuracy mA.

Say it aloud

m-A equals one over capital K, times the sum over k of c-k over n-k.

mA
m-A the mean class accuracy, from 0 to 1.
1/K
one over capital K divide by the number of room types, so each type counts once.
Σk
the sum over k add one term for each room type.
ck
c-k how many test images of type k the model got right.
nk
n-k how many test images of type k there are.
In plain words

For each room type k, divide the right answers c-k by the images n-k. Add these K accuracies. Divide by K. A type with 10 images counts as much as a type with 600.

With numbers

With made-up numbers: bedroom 54 of 60, kitchen 24 of 30, bathroom 2 of 10. Overall: 80 / 100 = 80%. Per class: 90%, 80%, 20%. mA = (0.90 + 0.80 + 0.20) / 3 = 63.3%. The overall number hides a broken bathroom class.

Hide a broken class, then expose it

Each bar's width is the number of test images in that class; its height is the class accuracy. Drag the sliders and watch the two lines part.

54
2

Illustrative counts. The kitchen stays at 24 of 30.

The second report is the per-class depth gain: colour-only accuracy, RGB-D accuracy, and their difference, one row per room type. Expect large gains where size decides the type and near zero where objects decide it. Then compare the two confusion matrices: the bedroom and hotel cells should shrink.

Room typeColour onlyRGB-DGain
Hotel room41%68%+27
Bedroom62%74%+12
Kitchen88%89%+1
Bathroom85%83%−2

Illustrative numbers, not from any paper. The shape is typical: a negative row can appear where noisy depth (mirrors, glass shower doors) misleads.

The failure, as symptom, measurement and fix

The symptom: a paper reports "+5 points from depth", and the robot still confuses bathrooms. To measure it, rebuild the per-class gain table. The fix: report mean class accuracy, the per-class gain and both confusion matrices, never one aggregate number alone.

Bedroom 90% (60 images), kitchen 80% (30), bathroom 20% (10). What is the mean class accuracy?

Chapter 10

Field Guide

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

An RGB-D scene classifier reads a registered colour image and depth map. Depth turns pixels into metres, so you can compute each pixel's height and surface angle. HHA packs disparity, height and angle into an image. Two streams read colour and HHA; late fusion adds their log-probabilities. Holes are missing values, depth error grows with Z2, and the honest score is mean class accuracy with a per-class gain.

TermRuleNumber to remember
Back-projectionX = Z · u / fu 200, Z 3 m, f 500: 1.2 m
Heighth = c − Z · v / fc 1.2, v 90, Z 2.5: 0.75 m
Disparityd = f · b / Zf · b 43.5: 43.5 px at 1 m, 10.9 px at 4 m
Angleθ = arccos(n · g)floor 0°, wall 90°, ceiling 180°
Late fusions(k) = log prgb(k) + log pdep(k)(0.50, 0.45) and (0.20, 0.70): hotel 0.75
Depth noiseσZ = Z2 σd / (f b)2.3 mm at 1 m, 3.7 cm at 4 m
Mean class accuracymA = (1/K) Σ ck / nk80% overall can be 63.3% mA
SUN RGB-D10,335 pairs, 4 sensors19 classes, 4,845 / 4,659
NYU Depth v21,449 pairs, Kinect10 classes, 795 / 654

Checklist for an RGB-D classifier

The core, in code

python
import numpy as np

def hha(Z, f, cx, cy, cam_h, fb=43.5):
    # Z: (H, W) depth in metres, 0 = hole. Level camera assumed.
    H, W = Z.shape
    valid = Z > 0
    u = np.arange(W)[None, :] - cx; v = np.arange(H)[:, None] - cy
    X, Y = Z * u / f, Z * v / f                    # back-project (Y points down)
    disp = np.where(valid, fb / np.maximum(Z, 1e-6), 0)  # d = f b / Z
    height = cam_h - Y                             # h = c - Z v / f
    P = np.stack([X, -Y, Z], -1)                  # (sideways, up, forward)
    n = np.cross(np.gradient(P, axis=1), np.gradient(P, axis=0))
    n /= np.linalg.norm(n, axis=-1, keepdims=True) + 1e-9
    n = np.where((n * P).sum(-1, keepdims=True) > 0, -n, n)  # point normals toward the camera
    angle = np.degrees(np.arccos(np.clip(n[..., 1], -1, 1)))  # theta = arccos(n . up)
    return np.stack([disp, height, angle], 0), valid   # (3, H, W) plus mask

def late_fuse(p_rgb, p_dep, floor=0.01):
    s = np.log(np.maximum(p_rgb, floor)) + np.log(np.maximum(p_dep, floor))
    e = np.exp(s - s.max()); return e / e.sum()

def mean_class_accuracy(pred, label, K):
    accs = [(pred[label == k] == k).mean() for k in range(K) if (label == k).any()]
    return float(np.mean(accs))

Where it sits

Keep going

Sources: N. Silberman, D. Hoiem, P. Kohli and R. Fergus, "Indoor Segmentation and Support Inference from RGBD Images", ECCV 2012 (NYU Depth v2). S. Song, S. Lichtenberg and J. Xiao, "SUN RGB-D: A RGB-D Scene Understanding Benchmark Suite", CVPR 2015 (SUN RGB-D). S. Gupta, R. Girshick, P. Arbeláez and J. Malik, "Learning Rich Features from RGB-D Images for Object Detection and Segmentation", ECCV 2014 (arXiv). X. Song, L. Herranz and S. Jiang, "Depth CNNs for RGB-D Scene Recognition: Learning from Scratch Better than Transferring from RGB-CNNs", AAAI 2017 (arXiv), and "Learning Effective RGB-D Representations for Scene Recognition", IEEE TIP 2018 (arXiv).

The takeaway. Depth is a second measurement, not a fourth colour. Turn it into metres, height and angle, give it its own stream, fuse late, and trust it only where the sensor can be trusted.

Now press Present or Teach and explain from memory: back-projection, height, HHA, two streams, the log sum, the Z2 noise and mean class accuracy. Then go back to the room classifier, pick colour only, and say why the hotel room fails.

RGB-D Scene Classification · When Depth Reveals the Room
Visual Scene Classification · Back to Gleams