Computing depth from stereo image

Humans view the world in three dimensions using their two eyes. Robots can do the same when they are equipped with two cameras. This is called stereovision. A stereo rig is a pair of cameras mounted on a device, looking at the same scene and separated by a fixed baseline (distance between the two cameras). This recipe will show you how a depth map can be computed from two stereo images by computing dense correspondence between the two views.

Getting ready

A stereovision system is generally made of two side-by-side cameras looking at the same direction. The following figure illustrates such a stereo system in a perfectly aligned configuration:

Under this ideal configuration the cameras are only separated by a horizontal ...

Get OpenCV 3 Computer Vision Application Programming Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.