niessner / Matterport

Matterport3D is a pretty awesome dataset for RGB-D machine learning tasks :)
https://niessner.github.io/Matterport/
MIT License
929 stars 153 forks source link

how to read .dpt file? #60

Open nita-xwj opened 1 year ago

nita-xwj commented 1 year ago

got a .dpt file,which is the ground-truth depth of 360 RGB scene, but when I use Hinterstousser to read dpt file, it goes wrong.Here is the code:

*``` INT_BYTES = 4 USHORT_BYTES = 2 def load_hinter_depth(path): ''' Loads depth image from the '.dpt' format used by Hinterstoisser. ''' f = open(path, 'rb') h = struct.unpack('i', f.read(INT_BYTES))[0] # this output 1212500304 w = struct.unpack('i', f.read(INT_BYTES))[0] # this output 2048 depth_map = [] for i in range(h): depth_map.append(struct.unpack(w'H', f.read(w * USHORT_BYTES)))

return np.array(depth_map, np.uint16)

  return np.array(depth_map, np.float32)


My 360 RGB PNG is 1024 height and 2048 width.When I change range(h) to range(1024), it can run, but the result array is obvious wrong.
liuyuzhenn commented 8 months ago

Hi, have you solved this?