added screen axis for c3d so that import possible in blender

This commit is contained in:
davidpagnon 2024-04-23 22:46:10 +02:00
parent db8014c3f5
commit fb191d8a59
3 changed files with 9 additions and 2 deletions

View File

@ -115,6 +115,9 @@ def c3d_to_trc_func(*args):
c3d_line_markers = c3d_line[index_data_markers]
trc_line = '{i}\t{t}\t'.format(i=i, t=trc_time[n]) + '\t'.join(map(str,c3d_line_markers))
trc_o.write(trc_line+'\n')
print(f'Converted c3d file to {trc_path}')
if __name__ == '__main__':
parser = argparse.ArgumentParser()

View File

@ -34,7 +34,7 @@ __status__ = "Development"
## FUNCTIONS
def extract_marker_data(trc_path):
def extract_trc_data(trc_path):
'''
Extract marker names and coordinates from a trc file.
@ -78,6 +78,7 @@ def create_c3d_file(c3d_path, marker_names, trc_data_np):
# write c3d file
writer = c3d.Writer(point_rate=frame_rate, analog_rate=0, point_scale=1.0, point_units='mm', gen_scale=-1.0)
writer.set_point_labels(marker_names)
writer.set_screen_axis(X='+Z', Y='+Y')
for frame in trc_data_np:
residuals = np.full((len(marker_names), 1), 0.0)
@ -113,9 +114,11 @@ def trc_to_c3d_func(*args):
trc_path = args[0] # invoked as a function
c3d_path = trc_path.replace('.trc', '.c3d')
marker_names, trc_data_np = extract_marker_data(trc_path)
marker_names, trc_data_np = extract_trc_data(trc_path)
create_c3d_file(c3d_path, marker_names, trc_data_np)
print(f'Converted trc file to {c3d_path}')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Convert TRC files to C3D files.')

View File

@ -428,6 +428,7 @@ def create_c3d_file(c3d_path, marker_names, trc_data_np):
# write c3d file
writer = c3d.Writer(point_rate=frame_rate, analog_rate=0, point_scale=1.0, point_units='mm', gen_scale=-1.0)
writer.set_point_labels(marker_names)
writer.set_screen_axis(X='+Z', Y='+Y')
for frame in trc_data_np:
residuals = np.full((len(marker_names), 1), 0.0)