|
from pathlib import Path |
|
import multiprocessing |
|
|
|
|
|
import fbx_handler |
|
import utils |
|
|
|
c = 'dowg' |
|
source = Path(f'G:/Firestorm/mocap-ai/data/fbx/{c}/') |
|
train_folder = Path(f'G:/Firestorm/mocap-ai/data/h5/{c}/train') |
|
test_folder = Path(f'G:/Firestorm/mocap-ai/data/h5/{c}/test') |
|
|
|
|
|
def process_fbx_file(fbx_file: Path): |
|
|
|
export_train_path = train_folder / fbx_file.with_suffix('.h5').name |
|
export_test_path = test_folder / fbx_file.with_suffix('.h5').name |
|
|
|
|
|
if export_train_path.exists() and export_test_path.exists(): |
|
print(f'{fbx_file} done already.') |
|
return |
|
else: |
|
print(fbx_file) |
|
|
|
|
|
my_obj = fbx_handler.FBXContainer(fbx_file, debug=0) |
|
|
|
with utils.Timer('Getting world transforms took'): |
|
try: |
|
my_obj.init_world_transforms() |
|
except BaseException as e: |
|
print(e) |
|
return |
|
|
|
try: |
|
|
|
|
|
train_data = my_obj.export_train_data(export_train_path) |
|
print(f'Train shape: {train_data.shape}') |
|
except BaseException as e: |
|
print(e) |
|
return |
|
|
|
try: |
|
|
|
test_data = my_obj.export_inf_data(export_test_path, merged=False) |
|
print(f'Test labeled shape: {test_data[0].shape}') |
|
print(f'Test unlabeled shape: {test_data[1].shape}') |
|
print(f'Minimum cloud size: {test_data[0].shape[2] + test_data[1].shape[2]}') |
|
except BaseException as e: |
|
print(e) |
|
return |
|
|
|
|
|
def process_fbx_files(source_folder: Path): |
|
|
|
|
|
train_folder.mkdir(parents=True, exist_ok=True) |
|
test_folder.mkdir(parents=True, exist_ok=True) |
|
|
|
files = list(source_folder.glob('*.fbx')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
with multiprocessing.Pool(1) as pool: |
|
pool.map(process_fbx_file, files) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
with utils.Timer('Full execution took'): |
|
process_fbx_files(source) |
|
|