Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

kinda working maybe?

Jon PC Win Hallway8dd60e1d2a81
diff --git a/freemocap/dev_scratchpad/batch_process.py b/freemocap/dev_scratchpad/batch_process.py
index f00e4219..a4e7c3d1 100644
--- a/freemocap/dev_scratchpad/batch_process.py
+++ b/freemocap/dev_scratchpad/batch_process.py
@@ -4,6 +4,7 @@ import freemocap as fmc
import datetime
import logging
from rich import inspect
+from rich import print
from rich.console import Console
console = Console()
import shutil
@@ -36,28 +37,52 @@ logging.basicConfig(filename=str(path_to_log_file), filemode='w', format='%(asct
logging.info('Log file create :D')
#%%
-dataframe_init_dict = {
- 'viable_folder_paths':[],
- 'outVid_exists_bool':[]}
-viable_folders_dataframe = pd.DataFrame(dataframe_init_dict)
out_vid_path = freemocap_data_path / 'output_animation_videos'
out_vid_path.mkdir(exist_ok=True)
-with console.status('Looking for viable folders (that contain synced vids)'):
- for this_folder in freemocap_data_path.glob('**/*'):
- if this_folder.is_dir():
- #check if there is a synced video folder in here
- for this_sub_folder in this_folder.iterdir():
- if this_sub_folder.is_dir():
- if this_sub_folder.name.lower()[0:4]=='sync':
- logging.info('Viable Folder found at {}'.format(str(this_folder)))
- out_vid_exists = False
- for this_mp4 in this_folder.glob('*.mp4'):
- out_vid_exists = True
- shutil.copy(this_mp4, str(out_vid_path))
- logging.info('OutVid - {} - Copied to - {}'.format(str(this_mp4), str(out_vid_path)))
- viable_folders_dataframe.loc[len(viable_folders_dataframe.index)] = [str(this_folder), out_vid_exists]
+csv_path = out_vid_path / 'viable_folders_status.csv'
+
+detect_folders_to_process_bool = False
+if detect_folders_to_process_bool:
+ dataframe_init_dict = {'viable_folder_paths':[],
+ 'outVid_exists_bool':[]}
+ viable_folders_dataframe = pd.DataFrame(dataframe_init_dict)
+
+ with console.status('Looking for viable folders (that contain synced vids)'):
+ for this_folder in freemocap_data_path.glob('**/*'):
+ if this_folder.is_dir():
+ #check if there is a synced video folder in here
+ for this_sub_folder in this_folder.iterdir():
+ if this_sub_folder.is_dir():
+ if this_sub_folder.name.lower()[0:4]=='sync':
+ logging.info('Viable Folder found at {}'.format(str(this_folder)))
+ out_vid_exists = False
+ for this_mp4 in this_folder.glob('*.mp4'):
+ out_vid_exists = True
+ # shutil.copy(this_mp4, str(out_vid_path))
+ # logging.info('OutVid - {} - Copied to - {}'.format(str(this_mp4), str(out_vid_path)))
+ viable_folders_dataframe.loc[len(viable_folders_dataframe.index)] = [str(this_folder), out_vid_exists]
+ viable_folders_dataframe.to_csv(csv_path, index=False)
+ logging.info('List of all viable session folders saved to {}'.format(str(csv_path)))
+else:
+ viable_folders_dataframe = pd.read_csv(csv_path)
+ logging.info('Loaded csv with list viable session folders from {}'.format(str(csv_path)))
+
# %%
-viable_folders_dataframe
\ No newline at end of file
+
+
+# %%
+folders_to_process = viable_folders_dataframe[viable_folders_dataframe["outVid_exists_bool"]==False]
+for this_item in folders_to_process['viable_folder_paths']:
+ this_session_id = Path(this_item).name
+ print('Starting to process SessionID: {}'.format(this_session_id))
+ logging.info('Starting to process SessionID: {}'.format(this_session_id))
+ try:
+ fmc.RunMe(sessionID = this_session_id, stage=3, useBlender=True, showAnimation=False)
+ logging.info('SessionID: {} processed successfully!'.format(this_session_id))
+ except Exception:
+ console.print_exception(Exception)
+ logging.info('SessionID: {} failed to process'.format(this_session_id))
+