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

Function select_nearest_neighbor_views

dataset_loaders/load_7Scenes.py:392–420  ·  view source on GitHub ↗

select nearest_neighbor views based on unique_frame_index

(args, train_set, threshold, unique_frame_index)

Source from the content-addressed store, hash-verified

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 '''
394 # Frustum near-far threshold
395 K_APPROX, FRUSTUM_APPROX, W, H = camera_frustum_initializer(args)
396
397 # compute how many unique views in the train set
398 keyframe_idx = 0
399 frame_index = []
400
401 for i in range(len(train_set)):
402 if i % 200 == 0:
403 print ('Image {:d} / {:d}'.format(i, len(train_set)))
404
405 if keyframe_idx == i:
406 continue
407
408 # compute frustum overlap
409 for j in unique_frame_index:
410 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)
411 if overlap_2p > threshold:
412 frame_index.append(i)
413 break
414 frame_index = np.array(frame_index)
415 frame_index = frame_index[::5]
416 print('train set selected', len(frame_index))
417 train_set.c_imgs = list(train_set.c_imgs[i] for i in frame_index)
418 train_set.d_imgs = list(train_set.d_imgs[i] for i in frame_index)
419 train_set.poses = train_set.poses[frame_index]
420 return
421
422def load_7Scenes_dataloader(args):
423 ''' Data loader for Pose Regression Network '''

Callers

nothing calls this directly

Calls 2

compute_frustums_overlapFunction · 0.70

Tested by

no test coverage detected