Skip to content

Commit

Permalink
init visualisation behind first keyframe
Browse files Browse the repository at this point in the history
  • Loading branch information
gaussianBP committed Mar 9, 2020
1 parent 61d8c72 commit 8c5bf7e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion vis/ba_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
from utils import transformations


def to_opengl_transform(transform=None):
if transform is None:
transform = np.eye(4)
return transform @ trimesh.transformations.rotation_matrix(
np.deg2rad(-180), [1, 0, 0]
)


class TrimeshSceneViewer(trimesh.viewer.SceneViewer):

def __init__(self, scene, resolution=None):
Expand Down Expand Up @@ -123,11 +131,16 @@ def create_scene(graph, fov=(640, 480)):
# geom[1].colors = [(0., 0., 1.)] * 16
scene.add_geometry(geom[1], transform=Twc, node_name=cam_name)

if i == 0:
# Set initial viewpoint behind this keyframe
cam_pose = Twc.copy()
cam_pose[:3, 3] -= 2.0 * cam_pose[:3, 2] / np.linalg.norm(cam_pose[:3, 2])
scene.camera.transform = to_opengl_transform(transform=cam_pose)

landmarks_pcd = trimesh.PointCloud(landmarks)
landmarks_pcd.colors = [[0., 0., 0.9]] * len(landmarks)
scene.add_geometry(landmarks_pcd, node_name='landmarks_pcd')

scene.set_camera()
scene.camera.resolution = [1200, 900]
scene.camera.fov = 60 * (scene.camera.resolution / scene.camera.resolution.max())

Expand Down

0 comments on commit 8c5bf7e

Please sign in to comment.