Spaces:
Starting
Starting
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ import torch.nn.functional as F
|
|
9 |
from torchvision import transforms
|
10 |
from torchvision.transforms import Compose
|
11 |
import trimesh
|
12 |
-
from geometry import create_triangles
|
13 |
import tempfile
|
14 |
from functools import partial
|
15 |
import spaces
|
@@ -247,10 +247,10 @@ def pano_depth_to_world_points(depth):
|
|
247 |
z = radius * np.sin(d_lon) * np.sin(d_lat)
|
248 |
|
249 |
pts = np.stack([x, y, z], axis=1)
|
250 |
-
uvs = np.stack([lon, lat], axis=1)
|
251 |
|
252 |
pts3d = np.concatenate((pts3d, pts), axis=0)
|
253 |
-
uv = np.concatenate((uv, uvs), axis=0)
|
254 |
#print(f'i: {i}, j: {j}')
|
255 |
j = j+1
|
256 |
i = i+1
|
@@ -280,13 +280,13 @@ def get_mesh(image, depth, blur_data, loadall):
|
|
280 |
print('depth to gray - ok')
|
281 |
points = pano_depth_to_world_points(gdepth)
|
282 |
pts3d = points[0]
|
283 |
-
uv = points[1]
|
284 |
print('radius from depth - ok')
|
285 |
|
286 |
# Create a trimesh mesh from the points
|
287 |
# Each pixel is connected to its 4 neighbors
|
288 |
# colors are the RGB values of the image
|
289 |
-
uvs = uv.reshape(-1, 2)
|
290 |
verts = pts3d.reshape(-1, 3)
|
291 |
rgba = cv2.cvtColor(blur_img, cv2.COLOR_RGB2RGBA)
|
292 |
colors = rgba.reshape(-1, 4)
|
@@ -296,15 +296,15 @@ def get_mesh(image, depth, blur_data, loadall):
|
|
296 |
clrs = np.concatenate((clrs, colors), axis=0)
|
297 |
i = i+1
|
298 |
|
299 |
-
triangles = create_triangles(rgba.shape[0], rgba.shape[1])
|
300 |
-
mesh.append(trimesh.Trimesh(vertices=verts, faces=triangles))
|
301 |
-
rgba_pil = Image.fromarray(rgba.astype(np.uint8))
|
302 |
-
material = trimesh.visual.texture.SimpleMaterial(image=rgba_pil)
|
303 |
-
visuals = trimesh.visual.TextureVisuals(uv=uvs, image=rgba_pil, material=material)
|
304 |
-
mesh[len(mesh)-1].visual = visuals
|
305 |
-
print('triangles - ok')
|
306 |
|
307 |
-
|
308 |
mesh_n.append(str(fnum))
|
309 |
mesh[len(mesh)-1].merge_vertices()
|
310 |
|
|
|
9 |
from torchvision import transforms
|
10 |
from torchvision.transforms import Compose
|
11 |
import trimesh
|
12 |
+
#from geometry import create_triangles
|
13 |
import tempfile
|
14 |
from functools import partial
|
15 |
import spaces
|
|
|
247 |
z = radius * np.sin(d_lon) * np.sin(d_lat)
|
248 |
|
249 |
pts = np.stack([x, y, z], axis=1)
|
250 |
+
#uvs = np.stack([lon, lat], axis=1)
|
251 |
|
252 |
pts3d = np.concatenate((pts3d, pts), axis=0)
|
253 |
+
#uv = np.concatenate((uv, uvs), axis=0)
|
254 |
#print(f'i: {i}, j: {j}')
|
255 |
j = j+1
|
256 |
i = i+1
|
|
|
280 |
print('depth to gray - ok')
|
281 |
points = pano_depth_to_world_points(gdepth)
|
282 |
pts3d = points[0]
|
283 |
+
#uv = points[1]
|
284 |
print('radius from depth - ok')
|
285 |
|
286 |
# Create a trimesh mesh from the points
|
287 |
# Each pixel is connected to its 4 neighbors
|
288 |
# colors are the RGB values of the image
|
289 |
+
#uvs = uv.reshape(-1, 2)
|
290 |
verts = pts3d.reshape(-1, 3)
|
291 |
rgba = cv2.cvtColor(blur_img, cv2.COLOR_RGB2RGBA)
|
292 |
colors = rgba.reshape(-1, 4)
|
|
|
296 |
clrs = np.concatenate((clrs, colors), axis=0)
|
297 |
i = i+1
|
298 |
|
299 |
+
#triangles = create_triangles(rgba.shape[0], rgba.shape[1])
|
300 |
+
#mesh.append(trimesh.Trimesh(vertices=verts, faces=triangles))
|
301 |
+
#rgba_pil = Image.fromarray(rgba.astype(np.uint8))
|
302 |
+
#material = trimesh.visual.texture.SimpleMaterial(image=rgba_pil)
|
303 |
+
#visuals = trimesh.visual.TextureVisuals(uv=uvs, image=rgba_pil, material=material)
|
304 |
+
#mesh[len(mesh)-1].visual = visuals
|
305 |
+
#print('triangles - ok')
|
306 |
|
307 |
+
mesh.append(trimesh.PointCloud(verts, colors=clrs))
|
308 |
mesh_n.append(str(fnum))
|
309 |
mesh[len(mesh)-1].merge_vertices()
|
310 |
|