plot_points(ax, xs, '.b') def draw_bundle(bundle): mpl.rcParams['legend.fontsize'] = 10 pts = np.random.randn(10,3).astype(float) fig = plt.figure() ax = fig.gca(projection='3d') draw_point_cloud(ax, bundle.points()) for camera in bundle.cameras: draw_pose(ax, camera.R, camera.t) ax.set_xlim(-10, 10) ax.set_ylim(-10, 10) ax.set_zlim(-10, 10) plt.show() if __name__ == '__main__': import sys import bundle_io bundle = bundle_io.load(sys.argv[1], sys.argv[2]) for track in bundle.tracks: track.reprojection = bundle.triangulate(track) draw_bundle(bundle)
import sys import numpy as np from copy import deepcopy from algebra import * from bundle import Bundle, Camera, Track, project from bundle_adjuster import BundleAdjuster import draw_bundle import bundle_io if __name__ == '__main__': tracks_path = sys.argv[1] cameras_path = sys.argv[2] bundle = bundle_io.load(tracks_path, cameras_path) for track in bundle.tracks: track.reconstruction = bundle.triangulate(track) NUM_CAMERAS = 100 NUM_TRACKS = 100 bundle.cameras = bundle.cameras[:NUM_CAMERAS] bundle.tracks = bundle.tracks[:NUM_TRACKS] for j,track in enumerate(bundle.tracks): track.measurements = { i : track.get_measurement(i) for i in range(NUM_CAMERAS) } param_mask = np.ones(bundle.num_params(), bool) param_mask[:6] = False param_mask[9] = False
def draw_bundle(bundle, subspace=None, pose_colors=None): if subspace is None: subspace = eye(3)[:2] #mpl.rcParams['legend.fontsize'] = 10 plt.figure() pts = bundle.points() assert pts.shape[1] == 3 draw_point_cloud(pts, subspace) for i, camera in enumerate(bundle.cameras): color = pose_colors[i] if pose_colors is not None else 'r' draw_pose(camera.R, camera.t, subspace, color) def compute_subspace(bundle): return pca.compute(bundle.ts(), 2) if __name__ == '__main__': import sys import bundle_io bundle = bundle_io.load(sys.argv[1], sys.argv[2]) for track in bundle.tracks: track.reprojection = bundle.triangulate(track) draw_bundle(bundle)
import sys import numpy as np from copy import deepcopy from algebra import * from bundle import Bundle, Camera, Track, project from bundle_adjuster import BundleAdjuster import draw_bundle import bundle_io if __name__ == '__main__': tracks_path = sys.argv[1] cameras_path = sys.argv[2] bundle = bundle_io.load(tracks_path, cameras_path) for track in bundle.tracks: track.reconstruction = bundle.triangulate(track) NUM_CAMERAS = 100 NUM_TRACKS = 100 bundle.cameras = bundle.cameras[:NUM_CAMERAS] bundle.tracks = bundle.tracks[:NUM_TRACKS] for j, track in enumerate(bundle.tracks): track.measurements = { i: track.get_measurement(i) for i in range(NUM_CAMERAS) }