MCPcopy Index your code
hub / github.com/LeapLabTHU/ActiveNeRF / load_llff_data

Function load_llff_data

load_llff.py:243–316  ·  view source on GitHub ↗
(basedir, factor=8, recenter=True, bd_factor=.75, spherify=False, path_zflat=False)

Source from the content-addressed store, hash-verified

241
242
243def load_llff_data(basedir, factor=8, recenter=True, bd_factor=.75, spherify=False, path_zflat=False):
244
245
246 poses, bds, imgs = _load_data(basedir, factor=factor) # factor=8 downsamples original imgs by 8x
247 print('Loaded', basedir, bds.min(), bds.max())
248
249 # Correct rotation matrix ordering and move variable dim to axis 0
250 poses = np.concatenate([poses[:, 1:2, :], -poses[:, 0:1, :], poses[:, 2:, :]], 1)
251 poses = np.moveaxis(poses, -1, 0).astype(np.float32)
252 imgs = np.moveaxis(imgs, -1, 0).astype(np.float32)
253 images = imgs
254 bds = np.moveaxis(bds, -1, 0).astype(np.float32)
255
256 # Rescale if bd_factor is provided
257 sc = 1. if bd_factor is None else 1./(bds.min() * bd_factor)
258 poses[:,:3,3] *= sc
259 bds *= sc
260
261 if recenter:
262 poses = recenter_poses(poses)
263
264 if spherify:
265 poses, render_poses, bds = spherify_poses(poses, bds)
266
267 else:
268
269 c2w = poses_avg(poses)
270 print('recentered', c2w.shape)
271 print(c2w[:3,:4])
272
273 ## Get spiral
274 # Get average pose
275 up = normalize(poses[:, :3, 1].sum(0))
276
277 # Find a reasonable "focus depth" for this dataset
278 close_depth, inf_depth = bds.min()*.9, bds.max()*5.
279 dt = .75
280 mean_dz = 1./(((1.-dt)/close_depth + dt/inf_depth))
281 focal = mean_dz
282
283 # Get radii for spiral path
284 shrink_factor = .8
285 zdelta = close_depth * .2
286 tt = poses[:,:3,3] # ptstocam(poses[:3,3,:].T, c2w).T
287 rads = np.percentile(np.abs(tt), 90, 0)
288 c2w_path = c2w
289 N_views = 120
290 N_rots = 2
291 if path_zflat:
292# zloc = np.percentile(tt, 10, 0)[2]
293 zloc = -close_depth * .1
294 c2w_path[:3,3] = c2w_path[:3,3] + zloc * c2w_path[:3,2]
295 rads[2] = 0.
296 N_rots = 1
297 N_views/=2
298
299 # Generate poses for spiral path
300 render_poses = render_path_spiral(c2w_path, up, rads, focal, zdelta, zrate=.5, rots=N_rots, N=N_views)

Callers 1

trainFunction · 0.90

Calls 6

_load_dataFunction · 0.85
recenter_posesFunction · 0.85
spherify_posesFunction · 0.85
poses_avgFunction · 0.85
normalizeFunction · 0.85
render_path_spiralFunction · 0.85

Tested by

no test coverage detected