MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / fetch_unique_view_index

Function fetch_unique_view_index

dataset_loaders/load_7Scenes.py:346–390  ·  view source on GitHub ↗

local NeRF data selection

(args, train_set, threshold)

Source from the content-addressed store, hash-verified

344 return train_set, val_set, bounds
345
346def fetch_unique_view_index(args, train_set, threshold):
347 ''' local NeRF data selection '''
348 # Frustum near-far threshold
349 K_APPROX, FRUSTUM_APPROX, W, H = camera_frustum_initializer(args)
350
351 # compute how many unique views in the train set
352 keyframe_idx = 0
353 unique_frame_index = []
354 unique_frame_index.append(keyframe_idx)
355
356 for i in range(len(train_set)):
357 if i % 200 == 0:
358 print ('Image {:d} / {:d}'.format(i, len(train_set)))
359
360 if keyframe_idx == i:
361 continue
362
363 # compute frustum overlap
364 overlap_1p = compute_frustums_overlap(
365 train_set.poses[keyframe_idx].reshape(3,4), train_set.poses[i].reshape(3,4), FRUSTUM_APPROX, K_APPROX, W, H
366 )
367 if overlap_1p > threshold:
368 continue
369
370 # double check with existing unique views
371 save_flag = True
372 for j in unique_frame_index:
373 overlap_2p = compute_frustums_overlap(train_set.poses[j].reshape(3,4), train_set.poses[i].reshape(3,4), FRUSTUM_APPROX, K_APPROX, W, H)
374 if overlap_2p > threshold:
375 save_flag = False
376 break
377
378 if not save_flag:
379 print('image[{}] is overlapped with unique_frame_index {}'.format(i, j))
380 keyframe_idx = i
381 continue
382
383 unique_frame_index.append(i)
384 print(unique_frame_index)
385 keyframe_idx = i
386 unique_frame_index = np.array(unique_frame_index)
387 print('total train set selected', len(unique_frame_index))
388 save_unique_view_dir = osp.join(args.datadir, 'unique_view.txt')
389 np.savetxt(save_unique_view_dir, unique_frame_index, fmt="%d")
390 return unique_frame_index
391
392def select_nearest_neighbor_views(args, train_set, threshold, unique_frame_index):
393 ''' select nearest_neighbor views based on unique_frame_index '''

Callers

nothing calls this directly

Calls 2

compute_frustums_overlapFunction · 0.70

Tested by

no test coverage detected