ON THIS PAGE

  • ToF
  • How to place it
  • Inputs and Outputs
  • ToF Settings
  • Phase unwrapping
  • ToF motion blur
  • Max distance
  • ToF FPS
  • Usage
  • Reference

ToF

ToF node is used for converting the raw data from the ToF sensor into a depth map. Currently, these 2 products contain a ToF sensor:
  • OAK-D SR PoE - integrated 33D ToF sensor, together with a stereo camera pair
  • OAK-FFC ToF 33D - standalone FFC module with a 33D ToF sensor
ToF's depth output can be used instead of StereoDepth's - so you can link ToF.depth to SpatialDetectionNetwork or SpatialLocationCalculator directly.ToF's depth accuracy is, in general, more accurate compared to Stereo depth. You can see ToF depth accuracy here.ToF pointcloud demo video, showcasing the depth accuracy:

How to place it

Python
C++

Python

Python
1pipeline = dai.Pipeline()
2tof = pipeline.create(dai.node.ToF)

Inputs and Outputs

ToF Settings

Here are the most important settings:
  • Optical Correction: It's a process that corrects the optical effect. When enabled, the ToF returns depth map (represented by Green Line on graph below) instead of distance, so it matches StereoDepth depth reporting. It does rectification and distance to depth conversion (Z-map).
  • Undistortion: depth and amplitude frames are undistorted by default.
  • Phase Unwrapping - Process that corrects the phase wrapping effect of the ToF sensor. You can set it to [0..5 are optimized]. The higher the number, the longer the ToF range, but it also increases the noise. Approximate max distance (for exact value, see Max distance below):
    • 0 - Disabled, up to ~1.87 meters (utilizing 80MHz modulation frequency)
    • 1 - Up to ~3 meters
    • 2 - Up to ~4.5 meters
    • 3 - Up to ~6 meters
    • 4 - Up to ~7.5 meters
  • Burst mode: When enabled, ToF node won't reuse frames, as shown on the graph below. It's related to post-processing of the ToF frames, not the actual sensor/projector. It's disabled by default.
  • Phase shuffle Temporal filter: Averages shuffled and non-shuffled frames of the same modulation frequency to reduce noise. It's enabled by default. You can disable it to reduce ToF motion blur and system load.
Here's the time diagram which showcases how ToF decoding gets done based on the settings.

Phase unwrapping

If the time it takes for the light to travel from ToF sensor and back exceeds the period of the emitted wave (1.5m or 1.87m), the resulting measurement will "wrap" back to a lower value. This is called phase wrapping. It's similar to how a clock resets after 12 hours. Phase unwrapping is possible as our ToF has two different modulation frequencies (80Mhz and 100MHz).Phase unwrapping aims to correct this by allowing the sensor to interpret longer distances without confusion. It uses algorithms to keep track of how many cycles (round trips of the wave) have occurred, thus correcting the "wrapped" phases. The downside is that the more cycles the sensor has to keep track of, the more noise it introduces into the measurement.

ToF motion blur

To reduce motion blur, we recommend these settings:
  • Increase camera FPS. It goes up to 160 FPS, which causes frame capture to be the fastest (6.25ms between frames). This will reduce motion blur as ToF combines multiple frames to get the depth. Note that 160FPS will increase system load significantly (see Debugging DepthAI pipeline). Note also that higher FPS -> lower exposure times, which can increase noise.
  • Disable phase shuffle temporal filter. This will introduce more noise.
  • Disable phase unwrapping. This will reduce max distance to 1.87 meters (utilizing 80MHz modulation frequency), so about 1 cubic meter of space will be visible (very limited use-cases).
  • Enable burst mode. This is irrelevant if shuffle filter and phase unwrapping are disabled (see diagram above). When enabled, ToF node won't reuse frames (lower FPS).
In the diagram above, the less frames are combined (bottom of the diagram), the less motion blur there is. The more frames are combined (top of the diagram), there's more filtering (better accuracy) but it results in more motion blur.

Max distance

Maximum ToF distance depends on the modulation frequency and the phase unwrapping level. If phase unwrapping is enabled, max distance is the shorter of both modulation frequencies (so max distance at 100MHz). Here's the formula:
Math
1c = 299792458.0 # speed of light in m/s
2
3MAX_80MHZ_M = c / (80000000 * 2) = 1.873 m
4MAX_100MHZ_M = c / (100000000 * 2) = 1.498 m
5
6MAX_DIST_80MHZ_M = (phaseUnwrappingLevel + 1) * 1.873 + (phaseUnwrapErrorThreshold / 2)
7MAX_DIST_100MHZ_M = (phaseUnwrappingLevel + 1) * 1.498 + (phaseUnwrapErrorThreshold / 2)
8
9MAX_DIST_PHASE_UNWRAPPING_M = MAX_DIST_100MHZ_M

ToF FPS

Sensor/emitter can go up to 160 FPS, which will translte to depth output at either 40 FPS (burst mode enabled) or 80 FPS (burst mode disabled). This is due to different modulation frequencies (80MHz and 100MHz) and the need to combine shuffled/non-shuffled frames to reduce noise.

Usage

Python
C++

Python

Python
1pipeline = dai.Pipeline()
2
3tof = pipeline.create(dai.node.ToF).build()
4
5# Median filter, kernel size 5x5
6tof.initialConfig.setMedianFilter(dai.MedianFilter.KERNEL_5x5)
7
8tofConfig = tof.initialConfig.get()
9# Temporal filter averages shuffle/non-shuffle frequencies
10tofConfig.enablePhaseShuffleTemporalFilter = True
11# Phase unwrapping, for longer range.
12tofConfig.phaseUnwrappingLevel = 4 # Up to 7.5 meters
13tofConfig.phaseUnwrapErrorThreshold = 300
14tof.initialConfig.set(tofConfig)
15
16depthQueue = tof.depth.createOutputQueue()

Reference

class

dai::node::ToF

variable
Subnode< ToFBase > tofBase
variable
Subnode< ToFDepthConfidenceFilter > tofDepthConfidenceFilter
variable
Subnode< ImageFilters > imageFilters
variable
Output & rawDepth
Raw depth output from ToF sensor
variable
Output & depth
Filtered depth output
variable
Output & confidence
Confidence output
variable
Output & amplitude
Amplitude output
variable
Output & intensity
Intensity output
variable
Output & phase
Phase output
variable
Input & tofBaseInputConfig
Input config for ToF base node
variable
Input & tofDepthConfidenceFilterInputConfig
Input config for ToF depth confidence filter
variable
Input & imageFiltersInputConfig
Input config for image filters
variable
ToFBase & tofBaseNode
ToF base node
variable
ToFDepthConfidenceFilter & tofDepthConfidenceFilterNode
ToF depth confidence filter node
variable
ImageFilters & imageFiltersNode
Image filters node
inline function
ToF(const std::shared_ptr< Device > & device)
inline function
void buildInternal()
inline function
std::shared_ptr< ToF > build(dai::CameraBoardSocket boardSocket, dai::ImageFiltersPresetMode presetMode, std::optional< float > fps)

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.