Fixed CSV export, added pc-csv flag

Former-commit-id: a80de54e92
pull/1161/head
Piero Toffanin 2018-06-03 21:01:04 -04:00
rodzic cdda8832cc
commit 06fef36605
3 zmienionych plików z 24 dodań i 18 usunięć

Wyświetl plik

@ -334,6 +334,11 @@ def config():
'Default: ' 'Default: '
'%(default)s') '%(default)s')
parser.add_argument('--pc-csv',
action='store_true',
default=False,
help='Export the georeferenced point cloud in CSV format. Default: %(default)s')
parser.add_argument('--texturing-data-term', parser.add_argument('--texturing-data-term',
metavar='<string>', metavar='<string>',
default='gmi', default='gmi',

Wyświetl plik

@ -1,6 +1,7 @@
import ecto import ecto
import csv import csv
import os import os
import struct
from opendm import io from opendm import io
from opendm import log from opendm import log
@ -143,21 +144,28 @@ class ODMGeoreferencingCell(ecto.Cell):
reconstruction.georef = geo_ref reconstruction.georef = geo_ref
# XYZ point cloud output # XYZ point cloud output
log.ODM_INFO("Creating geo-referenced CSV file (XYZ format)") if args.pc_csv:
with open(tree.odm_georeferencing_xyz_file, "wb") as csvfile: log.ODM_INFO("Creating geo-referenced CSV file (XYZ format)")
csvfile_writer = csv.writer(csvfile, delimiter=",") with open(tree.odm_georeferencing_xyz_file, "wb") as csvfile:
reachedpoints = False csvfile_writer = csv.writer(csvfile, delimiter=",")
with open(odm_georeferencing_model_ply_geo) as f: with open(odm_georeferencing_model_ply_geo) as f:
for lineNumber, line in enumerate(f): endianess = '<' # little endian
if reachedpoints: while True:
tokens = line.split(" ") line = f.readline()
if "binary_big_endian" in line:
endianess = '>'
if line.startswith("end_header"):
break
while True:
chunk = f.read(27) # 3 doubles, 3 uints
if len(chunk) < 27:
break
tokens = struct.unpack('<dddBBB', chunk)
csv_line = [float(tokens[0]), csv_line = [float(tokens[0]),
float(tokens[1]), float(tokens[1]),
tokens[2]] tokens[2]]
csvfile_writer.writerow(csv_line) csvfile_writer.writerow(csv_line)
if line.startswith("end_header"):
reachedpoints = True
csvfile.close()
if args.crop > 0: if args.crop > 0:
log.ODM_INFO("Calculating cropping area and generating bounds shapefile from point cloud") log.ODM_INFO("Calculating cropping area and generating bounds shapefile from point cloud")

Wyświetl plik

@ -136,13 +136,6 @@ class ODMOpenSfMCell(ecto.Cell):
log.ODM_WARNING('Found a valid OpenSfM reconstruction file in: %s' % log.ODM_WARNING('Found a valid OpenSfM reconstruction file in: %s' %
tree.opensfm_reconstruction) tree.opensfm_reconstruction)
if not io.file_exists(tree.opensfm_reconstruction_meshed) or rerun_cell:
system.run('PYTHONPATH=%s %s/bin/opensfm mesh %s' %
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
else:
log.ODM_WARNING('Found a valid OpenSfM meshed reconstruction file in: %s' %
tree.opensfm_reconstruction_meshed)
if not args.use_pmvs: if not args.use_pmvs:
if not io.file_exists(tree.opensfm_reconstruction_nvm) or rerun_cell: if not io.file_exists(tree.opensfm_reconstruction_nvm) or rerun_cell:
system.run('PYTHONPATH=%s %s/bin/opensfm export_visualsfm %s' % system.run('PYTHONPATH=%s %s/bin/opensfm export_visualsfm %s' %