# Depth Perception

Depth perception is a key feature of the DepthAI platform, which supports different methods of perceiving depth:

 1. [Passive Stereo Depth](#Depth%2520Perception-Passive%2520Stereo%2520Depth) - Used by non-Pro version of OAK-D and OAK4-D
    cameras.
 2. [Active Stereo Depth](#Depth%2520Perception-Active%2520Stereo%2520Depth) - Used by Pro version of OAK cameras.
 3. [Time-of-Flight Depth](#Depth%2520Perception-Time-of-Flight%2520Depth) - Used by OAK-ToF.

## Passive Stereo Depth

Passive stereo works similarly to human vision. Our brains estimate the depth of objects based on the difference in perception
between our left and right eyes. In OAK-D cameras, a stereo camera pair (left and right monocular cameras) performs a similar
function. The VPU (Visual Processing Unit) of the OAK cameras does disparity matching to estimate the depth.

Disparity is the pixel distance between the same point in the left and right images of the stereo pair camera. The OAK-D camera
calculates disparity for every pixel in the mono frame, assigning a disparity value with some confidence level. This process
occurs inside the [StereoDepth node](https://docs.luxonis.com/software/depthai-components/nodes/stereo_depth.md). The depth map is
calculated from the disparity map using [this
formula](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/stereo_depth.md).

> Passive stereo depth perception may not work well with featureless surfaces like walls or ceilings, as disparity matching relies
on distinctive points or features.

Factors affecting passive stereo accuracy/smoothness:

 * Lighting/Texture: Stereo depth depends on feature matching, which can be challenging in low light or on featureless surfaces.
   Active stereo can resolve both texture and lighting issues.
 * Calibration: Factory calibration is typically optimal.
 * Postprocessing filters: More information can be found
   [here](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/stereo_depth.md) (under Depth Filters). Additional
   filtering can be performed on the host side as well, e.g., [WLS
   filter](https://github.com/luxonis/oak-examples/tree/master/gen2-wls-filter).

## Active Stereo Depth

The [OAK Pro cameras](https://docs.luxonis.com/hardware.md?f-active-stereo-depth=true) use conventional active stereo vision
(ASV). A dot projector casts many small dots in front of the device, aiding in disparity matching, particularly on
low-visual-interest surfaces.

The stereo matching process is the same as in passive stereo, but the dots enhance accuracy.

The image above shows passive and active stereo perception against a wall. The mono image (bottom left) displays the projected
dots.

## Time-of-Flight Depth

While stereo perception is cost-effective and suitable for long distances, it may lack accuracy. For high-accuracy applications,
Time-of-Flight (ToF) is recommended. ToF can provide sub-centimeter depth accuracy.

We have developed a [ToF FFC module](https://shop.luxonis.com/products/oak-ffc-tof-33d) compatible with
[OAK-FFC](https://shop.luxonis.com/collections/oak-modules/?q=filter_tag%3dtype-base+module&sort_by=manual). A standalone camera
with an onboard ToF sensor is planned for the future.

The gif above demonstrates a high-accuracy point cloud produced using a ToF FFC module and a [color
camera](https://shop.luxonis.com/products/oak-ffc-imx378). The ToF resolution here is 244x172.
