MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / process_point_cloud

Function process_point_cloud

benchmark/models/loger/utils/visual_util.py:267–343  ·  view source on GitHub ↗

Process point cloud data and return vertices and colors

(data_dict, is_gt=False, color_offset=(0, 0, 0), gt_conf_mask=None)

Source from the content-addressed store, hash-verified

265
266 # Helper function to process point cloud data
267 def process_point_cloud(data_dict, is_gt=False, color_offset=(0, 0, 0), gt_conf_mask=None):
268 """Process point cloud data and return vertices and colors"""
269
270 # Select data source based on prediction mode
271 if "Pointmap" in prediction_mode and not is_gt:
272 if "world_points" in data_dict:
273 world_points = data_dict["world_points"]
274 world_points_conf = data_dict.get("world_points_conf", np.ones_like(world_points[..., 0]))
275 else:
276 world_points = data_dict["world_points_from_depth"]
277 world_points_conf = data_dict.get("depth_conf", np.ones_like(world_points[..., 0]))
278 else:
279 world_points = data_dict["world_points_from_depth"]
280 world_points_conf = data_dict.get("depth_conf", np.ones_like(world_points[..., 0]))
281 if is_gt and "world_points_conf" in data_dict:
282 # For GT, use world_points_conf if available
283 world_points_conf = data_dict["world_points_conf"]
284
285 images = data_dict["images"]
286
287 # Apply frame selection
288 if selected_frame_idx is not None:
289 world_points = world_points[selected_frame_idx][None]
290 world_points_conf = world_points_conf[selected_frame_idx][None]
291 images = images[selected_frame_idx][None]
292
293 # Prepare vertices and colors
294 vertices = world_points.reshape(-1, 3)
295
296 # Handle different image formats
297 if images.ndim == 4 and images.shape[1] == 3: # NCHW format
298 colors = np.transpose(images, (0, 2, 3, 1))
299 else: # NHWC format
300 colors = images
301 colors = (colors.reshape(-1, 3) * 255).astype(np.uint8)
302
303 # Apply color offset for distinction
304 colors = colors.astype(np.float32)
305 colors[:, 0] = np.clip(colors[:, 0] + color_offset[0], 0, 255)
306 colors[:, 1] = np.clip(colors[:, 1] + color_offset[1], 0, 255)
307 colors[:, 2] = np.clip(colors[:, 2] + color_offset[2], 0, 255)
308 colors = colors.astype(np.uint8)
309
310 # Apply confidence filtering
311 conf = world_points_conf.reshape(-1)
312
313 if gt_conf_mask is not None:
314 # Use provided GT confidence mask for fair comparison
315 conf_mask = gt_conf_mask
316 else:
317 # Create confidence mask based on data type
318 if is_gt:
319 # For GT, use a lower threshold since it's generally more reliable
320 conf_threshold = 0.01 # Much lower threshold for GT
321 else:
322 # For predictions, use the specified threshold
323 if conf_thres == 0.0:
324 conf_threshold = 0.0

Callers 1

Calls 1

getMethod · 0.45

Tested by

no test coverage detected