write associated measurements to file

This commit is contained in:
Christian Forster
2014-04-16 12:13:25 +02:00
parent 814336e5ff
commit 5fc8ef36a3
@@ -108,7 +108,6 @@ if __name__ == '__main__':
''')
parser.add_argument('first_file', help='first text file (format: timestamp data)')
parser.add_argument('second_file', help='second text file (format: timestamp data)')
parser.add_argument('--first_only', help='only output associated lines from first file', action='store_true')
parser.add_argument('--offset', help='time offset added to the timestamps of the second file (default: 0.0)',default=0.0)
parser.add_argument('--max_difference', help='maximally allowed time difference for matching entries (default: 0.02)',default=0.02)
args = parser.parse_args()
@@ -118,11 +117,14 @@ if __name__ == '__main__':
matches = associate(first_list, second_list,float(args.offset),float(args.max_difference))
if args.first_only:
filename = 'groundtruth_matched.txt'
associates_file = open(filename, 'w')
for a,b in matches:
print("%f %s"%(a," ".join(first_list[a])))
else:
for a,b in matches:
print("%f %s %f %s"%(a," ".join(first_list[a]),b-float(args.offset)," ".join(second_list[b])))
img = first_list[a]
pos = second_list[b]
associates_file.write('%.6f %s %s %s %s %s %s %s %s\n' %
(a, img[0],
pos[0], pos[1], pos[2],
pos[3], pos[4], pos[5], pos[6]))
print('Wrote matches to file: ' + filename)