add more protections
Browse files- handcrafted_solution.py +6 -4
handcrafted_solution.py
CHANGED
|
@@ -196,10 +196,12 @@ def get_SfM_depth(points3D, depth_np, gest_seg_np, K, R, t, dilate_r = 5):
|
|
| 196 |
xyz = world_to_cam @ XYZ1.transpose()
|
| 197 |
xyz = np.transpose(xyz)
|
| 198 |
#print('shape of xyz: ', xyz.shape)
|
| 199 |
-
valid_idx = ~np.isclose(xyz[:,2], 0, atol=1e-
|
| 200 |
xyz = xyz[valid_idx, :]
|
| 201 |
us, vs, zs = xyz[:,0]/xyz[:,2], xyz[:,1]/xyz[:,2], xyz[:,2]
|
| 202 |
-
#print('dim of us uv zs rgb:', len(us), len(vs), len(zs), len(rgb))
|
|
|
|
|
|
|
| 203 |
us = us.astype(np.int32)
|
| 204 |
vs = vs.astype(np.int32)
|
| 205 |
#checked = 0
|
|
@@ -615,8 +617,8 @@ def predict(entry, visualize=False, prune_dist_thr=600, depth_scale=2.5, ) -> Tu
|
|
| 615 |
all_3d_vertices, connections_3d = merge_vertices_3d(vert_edge_per_image, 30)
|
| 616 |
#print(f'after merge, {len(all_3d_vertices)} 3d vertices and {len(connections_3d)} 3d connections')
|
| 617 |
#all_3d_vertices_clean, connections_3d_clean = prune_not_connected(all_3d_vertices, connections_3d)
|
| 618 |
-
all_3d_vertices_clean, connections_3d_clean = prune_far(all_3d_vertices, connections_3d, prune_dist_thr=prune_dist_thr)
|
| 619 |
-
|
| 620 |
#print(f'after pruning, {len(all_3d_vertices_clean)} 3d clean vertices and {len(connections_3d_clean)} 3d clean connections')
|
| 621 |
if (len(all_3d_vertices_clean) < 2) or len(connections_3d_clean) < 1:
|
| 622 |
print (f'Not enough vertices or connections in the 3D vertices')
|
|
|
|
| 196 |
xyz = world_to_cam @ XYZ1.transpose()
|
| 197 |
xyz = np.transpose(xyz)
|
| 198 |
#print('shape of xyz: ', xyz.shape)
|
| 199 |
+
valid_idx = ~np.isclose(xyz[:,2], 0, atol=1e-2) & ~np.isnan(xyz[:,0]) & ~np.isnan(xyz[:,1]) & ~np.isnan(xyz[:,2])
|
| 200 |
xyz = xyz[valid_idx, :]
|
| 201 |
us, vs, zs = xyz[:,0]/xyz[:,2], xyz[:,1]/xyz[:,2], xyz[:,2]
|
| 202 |
+
#print('dim of us uv zs rgb:', len(us), len(vs), len(zs), len(rgb))
|
| 203 |
+
us = us[~np.isnan(us)]
|
| 204 |
+
vs = vs[~np.isnan(vs)]
|
| 205 |
us = us.astype(np.int32)
|
| 206 |
vs = vs.astype(np.int32)
|
| 207 |
#checked = 0
|
|
|
|
| 617 |
all_3d_vertices, connections_3d = merge_vertices_3d(vert_edge_per_image, 30)
|
| 618 |
#print(f'after merge, {len(all_3d_vertices)} 3d vertices and {len(connections_3d)} 3d connections')
|
| 619 |
#all_3d_vertices_clean, connections_3d_clean = prune_not_connected(all_3d_vertices, connections_3d)
|
| 620 |
+
#all_3d_vertices_clean, connections_3d_clean = prune_far(all_3d_vertices, connections_3d, prune_dist_thr=prune_dist_thr)
|
| 621 |
+
all_3d_vertices_clean, connections_3d_clean = all_3d_vertices, connections_3d # don't prune -> cost:2.0
|
| 622 |
#print(f'after pruning, {len(all_3d_vertices_clean)} 3d clean vertices and {len(connections_3d_clean)} 3d clean connections')
|
| 623 |
if (len(all_3d_vertices_clean) < 2) or len(connections_3d_clean) < 1:
|
| 624 |
print (f'Not enough vertices or connections in the 3D vertices')
|