Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lichengunc/d8ea27cd79280788a683f9812c48b0db to your computer and use it in GitHub Desktop.
Save lichengunc/d8ea27cd79280788a683f9812c48b0db to your computer and use it in GitHub Desktop.
get_best_view_points
def get_best_view_points(h3d, obj_id, args):
# obj info
obj = h3d.objects[obj_id]
h3d.set_target_object(obj)
obj_conn_map = h3d.env.house.connMapDict[obj_id][0]
obj_point_cands = np.argwhere( (obj_conn_map > args.min_conn_dist) & (obj_conn_map <= args.max_conn_dist) )
# don't search too many for saving time
if obj_point_cands.shape[0] > args.num_samples:
perm = np.random.permutation(obj_point_cands.shape[0])[:args.num_samples]
obj_point_cands = obj_point_cands[perm]
# traverse
points, ious, yaws = [], [], []
for obj_point in obj_point_cands:
obj_view, obj_iou, obj_mask = h3d._get_best_yaw_obj_from_pos(obj_id, obj_point, height=1., use_iou=True)
x, z = h3d.env.house.to_coor(obj_point[0], obj_point[1])
points.append([x, 1., z, obj_view])
ious.append(obj_iou)
# sort
points, ious = np.array(points), np.array(ious)
ixs = (-ious).argsort() # descending order
ious = ious[ixs]
points = points[ixs]
# return
return points.tolist(), ious.tolist()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment