-
Notifications
You must be signed in to change notification settings - Fork 891
Expand file tree
/
Copy pathmesh.py
More file actions
41 lines (31 loc) · 1.29 KB
/
mesh.py
File metadata and controls
41 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import logging
import time
from opensfm import dataset
from opensfm import mesh
from opensfm import types
logger = logging.getLogger(__name__)
class Command:
name = 'mesh'
help = "Add delaunay meshes to the reconstruction"
def add_arguments(self, parser):
parser.add_argument('dataset', help='dataset to process')
def run(self, args):
start = time.time()
data = dataset.DataSet(args.dataset)
graph = data.load_tracks_graph()
reconstructions = data.load_reconstruction()
logger.debug("Starting calculation of reconstruction mesh")
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))