Write depth map to pfm and png file. Args: path (str): filepath without extension depth (array): depth
(path, depth, bits=1)
| 168 | return depth_resized |
| 169 | |
| 170 | def write_depth(path, depth, bits=1): |
| 171 | """Write depth map to pfm and png file. |
| 172 | |
| 173 | Args: |
| 174 | path (str): filepath without extension |
| 175 | depth (array): depth |
| 176 | """ |
| 177 | write_pfm(path + ".pfm", depth.astype(np.float32)) |
| 178 | |
| 179 | depth_min = depth.min() |
| 180 | depth_max = depth.max() |
| 181 | |
| 182 | max_val = (2**(8*bits))-1 |
| 183 | |
| 184 | if depth_max - depth_min > np.finfo("float").eps: |
| 185 | out = max_val * (depth - depth_min) / (depth_max - depth_min) |
| 186 | else: |
| 187 | out = np.zeros(depth.shape, dtype=depth.type) |
| 188 | |
| 189 | if bits == 1: |
| 190 | cv2.imwrite(path + ".png", out.astype("uint8")) |
| 191 | elif bits == 2: |
| 192 | cv2.imwrite(path + ".png", out.astype("uint16")) |
| 193 | |
| 194 | return |
nothing calls this directly
no test coverage detected