Texture where there is none
Window matching in stereo needs texture, and many surfaces have none: in this scene, every surface has a single color. A speckle projector solves this by adding texture: a laser shines through a diffuser and throws a fixed pattern of thousands of random dots, usually in the near infrared, so that people do not see it. The pattern is random, so every window of it is different from every other window along the row, and a single camera image is enough. This is how the first Kinect worked.
A reference image instead of a second camera
The projector sits a baseline beside the camera, with a parallel optical axis. Its dots therefore move only along the rows, just like the pixels of a rectified stereo pair. Instead of a second image, the device stores one picture of the dots on a plane at a known depth , taken during calibration. A point at depth shows the dots shifted by
compared to the reference image: to the right for points in front of the plane, to the left for points behind it. The relation is the stereo formula , measured relative to the reference plane.
Finding the shift
For each pixel, a window around it is compared with windows of the reference image along the same row, for every shift in the search range. The comparison uses the normalized cross-correlation
which ignores the gain and bias between the two windows: a dark surface or one at a slant reflects the dots more weakly, but in the same arrangement. A parabola through the best cost and its two neighbors gives the shift to a fraction of a pixel, and pixels whose best NCC is too low get no depth. These include the shadows, which the projector cannot reach, and windows that cross a depth edge, where half the window belongs to another shift.
Try this
- Click on the box, the sphere and the wall, and compare the NCC curves: one clear peak, at the dashed true shift. Then click near an edge of the box, where the peak is lower and can sit at the wrong shift.
- Make the window small: the depth image gets noisy, with many isolated wrong pixels. Make it large: the noise goes away, but edges get thick and blurred.
- Lower the dot density to 0.05: many windows contain only a dot or two and become ambiguous.
- Raise the ambient light until the image saturates, like a depth camera in sunlight: the dots disappear, and so does the depth.
- Halve the baseline: shifts and their range shrink, so the same matching error becomes a larger depth error.
- Move the reference plane : the shifts change sign where the scene crosses it, but the depth stays the same.