Skip to content

Commit 8db7a41

Browse files
committed
Updated ToF example
1 parent 8490f76 commit 8db7a41

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docs/source/components/nodes/tof.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ In :ref:`ToF depth` example we allow users to quickly configure ToF settings. Th
6161

6262
And these settings are up to the user:
6363

64-
- Optical Correction: It's a process that corrects the optical effect (On -> ToF returns distance represented by Green Line), so it matches :ref:`StereoDepth` depth reporting.
64+
- Optical Correction: It's a process that corrects the optical effect (On -> ToF returns distance represented by Green Line), so it matches :ref:`StereoDepth` depth reporting. It does rectification and distance to depth conversion (Z-map).
6565
- 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.
6666
- `0` - Disabled.
6767
- `1` - Up to 1.5 meters
6868
- `2` - Up to 3 meters
6969
- `3` - Up to 4.5 meters
7070
- `4` - Up to 6 meters
71+
- `5` - Up to 7.5 meters (not recommended for most applications)
7172

7273
.. image:: /_static/images/components/tof-optical-correction.png
7374

examples/ToF/tof_depth.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
print(dai.__version__)
99

10+
cvColorMap = cv2.applyColorMap(np.arange(256, dtype=np.uint8), cv2.COLORMAP_JET)
11+
cvColorMap[0] = [0, 0, 0]
12+
1013
def create_pipeline():
1114
pipeline = dai.Pipeline()
1215

@@ -91,6 +94,10 @@ def create_pipeline():
9194
tofConfig.enablePhaseUnwrapping = True
9295
tofConfig.phaseUnwrappingLevel = 4
9396
tofConfigInQueue.send(tofConfig)
97+
elif key == ord('5'):
98+
tofConfig.enablePhaseUnwrapping = True
99+
tofConfig.phaseUnwrappingLevel = 5
100+
tofConfigInQueue.send(tofConfig)
94101
elif key == ord('m'):
95102
medianSettings = [dai.MedianFilter.MEDIAN_OFF, dai.MedianFilter.KERNEL_3x3, dai.MedianFilter.KERNEL_5x5,
96103
dai.MedianFilter.KERNEL_7x7]
@@ -116,8 +123,7 @@ def create_pipeline():
116123
min_depth = 200
117124
max_depth = 6000
118125
depth_colorized = np.interp(depth_map, (min_depth, max_depth), (0, 255)).astype(np.uint8)
119-
depth_colorized = cv2.applyColorMap(depth_colorized, cv2.COLORMAP_JET)
120-
126+
depth_colorized = cv2.applyColorMap(depth_colorized, cvColorMap)
121127

122128
cv2.imshow("Colorized depth", depth_colorized)
123129
counter += 1

0 commit comments

Comments
 (0)