コード例 #1
0
    def run(self, args):
        start = time.time()
        data = dataset.DataSet(args.dataset)

        try:
            graph = data.load_tracks_graph()
            reconstructions = data.load_reconstruction()
        except IOError:
            print 'mesh.py: Failed to load reconstructions or tracks graph. May be missing...'
            return

        for i, r in enumerate(reconstructions):
            for shot in r.shots.values():
                if shot.id in graph:
                    vertices, faces = mesh.triangle_mesh(
                        shot.id, r, graph, data)
                    shot.mesh = types.ShotMesh()
                    shot.mesh.vertices = vertices
                    shot.mesh.faces = faces

        data.save_reconstruction(reconstructions,
                                 filename='reconstruction.meshed.json',
                                 minify=True)

        end = time.time()
        with open(data.profile_log(), 'a') as fout:
            fout.write('mesh: {0}\n'.format(end - start))
コード例 #2
0
ファイル: mesh.py プロジェクト: ziweiWWANG/OpenSfM
def run_dataset(data):
    """ Add delaunay meshes to the reconstruction. """

    tracks_manager = data.load_tracks_manager()
    reconstructions = data.load_reconstruction()

    all_shot_ids = set(tracks_manager.get_shot_ids())
    for r in reconstructions:
        for shot in r.shots.values():
            if shot.id in all_shot_ids:
                vertices, faces = mesh.triangle_mesh(shot.id, r, tracks_manager, data)
                shot.mesh.vertices = vertices
                shot.mesh.faces = faces

    data.save_reconstruction(
        reconstructions, filename="reconstruction.meshed.json", minify=True
    )
コード例 #3
0
def run(data):
    start = time.time()
    graph = data.track_graph_of_images
    reconstructions = data.reconstructions

    for i, r in enumerate(reconstructions):
        for shot in r.shots.values():
            if shot.id in graph:
                vertices, faces = mesh.triangle_mesh(shot.id, r, graph, data)
                shot.mesh = types.ShotMesh()
                shot.mesh.vertices = vertices
                shot.mesh.faces = faces

    data.save_reconstruction(reconstructions,
                             filename='reconstruction.meshed.json',
                             minify=True)

    end = time.time()
    with open(data.profile_log(), 'a') as fout:
        fout.write('mesh: {0}\n'.format(end - start))
コード例 #4
0
ファイル: mesh.py プロジェクト: zorrock/OpenSfM
    def run(self, args):
        start = time.time()
        data = dataset.DataSet(args.dataset)
        graph = data.load_tracks_graph()
        reconstructions = data.load_reconstruction()

        for i, r in enumerate(reconstructions):
            for shot in r.shots.values():
                if shot.id in graph:
                    vertices, faces = mesh.triangle_mesh(shot.id, r, graph,
                                                         data)
                    shot.mesh = types.ShotMesh()
                    shot.mesh.vertices = vertices
                    shot.mesh.faces = faces

        data.save_reconstruction(reconstructions,
                                 filename='reconstruction.meshed.json')

        end = time.time()
        with open(data.profile_log(), 'a') as fout:
            fout.write('mesh: {0}\n'.format(end - start))
コード例 #5
0
    def run(self, args):
        start = time.time()
        data = dataset.DataSet(args.dataset)
        tracks_manager = data.load_tracks_manager()
        reconstructions = data.load_reconstruction()

        all_shot_ids = set(tracks_manager.get_shot_ids())
        for r in reconstructions:
            for shot in r.shots.values():
                if shot.id in all_shot_ids:
                    vertices, faces = mesh.triangle_mesh(
                        shot.id, r, tracks_manager, data)
                    shot.mesh.vertices = vertices
                    shot.mesh.faces = faces

        data.save_reconstruction(reconstructions,
                                 filename='reconstruction.meshed.json',
                                 minify=True)

        end = time.time()
        with open(data.profile_log(), 'a') as fout:
            fout.write('mesh: {0}\n'.format(end - start))
コード例 #6
0
    data.config['label'] = label

    try:
        # with open(seg_path + '/OpenSfM/' + 'reconstruction{:02d}.json'.format(label)) as f:
        reconstructions = data.load_reconstruction()
    except:
        reconstruction.incremental_reconstruction(data,
                                                  graph=graphs[label],
                                                  my_init=my_init)
        reconstructions = data.load_reconstruction()

    if (save_mesh):
        for i, r in enumerate(reconstructions):
            for shot in r.shots.values():
                if shot.id in graphs[label]:
                    vertices, faces = mesh.triangle_mesh(
                        shot.id, r, graphs[label], data)
                    shot.mesh = types.ShotMesh()
                    shot.mesh.vertices = vertices
                    shot.mesh.faces = faces
        data.save_reconstruction(reconstructions,
                                 filename='reconstruction.meshed.json')

    scene_reconstructions[label] = reconstructions

    if (len(reconstructions) == 1):
        """there is only one reconstruction for this, probably good"""
        reconstruct = reconstructions[0]
    else:
        print "have trouble with reconstruction of label {:d}".format(label)

# ## merge reconstructions together