Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,13 +112,20 @@ def main(share=True):
|
|
| 112 |
cl, ind = pcd.remove_statistical_outlier(nb_neighbors=20, std_ratio=3.0)
|
| 113 |
pcd = pcd.select_by_index(ind)
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
# save pcd to temporary .ply for Model3D
|
| 116 |
tmp_ply = tempfile.NamedTemporaryFile(suffix='.ply', delete=False)
|
| 117 |
-
o3d.
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
depth = cv2.resize(ppd_depth, (W, H), interpolation=cv2.INTER_LINEAR)
|
| 120 |
|
| 121 |
# save raw depth (npy)
|
|
|
|
| 122 |
tmp_raw_depth = tempfile.NamedTemporaryFile(suffix='.npy', delete=False)
|
| 123 |
np.save(tmp_raw_depth.name, depth)
|
| 124 |
|
|
|
|
| 112 |
cl, ind = pcd.remove_statistical_outlier(nb_neighbors=20, std_ratio=3.0)
|
| 113 |
pcd = pcd.select_by_index(ind)
|
| 114 |
|
| 115 |
+
points = np.asarray(pcd.points, dtype=np.float32)
|
| 116 |
+
colors = np.asarray(pcd.colors, dtype=np.float32) # [0,1]
|
| 117 |
+
colors = (colors * 255).astype(np.uint8)
|
| 118 |
+
|
| 119 |
# save pcd to temporary .ply for Model3D
|
| 120 |
tmp_ply = tempfile.NamedTemporaryFile(suffix='.ply', delete=False)
|
| 121 |
+
pcd_to_save = o3d.geometry.PointCloud()
|
| 122 |
+
pcd_to_save.points = o3d.utility.Vector3dVector(points)
|
| 123 |
+
pcd_to_save.colors = o3d.utility.Vector3dVector(colors)
|
| 124 |
+
o3d.io.write_point_cloud(tmp_ply.name, pcd_to_save)
|
| 125 |
|
|
|
|
| 126 |
|
| 127 |
# save raw depth (npy)
|
| 128 |
+
depth = cv2.resize(ppd_depth, (W, H), interpolation=cv2.INTER_LINEAR)
|
| 129 |
tmp_raw_depth = tempfile.NamedTemporaryFile(suffix='.npy', delete=False)
|
| 130 |
np.save(tmp_raw_depth.name, depth)
|
| 131 |
|