Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/python/ToF/tof_align.py
Comment thread
JakubFara marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def colorizeDepth(frameDepth: np.ndarray, minDepth: float, maxDepth: float) -> n
try:
logDepth = np.log(frameDepth.astype(np.float32) + 1e-6)
logDepth[invalidMask] = 0.0
logDepth = np.clip(logDepth, np.log(minDepth + 1e-6), np.log(maxDepth + 1e-6))
depthFrameColor = np.interp(logDepth, (logDepth[~invalidMask].min(), logDepth[~invalidMask].max()), (0, 255))
logMin, logMax = np.log(minDepth + 1e-6), np.log(maxDepth + 1e-6)
logDepth = np.clip(logDepth, logMin, logMax)
# Map from the FIXED depth range (not the per-frame min/max) so a given depth
# always maps to the same color -- otherwise the mapping shifts every frame and
# the image flickers.
Comment thread
JakubFara marked this conversation as resolved.
Outdated
depthFrameColor = np.interp(logDepth, (logMin, logMax), (0, 255))
depthFrameColor = depthFrameColor.astype(np.uint8)
depthFrameColor = cv2.applyColorMap(depthFrameColor, cv2.COLORMAP_JET)
depthFrameColor[invalidMask] = 0
Expand Down
8 changes: 6 additions & 2 deletions examples/python/ToF/tof_all_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ def colorizeDepth(frame: np.ndarray, minDepth: float, maxDepth: float) -> np.nda
try:
logDepth = np.log(frame.astype(np.float32) + 1e-6)
logDepth[invalidMask] = 0.0
logDepth = np.clip(logDepth, np.log(minDepth + 1e-6), np.log(maxDepth + 1e-6))
colored = np.interp(logDepth, (logDepth[~invalidMask].min(), logDepth[~invalidMask].max()), (0, 255))
logMin, logMax = np.log(minDepth + 1e-6), np.log(maxDepth + 1e-6)
logDepth = np.clip(logDepth, logMin, logMax)
# Map from the FIXED depth range (not the per-frame min/max) so a given depth
# always maps to the same color -- otherwise the mapping shifts every frame and
# the image flickers.
colored = np.interp(logDepth, (logMin, logMax), (0, 255))
colored = colored.astype(np.uint8)
colored = cv2.applyColorMap(colored, cv2.COLORMAP_JET)
colored[invalidMask] = 0
Expand Down
8 changes: 6 additions & 2 deletions examples/python/ToF/tof_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ def colorizeDepth(frame: np.ndarray, minDepth: float, maxDepth: float) -> np.nda
try:
logDepth = np.log(frame.astype(np.float32) + 1e-6)
logDepth[invalidMask] = 0.0
logDepth = np.clip(logDepth, np.log(minDepth + 1e-6), np.log(maxDepth + 1e-6))
colored = np.interp(logDepth, (logDepth[~invalidMask].min(), logDepth[~invalidMask].max()), (0, 255))
logMin, logMax = np.log(minDepth + 1e-6), np.log(maxDepth + 1e-6)
logDepth = np.clip(logDepth, logMin, logMax)
# Map from the FIXED depth range (not the per-frame min/max) so a given depth
# always maps to the same color -- otherwise the mapping shifts every frame and
# the image flickers.
colored = np.interp(logDepth, (logMin, logMax), (0, 255))
colored = colored.astype(np.uint8)
colored = cv2.applyColorMap(colored, cv2.COLORMAP_JET)
colored[invalidMask] = 0
Expand Down