freealise commited on
Commit
6ab1556
1 Parent(s): fcce986

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -198,14 +198,23 @@ def pano_depth_to_world_points(depth, scale):
198
  lat = lat.flatten()
199
 
200
  # Convert to cartesian coordinates
201
- x = radius * np.cos(lon) * np.sin(lat)
202
- y = radius * np.cos(lat)
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])
@@ -216,6 +225,7 @@ def get_mesh(image, depth, scale):
216
  points = pano_depth_to_world_points(gdepth, scale)
217
  pts3d = points[0]
218
  uv = points[1]
 
219
  print('radius from depth - ok')
220
 
221
  # Create a trimesh mesh from the points
@@ -223,11 +233,13 @@ def get_mesh(image, depth, scale):
223
  # colors are the RGB values of the image
224
 
225
  verts = pts3d.reshape(-1, 3)
226
- triangles = create_triangles(image.shape[0], image.shape[1])
227
- print('triangles - ok')
 
228
  colors = image.reshape(-1, 3)
229
  #mesh = trimesh.Trimesh(vertices=verts, faces=triangles, vertex_colors=colors)
230
- mesh = trimesh.PointCloud(verts, colors=colors)
 
231
  #material = trimesh.visual.texture.SimpleMaterial(image=image)
232
  #texture = trimesh.visual.TextureVisuals(uv=uv, image=image, material=material)
233
  #mesh.visual = texture
 
198
  lat = lat.flatten()
199
 
200
  # Convert to cartesian coordinates
201
+ x = np.cos(lon) * np.sin(lat)
202
+ y = np.cos(lat)
203
+ z = np.sin(lon) * np.sin(lat)
204
 
205
+ x_ = radius * x
206
+ y_ = radius * y
207
+ z_ = radius * z
208
+
209
+ _x = 255 * x
210
+ _y = 255 * y
211
+ _z = 255 * z
212
+
213
+ pts3d = np.stack([x_, y_, z_, _x, _y, _z], axis=1)
214
  uv = np.stack([lon, lat], axis=1)
215
+ lines = np.arange(0, depth.shape[0]*depth.shape[1], 1)
216
 
217
+ return [pts3d, uv, lines]
218
 
219
  def rgb2gray(rgb):
220
  return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
 
225
  points = pano_depth_to_world_points(gdepth, scale)
226
  pts3d = points[0]
227
  uv = points[1]
228
+ lines = points[2]
229
  print('radius from depth - ok')
230
 
231
  # Create a trimesh mesh from the points
 
233
  # colors are the RGB values of the image
234
 
235
  verts = pts3d.reshape(-1, 3)
236
+ #triangles = create_triangles(image.shape[0], image.shape[1])
237
+ #print('triangles - ok')
238
+ segments = trimesh.path.entities.Line(lines, closed=None, layer=None, metadata=None, color=None).explode()
239
  colors = image.reshape(-1, 3)
240
  #mesh = trimesh.Trimesh(vertices=verts, faces=triangles, vertex_colors=colors)
241
+ mesh = trimesh.path.path.Path3D(vertices=verts, entities=[segments], colors=colors)
242
+ #mesh = trimesh.PointCloud(verts, colors=colors)
243
  #material = trimesh.visual.texture.SimpleMaterial(image=image)
244
  #texture = trimesh.visual.TextureVisuals(uv=uv, image=image, material=material)
245
  #mesh.visual = texture