MCPcopy Create free account
hub / github.com/Robotics-STAR-Lab/H2-Mapping / get_features

Function get_features

mapping/src/functions/render_helpers.py:120–154  ·  view source on GitHub ↗

Retrieve the voxel corresponding to the sampling point and the surrounding vertices, and obtain the input features of each sampling point through cubic linear interpolation Args: samples (dict): sampling points information. map_states (dict): voxel information acco

(samples, map_states, voxel_size)

Source from the content-addressed store, hash-verified

118
119@torch.enable_grad()
120def get_features(samples, map_states, voxel_size):
121 """
122 Retrieve the voxel corresponding to the sampling point and the surrounding vertices,
123 and obtain the input features of each sampling point through cubic linear interpolation
124
125 Args:
126 samples (dict): sampling points information.
127 map_states (dict): voxel information according to the octrees.
128 voxel_size (int): voxel size.
129
130 Returns:
131 inputs (dict): sampled distance(N_points) and embedding feature vectors(N_points,emb_dim).
132 """
133 # encoder states
134 point_feats = map_states["voxel_vertex_idx"].cuda()
135 point_xyz = map_states["voxel_center_xyz"].cuda() # (voxel_num,3)
136 sdf_priors_all = map_states["sdf_priors"].cuda()
137
138 # ray point samples
139 sampled_idx = samples["sampled_point_voxel_idx"].long()
140 sampled_xyz = samples["sampled_point_xyz"].requires_grad_(True)
141 # sampled_idx stores the index of each sampling point corresponding to voxel_center_xyz,
142 # and after F.embedding, the voxel center corresponding to each point is obtained
143 point_xyz = F.embedding(sampled_idx, point_xyz) # (chunk_size,3)
144 # sampled_idx is the voxel id corresponding to the sampling point,
145 # and find the vert id contained in feats according to the voxel id
146 point_emd_idx = F.embedding(sampled_idx, point_feats) # (chunk_size,8)
147
148 point_sdf_priors = F.embedding(point_emd_idx, sdf_priors_all).view(point_xyz.size(0),
149 -1) # (chunk_size,8,emd_dim) -> (chunk_size,8*emd_dim)
150 sdf_priors = get_embeddings(sampled_xyz, point_xyz, point_sdf_priors, voxel_size)
151 feats = None
152
153 inputs = {"emb": feats, "sdf_priors": sdf_priors}
154 return inputs
155
156
157@torch.no_grad()

Callers 3

get_scores_onceFunction · 0.85
render_raysFunction · 0.85
bundle_adjust_framesFunction · 0.85

Calls 2

get_embeddingsFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected