depth: (H, W)
(depth, minmax=None, cmap=cv2.COLORMAP_JET)
| 28 | |
| 29 | |
| 30 | def visualize_depth_numpy(depth, minmax=None, cmap=cv2.COLORMAP_JET): |
| 31 | """ |
| 32 | depth: (H, W) |
| 33 | """ |
| 34 | |
| 35 | x = np.nan_to_num(depth) # change nan to 0 |
| 36 | if minmax is None: |
| 37 | mi = np.min(x[x>0]) # get minimum positive depth (ignore background) |
| 38 | ma = np.max(x) |
| 39 | else: |
| 40 | mi,ma = minmax |
| 41 | |
| 42 | x = (x-mi)/(ma-mi+1e-8) # normalize to 0~1 |
| 43 | x = (255*x).astype(np.uint8) |
| 44 | x_ = cv2.applyColorMap(x, cmap) |
| 45 | return x_, [mi,ma] |
| 46 | |
| 47 | def visualize_depth(depth, minmax=None, cmap=cv2.COLORMAP_JET): |
| 48 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected