kcml commited on
Commit
094a253
·
1 Parent(s): 1f1646d
Files changed (1) hide show
  1. handcrafted_solution.py +8 -6
handcrafted_solution.py CHANGED
@@ -164,7 +164,7 @@ def get_smooth_uv_depth(vertices, depth, gest_seg_np, sfm_depth_np):
164
  vertex_depth = np.array(vertex_depth)
165
  return uv, vertex_depth
166
 
167
- '''
168
  from numba import njit, prange
169
  @njit(parallel=True)
170
  def fill_range(u, v, z, dilate_r, c, sfm_depth_np, sfm_color_np, H, W):
@@ -178,7 +178,7 @@ def fill_range(u, v, z, dilate_r, c, sfm_depth_np, sfm_color_np, H, W):
178
  if DUMP_IMG:
179
  sfm_color_np[j, i] = c
180
  return sfm_depth_np, sfm_color_np
181
- '''
182
 
183
  def get_SfM_depth(points3D, depth_np, gest_seg_np, K, R, t, dilate_r = 5):
184
  '''Project 3D sfm pointcloud to the image plane '''
@@ -204,8 +204,8 @@ def get_SfM_depth(points3D, depth_np, gest_seg_np, K, R, t, dilate_r = 5):
204
  #print('dim of us uv zs rgb:', len(us), len(vs), len(zs), len(rgb))
205
  for u,v,z,c in zip(us,vs,zs, rgb):
206
 
207
- #sfm_depth_np, sfm_color_np = fill_range(u, v, z, dilate_r, c, sfm_depth_np, sfm_color_np, H, W)
208
-
209
  i_range = range(max(0, u - dilate_r), min(W, u + dilate_r))
210
  j_range = range(max(0, v - dilate_r), min(H, v + dilate_r))
211
  for i in i_range:
@@ -217,7 +217,7 @@ def get_SfM_depth(points3D, depth_np, gest_seg_np, K, R, t, dilate_r = 5):
217
  sfm_depth_np[j, i] = z
218
  if DUMP_IMG:
219
  sfm_color_np[j, i] = c
220
-
221
 
222
  #print(f'checked {checked} pts')
223
 
@@ -523,7 +523,7 @@ def delete_one_vert(vertices, vertices_3d, connections, vert_to_del):
523
 
524
  def prune_far(all_3d_vertices, connections_3d, prune_dist_thr=3000):
525
  '''Prune vertices that are far away from any the other vertices'''
526
- if (len(all_3d_vertices) < 2) or len(connections_3d) < 1:
527
  return all_3d_vertices, connections_3d
528
 
529
  isolated = []
@@ -543,6 +543,8 @@ def prune_far(all_3d_vertices, connections_3d, prune_dist_thr=3000):
543
  #print('isolated:', isolated_pt)
544
  pt_to_del = all_3d_vertices[isolated_pt]
545
  all_3d_vertices, connections_3d = delete_one_vert([], all_3d_vertices, connections_3d, pt_to_del)
 
 
546
 
547
  distmat = cdist(all_3d_vertices, all_3d_vertices)
548
  for i, v in enumerate(distmat):
 
164
  vertex_depth = np.array(vertex_depth)
165
  return uv, vertex_depth
166
 
167
+
168
  from numba import njit, prange
169
  @njit(parallel=True)
170
  def fill_range(u, v, z, dilate_r, c, sfm_depth_np, sfm_color_np, H, W):
 
178
  if DUMP_IMG:
179
  sfm_color_np[j, i] = c
180
  return sfm_depth_np, sfm_color_np
181
+
182
 
183
  def get_SfM_depth(points3D, depth_np, gest_seg_np, K, R, t, dilate_r = 5):
184
  '''Project 3D sfm pointcloud to the image plane '''
 
204
  #print('dim of us uv zs rgb:', len(us), len(vs), len(zs), len(rgb))
205
  for u,v,z,c in zip(us,vs,zs, rgb):
206
 
207
+ sfm_depth_np, sfm_color_np = fill_range(u, v, z, dilate_r, c, sfm_depth_np, sfm_color_np, H, W)
208
+ '''
209
  i_range = range(max(0, u - dilate_r), min(W, u + dilate_r))
210
  j_range = range(max(0, v - dilate_r), min(H, v + dilate_r))
211
  for i in i_range:
 
217
  sfm_depth_np[j, i] = z
218
  if DUMP_IMG:
219
  sfm_color_np[j, i] = c
220
+ '''
221
 
222
  #print(f'checked {checked} pts')
223
 
 
523
 
524
  def prune_far(all_3d_vertices, connections_3d, prune_dist_thr=3000):
525
  '''Prune vertices that are far away from any the other vertices'''
526
+ if (len(all_3d_vertices) < 3) or len(connections_3d) < 1:
527
  return all_3d_vertices, connections_3d
528
 
529
  isolated = []
 
543
  #print('isolated:', isolated_pt)
544
  pt_to_del = all_3d_vertices[isolated_pt]
545
  all_3d_vertices, connections_3d = delete_one_vert([], all_3d_vertices, connections_3d, pt_to_del)
546
+ if (len(all_3d_vertices) < 3) or len(connections_3d) < 1:
547
+ return all_3d_vertices, connections_3d
548
 
549
  distmat = cdist(all_3d_vertices, all_3d_vertices)
550
  for i, v in enumerate(distmat):