Open ItaloFan opened 2 years ago
Hi, @ItaloFan , maybe you can try to use the depth_min and depth depth_max read from XXXXXXXX_cam.txt to exclude some abnormal values, and then use them to normalize depth maps.
Thanks for your great work! I used program to read .dmb file by removing the file header and getting a two dimensional array. Then I used plt.imshow to display the dimensional array. My way does not get a good display. Could you tell me how to get the depth map shown above from .dmb files?Thank you very much.
I can do that. You can find me. My Q: 917318329
Sorry for late reply.
Thanks for your great work! I used program to read .dmb file by removing the file header and getting a two dimensional array. Then I used plt.imshow to display the dimensional array. My way does not get a good display. Could you tell me how to get the depth map shown above from .dmb files?Thank you very much.
Here's my code:
import numpy as np
from PIL import Image
def read_depth(
input: str, output: str, min_depth: float = None, max_depth: float = None
):
file = open(input, "rb")
type_, h, w, nb = np.fromfile(file, dtype=np.int32, count=4)
depth_map = np.fromfile(file, dtype=np.float32)
file.close()
depth_map = np.resize(depth_map, (h, w))
depth_map[np.isnan(depth_map)] = 0
if min_depth:
depth_map[depth_map < min_depth] = min_depth
if max_depth:
depth_map[depth_map > max_depth] = max_depth
if not (min_depth or max_depth):
min_depth, max_depth = np.quantile(depth_map[depth_map > 0], (0.05, 0.95))
depth_map[depth_map < min_depth] = min_depth
depth_map[depth_map > max_depth] = max_depth
# convert to range [0-1]
depth_map = (depth_map - depth_map.min()) / (
depth_map.max() - depth_map.min()
)
# pseudo color map
cm_jet = mpl.cm.get_cmap("jet")
im = cm_jet(depth_map)
im = np.uint8(im * (2**8 - 1))
img = Image.fromarray(im)
img.save(output) # save picture
By the way, I tried to clip depth using infomation from camera, but it doesn't improve much.
Thanks for your great work! I get excellent result on my indoor dataset. But when I try to visualize the depth map, I find it's ugly compared with colmap depth map. I just normalize the depth map through (depthmap - depthmap.min)/(depthmap.max - depthmap.min). Is there anything better I can do? colmap depth map: ACMP depth map: Planar model: