Siromanec commited on
Commit
babad62
1 Parent(s): cdd5e5a

added dbscan

Browse files
Files changed (1) hide show
  1. handcrafted_solution.py +4 -2
handcrafted_solution.py CHANGED
@@ -14,6 +14,7 @@ from hoho.read_write_colmap import read_cameras_binary, read_images_binary, read
14
  from scipy.spatial import KDTree
15
  from scipy.spatial.distance import cdist
16
  import scipy.cluster.hierarchy as shc
 
17
 
18
  apex_color = gestalt_color_mapping["apex"]
19
  eave_end_point = gestalt_color_mapping["eave_end_point"]
@@ -185,6 +186,7 @@ def infer_missing_vertices(ridge_edges, rake_edges):
185
  missing_candidates = rake_ends.query_ball_tree(ridge_ends, 5)
186
  missing_candidates = np.concatenate([*missing_candidates])
187
  missing_candidates = np.unique(missing_candidates).astype(np.int32)
 
188
  return ridge_ends.data[missing_candidates]
189
 
190
 
@@ -439,7 +441,7 @@ def predict(entry, visualize=False, scale_estimation_coefficient=2.5, **kwargs)
439
  for k, v in entry["images"].items():
440
  image_dict[v.name] = v
441
  points = [v.xyz for k, v in entry["points3d"].items()]
442
- too_big = len(points) > 25000
443
 
444
  if not too_big:
445
  points = np.array(points)
@@ -448,7 +450,7 @@ def predict(entry, visualize=False, scale_estimation_coefficient=2.5, **kwargs)
448
 
449
  # print(len(points))
450
 
451
- clustered = shc.fclusterdata(points, 100, criterion='distance')
452
  clustered_indices = np.argsort(clustered)
453
 
454
  points = points[clustered_indices]
 
14
  from scipy.spatial import KDTree
15
  from scipy.spatial.distance import cdist
16
  import scipy.cluster.hierarchy as shc
17
+ from sklearn.cluster import DBSCAN
18
 
19
  apex_color = gestalt_color_mapping["apex"]
20
  eave_end_point = gestalt_color_mapping["eave_end_point"]
 
186
  missing_candidates = rake_ends.query_ball_tree(ridge_ends, 5)
187
  missing_candidates = np.concatenate([*missing_candidates])
188
  missing_candidates = np.unique(missing_candidates).astype(np.int32)
189
+
190
  return ridge_ends.data[missing_candidates]
191
 
192
 
 
441
  for k, v in entry["images"].items():
442
  image_dict[v.name] = v
443
  points = [v.xyz for k, v in entry["points3d"].items()]
444
+ too_big = False
445
 
446
  if not too_big:
447
  points = np.array(points)
 
450
 
451
  # print(len(points))
452
 
453
+ clustered = DBSCAN(eps=100, min_samples=10).fit(points).labels_
454
  clustered_indices = np.argsort(clustered)
455
 
456
  points = points[clustered_indices]