Skip to content

Commit

Permalink
Updated ToF example
Browse files Browse the repository at this point in the history
  • Loading branch information
Erol444 committed Apr 30, 2024
1 parent 8490f76 commit 8db7a41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/source/components/nodes/tof.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ In :ref:`ToF depth` example we allow users to quickly configure ToF settings. Th

And these settings are up to the user:

- 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.
- 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).
- 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.
- `0` - Disabled.
- `1` - Up to 1.5 meters
- `2` - Up to 3 meters
- `3` - Up to 4.5 meters
- `4` - Up to 6 meters
- `5` - Up to 7.5 meters (not recommended for most applications)

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

Expand Down
10 changes: 8 additions & 2 deletions examples/ToF/tof_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

print(dai.__version__)

cvColorMap = cv2.applyColorMap(np.arange(256, dtype=np.uint8), cv2.COLORMAP_JET)
cvColorMap[0] = [0, 0, 0]

def create_pipeline():
pipeline = dai.Pipeline()

Expand Down Expand Up @@ -91,6 +94,10 @@ def create_pipeline():
tofConfig.enablePhaseUnwrapping = True
tofConfig.phaseUnwrappingLevel = 4
tofConfigInQueue.send(tofConfig)
elif key == ord('5'):
tofConfig.enablePhaseUnwrapping = True
tofConfig.phaseUnwrappingLevel = 5
tofConfigInQueue.send(tofConfig)
elif key == ord('m'):
medianSettings = [dai.MedianFilter.MEDIAN_OFF, dai.MedianFilter.KERNEL_3x3, dai.MedianFilter.KERNEL_5x5,
dai.MedianFilter.KERNEL_7x7]
Expand All @@ -116,8 +123,7 @@ def create_pipeline():
min_depth = 200
max_depth = 6000
depth_colorized = np.interp(depth_map, (min_depth, max_depth), (0, 255)).astype(np.uint8)
depth_colorized = cv2.applyColorMap(depth_colorized, cv2.COLORMAP_JET)

depth_colorized = cv2.applyColorMap(depth_colorized, cvColorMap)

cv2.imshow("Colorized depth", depth_colorized)
counter += 1
Expand Down

0 comments on commit 8db7a41

Please sign in to comment.