Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -203,8 +203,9 @@ def pano_depth_to_world_points(depth):
|
|
203 |
z = radius * np.sin(lon) * np.sin(lat)
|
204 |
|
205 |
pts3d = np.stack([x, y, z], axis=1)
|
|
|
206 |
|
207 |
-
return pts3d
|
208 |
|
209 |
def rgb2gray(rgb):
|
210 |
return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
|
@@ -212,7 +213,9 @@ def rgb2gray(rgb):
|
|
212 |
def get_mesh(image, depth):
|
213 |
gdepth = rgb2gray(depth)
|
214 |
print('depth to gray - ok')
|
215 |
-
|
|
|
|
|
216 |
print('radius from depth - ok')
|
217 |
|
218 |
# Create a trimesh mesh from the points
|
@@ -224,7 +227,7 @@ def get_mesh(image, depth):
|
|
224 |
print('triangles - ok')
|
225 |
#colors = image.reshape(-1, 3)
|
226 |
mesh = trimesh.Trimesh(vertices=verts, faces=triangles)#, vertex_colors=colors)
|
227 |
-
|
228 |
material = trimesh.visual.texture.SimpleMaterial(image=image)
|
229 |
texture = trimesh.visual.TextureVisuals(uv=uv, image=image, material=material)
|
230 |
mesh.visual = texture
|
|
|
203 |
z = radius * np.sin(lon) * np.sin(lat)
|
204 |
|
205 |
pts3d = np.stack([x, y, z], axis=1)
|
206 |
+
uv = np.stack([lon, lat], axis=1)
|
207 |
|
208 |
+
return [pts3d, uv]
|
209 |
|
210 |
def rgb2gray(rgb):
|
211 |
return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
|
|
|
213 |
def get_mesh(image, depth):
|
214 |
gdepth = rgb2gray(depth)
|
215 |
print('depth to gray - ok')
|
216 |
+
points = pano_depth_to_world_points(gdepth)
|
217 |
+
pts3d = points[0]
|
218 |
+
uv = points[1]
|
219 |
print('radius from depth - ok')
|
220 |
|
221 |
# Create a trimesh mesh from the points
|
|
|
227 |
print('triangles - ok')
|
228 |
#colors = image.reshape(-1, 3)
|
229 |
mesh = trimesh.Trimesh(vertices=verts, faces=triangles)#, vertex_colors=colors)
|
230 |
+
print(mesh.vertex_normals[0])
|
231 |
material = trimesh.visual.texture.SimpleMaterial(image=image)
|
232 |
texture = trimesh.visual.TextureVisuals(uv=uv, image=image, material=material)
|
233 |
mesh.visual = texture
|