freealise commited on
Commit
c574318
1 Parent(s): 434ff0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -245,15 +245,7 @@ def pano_depth_to_world_points(depth, location):
245
  y = radius * np.cos(d_lat)
246
  z = radius * np.sin(d_lon) * np.sin(d_lat) + location["lng"]
247
 
248
- theta = location["heading"] / 180 * np.pi
249
- phi = location["pitch"] / 180 * np.pi
250
-
251
- x_ = x*np.cos(phi)*np.cos(theta) - y*np.sin(theta) + z*np.sin(phi)*np.cos(theta)
252
- y_ = x*np.sin(theta)*np.cos(phi) + y*np.cos(theta) + z*np.sin(phi)*np.sin(theta)
253
- z_ = -x*np.sin(phi) + z*np.cos(phi)
254
- #https://www.physicsforums.com/threads/rotate-points-on-sphere-by-theta-and-phi.1014278/
255
-
256
- pts = np.stack([x_, y_, z_], axis=1)
257
  uvs = np.stack([lon, lat], axis=1)
258
 
259
  pts3d = np.concatenate((pts3d, pts), axis=0)
@@ -305,6 +297,15 @@ def get_mesh(image, depth, blur_data, loadall):
305
  #mesh = trimesh.Trimesh(vertices=verts, faces=triangles, vertex_colors=colors)
306
  mesh.append(trimesh.PointCloud(verts, colors=clrs))
307
  mesh[len(mesh)-1].merge_vertices()
 
 
 
 
 
 
 
 
 
308
  #material = trimesh.visual.texture.SimpleMaterial(image=image)
309
  #texture = trimesh.visual.TextureVisuals(uv=uv, image=image, material=material)
310
  #mesh.visual = texture
 
245
  y = radius * np.cos(d_lat)
246
  z = radius * np.sin(d_lon) * np.sin(d_lat) + location["lng"]
247
 
248
+ pts = np.stack([x, y, z], axis=1)
 
 
 
 
 
 
 
 
249
  uvs = np.stack([lon, lat], axis=1)
250
 
251
  pts3d = np.concatenate((pts3d, pts), axis=0)
 
297
  #mesh = trimesh.Trimesh(vertices=verts, faces=triangles, vertex_colors=colors)
298
  mesh.append(trimesh.PointCloud(verts, colors=clrs))
299
  mesh[len(mesh)-1].merge_vertices()
300
+
301
+ theta = locations[fnum]["heading"] / 180 * np.pi
302
+ phi = locations[fnum]["pitch"] / 180 * np.pi
303
+ center = [locations[fnum]["lat"], 0, locations[fnum]["lng"]]
304
+
305
+ r_matrix = trimesh.transformations.rotation_matrix(theta, [0, 1, 0], center)
306
+ mesh[len(mesh)-1].apply_transform(r_matrix)
307
+ r_matrix = trimesh.transformations.rotation_matrix(phi, [1, 0, 0], center)
308
+ mesh[len(mesh)-1].apply_transform(r_matrix)
309
  #material = trimesh.visual.texture.SimpleMaterial(image=image)
310
  #texture = trimesh.visual.TextureVisuals(uv=uv, image=image, material=material)
311
  #mesh.visual = texture