dmytromishkin commited on
Commit
fd53e59
·
unverified ·
1 Parent(s): 6e38ddc

more checks

Browse files
Files changed (1) hide show
  1. hoho2025/example_solutions.py +8 -3
hoho2025/example_solutions.py CHANGED
@@ -695,9 +695,14 @@ def prune_too_far(all_3d_vertices, connections_3d, colmap_rec, th=3.0):
695
  Vertices lifted from noisy monocular depth with no nearby COLMAP point are
696
  likely hallucinations; discarding them improves geometric accuracy.
697
  """
 
 
 
698
  xyz_sfm = []
699
  for k, v in colmap_rec.points3D.items():
700
  xyz_sfm.append(v.xyz)
 
 
701
  xyz_sfm = np.array(xyz_sfm)
702
  diff = all_3d_vertices[:, None, :] - xyz_sfm[None, :, :]
703
  mindist = np.sqrt((diff ** 2).sum(axis=-1)).min(axis=1)
@@ -754,9 +759,9 @@ def predict_wireframe(entry, verbose: bool = False) -> Tuple[np.ndarray, List[in
754
 
755
  # Merge vertices from all images
756
  all_3d_vertices, connections_3d = merge_vertices_3d(vert_edge_per_image, 0.5)
757
- all_3d_vertices_clean, connections_3d_clean = prune_not_connected(all_3d_vertices, connections_3d, keep_largest=False)
758
- all_3d_vertices_clean, connections_3d_clean = prune_too_far(all_3d_vertices_clean, connections_3d_clean, colmap_rec, th = 4.0)
759
-
760
  if (len(all_3d_vertices_clean) < 2) or len(connections_3d_clean) < 1:
761
  if verbose:
762
  print(f'Not enough vertices or connections in the 3D vertices')
 
695
  Vertices lifted from noisy monocular depth with no nearby COLMAP point are
696
  likely hallucinations; discarding them improves geometric accuracy.
697
  """
698
+ if len(all_3d_vertices) == 0:
699
+ return np.empty((0, 3)), []
700
+
701
  xyz_sfm = []
702
  for k, v in colmap_rec.points3D.items():
703
  xyz_sfm.append(v.xyz)
704
+ if not xyz_sfm:
705
+ return all_3d_vertices, connections_3d
706
  xyz_sfm = np.array(xyz_sfm)
707
  diff = all_3d_vertices[:, None, :] - xyz_sfm[None, :, :]
708
  mindist = np.sqrt((diff ** 2).sum(axis=-1)).min(axis=1)
 
759
 
760
  # Merge vertices from all images
761
  all_3d_vertices, connections_3d = merge_vertices_3d(vert_edge_per_image, 0.5)
762
+ all_3d_vertices_clean, connections_3d_clean = prune_not_connected(all_3d_vertices, connections_3d, keep_largest=False)
763
+ all_3d_vertices_clean, connections_3d_clean = prune_too_far(all_3d_vertices_clean, connections_3d_clean, colmap_rec, th=4.0)
764
+
765
  if (len(all_3d_vertices_clean) < 2) or len(connections_3d_clean) < 1:
766
  if verbose:
767
  print(f'Not enough vertices or connections in the 3D vertices')