Stereo & ToF — depth vision
About this app
An interactive 3D scene on machine depth vision: in stereo mode two cameras with adjustable baseline show the left/right image plus a depth map live, and the disparity d = f·B/z becomes visible at the marked object as a pixel offset. In ToF mode, animated light pulses send echoes back and build the depth map object by object from the travel times.
Two ways to measure depth
Machines mainly measure depth in two ways. A stereo camera triangulates like our eyes: a point at distance z appears shifted between the left and right image by the disparity d = f·B/z, with focal length f in pixels and baseline B. A larger baseline increases disparity and improves depth resolution; depth error grows roughly with z². A time-of-flight (ToF) camera instead measures the round-trip time t of a light pulse: z = c·t/2. It needs no texture and works in the dark, but can be disturbed by sunlight and is limited in range and resolution.
What the app shows
A 3D scene with several objects is viewed from the camera. In stereo mode the app shows the left and right images and a depth map. Sliders set baseline B and object distance z; on the marked sphere the disparity appears as a pixel offset, and disparity lines can be shown. The measurement panel works out d = f·B/z with f = 429 px and shows the depth resolution Δz per pixel. In ToF mode animated light pulses send echoes back, and the depth map is built object by object from the flight times.
Try it yourself
Double the baseline and watch the disparity double while Δz shrinks. Move the object further away: disparity falls as 1/z and depth resolution becomes much coarser. With a large baseline and short distance the object leaves one camera image, and stereo matching is no longer possible. Switch to ToF mode and read off the flight times. A comparison table sums up the strengths and weaknesses of both methods.
Frequently asked questions
- How does a stereo camera calculate distance?
- It finds the same point in the left and right images and measures the horizontal offset, the disparity d. With focal length f and baseline B the distance is z = f·B/d. The larger the disparity, the closer the object.
- How does a time-of-flight camera work?
- A ToF camera emits light and measures, for each pixel, how long it takes to reach the object and return. The distance follows from the flight time t as z = c·t/2. It gives depth directly without comparing two images.
- Which is better, stereo or ToF?
- It depends on the application. Stereo is passive and can gain accuracy with a larger baseline, but needs texture, light and a lot of computation for matching. ToF works without texture and in the dark, but can be disturbed by sunlight and is limited in range and resolution.
- What can I adjust in the app?
- The mode (stereo or ToF), the baseline B, the object distance z and whether disparity lines are shown. The formulas are worked out with the current values.
Subject: Computer Vision
More from Computer Vision
- 3D Gaussian Splatting
- Convolution playground
- CV Foundational Skills
- Industrial lighting
- Neural Rendering (NeRF)
- Photogrammetry & Its Limits
- Pixel grid
A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps