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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -237,15 +237,23 @@ def pano_depth_to_world_points(depth, location):
237
  for j in range(0, 1): #(0,2)
238
  #rnd_lon = (np.random.rand(depth.shape[0]*depth.shape[1]) - 0.5) / 8
239
  #rnd_lat = (np.random.rand(depth.shape[0]*depth.shape[1]) - 0.5) / 8
240
- d_lon = lon + i/2 * np.pi*2 / depth.shape[1] #+ location["heading"] / 180 * np.pi
241
- d_lat = lat + j/2 * np.pi / depth.shape[0] #+ location["pitch"] / 180 * np.pi
242
 
243
  # Convert to cartesian coordinates
244
  x = radius * np.cos(d_lon) * np.sin(d_lat) + location["lat"]
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)
 
237
  for j in range(0, 1): #(0,2)
238
  #rnd_lon = (np.random.rand(depth.shape[0]*depth.shape[1]) - 0.5) / 8
239
  #rnd_lat = (np.random.rand(depth.shape[0]*depth.shape[1]) - 0.5) / 8
240
+ d_lon = lon + i/2 * np.pi*2 / depth.shape[1]
241
+ d_lat = lat + j/2 * np.pi / depth.shape[0]
242
 
243
  # Convert to cartesian coordinates
244
  x = radius * np.cos(d_lon) * np.sin(d_lat) + location["lat"]
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)