MCPcopy Create free account
hub / github.com/Picsart-AI-Research/Text2Video-Zero / write_depth

Function write_depth

annotator/midas/utils.py:165–189  ·  view source on GitHub ↗

Write depth map to pfm and png file. Args: path (str): filepath without extension depth (array): depth

(path, depth, bits=1)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

write_pfmFunction · 0.85

Tested by

no test coverage detected