Free Motion Capture for Everyone πβ¨
TypeScript
Lint everything with Black (#453)
philipqueen75e94c751a8b
diff --git a/freemocap/__init__.py b/freemocap/__init__.pyindex f12f01d0..bfdf1606 100644--- a/freemocap/__init__.py+++ b/freemocap/__init__.py@@ -10,16 +10,17 @@ __repo_url__ = f"https://github.com/freemocap/{__package_name__}/"__repo_issues_url__ = f"{__repo_url__}issues"-# if we're running from source, we need to add the parent directory to sys.pathimport sysfrom pathlib import Path+## base_package_path = Path(__file__).parent.parent# print(f"adding base_package_path: {base_package_path} : to sys.path")# sys.path.insert(0, str(base_package_path)) # add parfrom freemocap.system.logging.configure_logging import configure_logging+configure_logging()import logging@@ -30,19 +31,23 @@ logger.info(f"Initializing {__package_name__} package, version: {__version__}, f# breadcrumbs for legacy/deprecated 'pre-alpha` entry pointdef RunMe(*args, **kwargs):logger.info(- "User tried using `pre-alpha` entry point (`import freemocap: freemocap.RunMe() - displaying friendly message then re-directing to `freemocap.__main__:main()` entry point")-- print("--------------------------------\n"- "--------------------------------\n"- "--------------------------------\n"- "Hello! Looks like you're trying to use the `pre-alpha` entry point for FreeMoCap.\n"- "This entry point is deprecated, so we're launching the GUI via `freemocap.__main__:main()` entry point.\n"- "if you need to install the `pre-alpha` code, use `pip install freemocap==0.0.54`"- "Thank you for using FreeMoCap!\n"- "--------------------------------\n"- "--------------------------------\n"- "(NOTE - this entry point will be removed eventually\n"- "--------------------------------\n")+ "User tried using `pre-alpha` entry point (`import freemocap: freemocap.RunMe() - displaying friendly message then re-directing to `freemocap.__main__:main()` entry point"+ )++ print(+ "--------------------------------\n"+ "--------------------------------\n"+ "--------------------------------\n"+ "Hello! Looks like you're trying to use the `pre-alpha` entry point for FreeMoCap.\n"+ "This entry point is deprecated, so we're launching the GUI via `freemocap.__main__:main()` entry point.\n"+ "if you need to install the `pre-alpha` code, use `pip install freemocap==0.0.54`"+ "Thank you for using FreeMoCap!\n"+ "--------------------------------\n"+ "--------------------------------\n"+ "(NOTE - this entry point will be removed eventually\n"+ "--------------------------------\n"+ )from freemocap.__main__ import main+main()diff --git a/freemocap/__main__.py b/freemocap/__main__.pyindex f3d5250d..22a83b33 100644--- a/freemocap/__main__.py+++ b/freemocap/__main__.py@@ -14,7 +14,6 @@ except Exception as e:def main():-# set up so you can change the taskbar icon - https://stackoverflow.com/a/74531530/14662833import ctypesimport freemocapdiff --git a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.py b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.pyindex 10072161..a7343552 100644--- a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.py+++ b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.py@@ -11,8 +11,11 @@ from freemocap.core_processes.capture_volume_calibration.anipose_camera_calibratfrom freemocap.core_processes.capture_volume_calibration.charuco_stuff.charuco_board_definition import (CharucoBoardDefinition,)-from freemocap.system.paths_and_filenames.path_getters import create_camera_calibration_file_name, \- get_calibrations_folder_path, get_last_successful_calibration_toml_path+from freemocap.system.paths_and_filenames.path_getters import (+ create_camera_calibration_file_name,+ get_calibrations_folder_path,+ get_last_successful_calibration_toml_path,+)from freemocap.utilities.get_video_paths import get_video_pathslogger = logging.getLogger(__name__)@@ -26,7 +29,6 @@ class AniposeCameraCalibrator:calibration_videos_folder_path: Union[str, Path],progress_callback: Callable[[str], None] = None,):-self._charuco_board_object = charuco_board_objectself._progress_callback = progress_callback@@ -67,10 +69,13 @@ class AniposeCameraCalibrator:)def calibrate_camera_capture_volume(self, pin_camera_0_to_origin: bool = False):-video_paths_list_of_list_of_strings = [[str(this_path)] for this_path in self._list_of_video_paths]- (error, charuco_frame_data, charuco_frame_numbers,) = self._anipose_camera_group_object.calibrate_videos(+ (+ error,+ charuco_frame_data,+ charuco_frame_numbers,+ ) = self._anipose_camera_group_object.calibrate_videos(video_paths_list_of_list_of_strings, self._anipose_charuco_board)success_str = "Anipose Calibration Successful!"@@ -82,12 +87,16 @@ class AniposeCameraCalibrator:# self._anipose_camera_group_object = self.rotate_cameras_so_camera_zero_aligns_with_XYZ(self._anipose_camera_group_object)# save calibration info to files- calibration_toml_filename = create_camera_calibration_file_name(recording_name = self._calibration_videos_folder_path.parent.stem)+ calibration_toml_filename = create_camera_calibration_file_name(+ recording_name=self._calibration_videos_folder_path.parent.stem+ )calibration_folder_toml_path = Path(get_calibrations_folder_path()) / calibration_toml_filenameself._anipose_camera_group_object.dump(calibration_folder_toml_path)- logger.info(f"anipose camera calibration data saved to Calibrations folder - {str(calibration_folder_toml_path)}")+ logger.info(+ f"anipose camera calibration data saved to Calibrations folder - {str(calibration_folder_toml_path)}"+ )recording_folder_toml_path = Path(self._recording_folder_path) / calibration_toml_filename@@ -97,8 +106,9 @@ class AniposeCameraCalibrator:last_successful_calibration_toml_path = get_last_successful_calibration_toml_path()self._anipose_camera_group_object.dump(last_successful_calibration_toml_path)- logger.info(f"anipose camera calibration data also saved to 'Last Successful Calibration' - {last_successful_calibration_toml_path}")-+ logger.info(+ f"anipose camera calibration data also saved to 'Last Successful Calibration' - {last_successful_calibration_toml_path}"+ )def pin_camera_zero_to_origin(self, _anipose_camera_group_object):original_translation_vectors = _anipose_camera_group_object.get_translations()diff --git a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.py b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.pyindex a8897794..562cbc31 100644--- a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.py+++ b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.py@@ -200,7 +200,6 @@ class Camera:name=None,extra_dist=False,):-self.set_camera_matrix(matrix)self.set_distortions(dist)self.set_size(size)@@ -499,7 +498,7 @@ class CameraGroup:return out- def triangulate(self, points, undistort=True, progress=False, kill_event:multiprocessing.Event=None):+ def triangulate(self, points, undistort=True, progress=False, kill_event: multiprocessing.Event = None):"""Given an CxNx2 array, this returns an Nx3 array of points,where N is the number of points and C is the number of cameras"""@@ -548,7 +547,15 @@ class CameraGroup:return out- def triangulate_possible(self, points, undistort=True, min_cams=2, progress=False, threshold=0.5, kill_event:multiprocessing.Event=None):+ def triangulate_possible(+ self,+ points,+ undistort=True,+ min_cams=2,+ progress=False,+ threshold=0.5,+ kill_event: multiprocessing.Event = None,+ ):"""Given an CxNxPx2 array, this returns an Nx3 array of pointsby triangulating all possible points and picking the ones withbest reprojection error@@ -636,7 +643,9 @@ class CameraGroup:# return out, picked_vals, points_2d, errors #original code from OG aniposereturn out # simplify output so that `triangulate_ransac` can be used exactly the same way as `triangulate`- def triangulate_ransac(self, points, undistort=True, min_cams=2, progress=False, kill_event:multiprocessing.Event=None):+ def triangulate_ransac(+ self, points, undistort=True, min_cams=2, progress=False, kill_event: multiprocessing.Event = None+ ):"""Given an CxNx2 array, this returns an Nx3 array of points,where N is the number of points and C is the number of cameras"""@@ -650,7 +659,9 @@ class CameraGroup:points_ransac = points.reshape(n_cams, n_points, 1, 2)- return self.triangulate_possible(points_ransac, undistort=undistort, min_cams=min_cams, progress=progress, kill_event=kill_event)+ return self.triangulate_possible(+ points_ransac, undistort=undistort, min_cams=min_cams, progress=progress, kill_event=kill_event+ )@jit(parallel=True, forceobj=True)def reprojection_error(self, p3ds, p2ds, mean=False):diff --git a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/get_anipose_calibration_object.py b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/get_anipose_calibration_object.pyindex 4f08f2d5..b2a8074e 100644--- a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/get_anipose_calibration_object.py+++ b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/get_anipose_calibration_object.py@@ -27,18 +27,18 @@ def load_most_recent_anipose_calibration_toml(save_copy_of_calibration_to_this_pdef load_anipose_calibration_toml_from_path(- camera_calibration_data_toml_path: Union[str, Path],- save_copy_of_calibration_to_this_path: Union[str, Path],+ camera_calibration_data_toml_path: Union[str, Path],+ save_copy_of_calibration_to_this_path: Union[str, Path],):logger.info(f"loading camera calibration file from:{str(camera_calibration_data_toml_path)}")try:anipose_calibration_object = freemocap_anipose.CameraGroup.load(str(camera_calibration_data_toml_path))copy_toml_path = str(Path(save_copy_of_calibration_to_this_path) / Path(camera_calibration_data_toml_path).name)- if Path(copy_toml_path).is_file() and\- not filecmp.cmp(str(camera_calibration_data_toml_path), copy_toml_path):+ if Path(copy_toml_path).is_file() and not filecmp.cmp(str(camera_calibration_data_toml_path), copy_toml_path):logger.info(- f"Saving copy of {camera_calibration_data_toml_path} to {save_copy_of_calibration_to_this_path}")+ f"Saving copy of {camera_calibration_data_toml_path} to {save_copy_of_calibration_to_this_path}"+ )shutil.copyfile(str(camera_calibration_data_toml_path), copy_toml_path)return anipose_calibration_object@@ -48,11 +48,10 @@ def load_anipose_calibration_toml_from_path(def load_calibration_from_session_id(- session_calibration_file_path: Union[str, Path],+ session_calibration_file_path: Union[str, Path],):logger.info(f"loading camera calibration file from:{str(session_calibration_file_path)}")try:-return freemocap_anipose.CameraGroup.load(str(session_calibration_file_path))except Exception as e:logger.error(f"Failed to load anipose calibration info from {str(session_calibration_file_path)}")diff --git a/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.py b/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.pyindex 2db5c8fb..ba10fb49 100644--- a/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.py+++ b/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.py@@ -38,6 +38,4 @@ class CharucoBoardDefinition:dictionary=self.aruco_marker_dict,)- self.number_of_charuco_corners = (self.number_of_squares_width - 1) * (- self.number_of_squares_height - 1- )+ self.number_of_charuco_corners = (self.number_of_squares_width - 1) * (self.number_of_squares_height - 1)diff --git a/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.py b/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.pyindex 9eac95a1..860ceb8a 100644--- a/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.py+++ b/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.py@@ -32,7 +32,6 @@ def remove_3d_data_with_high_reprojection_error(data3d_numFrames_numTrackedPoints_XYZ: np.ndarray,data3d_numFrames_numTrackedPoints_reprojectionError: np.ndarray,):-return data3d_numFrames_numTrackedPoints_XYZ# TODO - Fix this function (it was causing overfiltering when combined with the anipose calibration confidence thresholding)@@ -83,9 +82,8 @@ def triangulate_3d_data(output_data_folder_path: Union[str, Path],mediapipe_confidence_cutoff_threshold: float,use_triangulate_ransac: bool = False,- kill_event : multiprocessing.Event = None,+ kill_event: multiprocessing.Event = None,):-number_of_cameras = mediapipe_2d_data.shape[0]number_of_frames = mediapipe_2d_data.shape[1]number_of_tracked_points = mediapipe_2d_data.shape[2]diff --git a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/convert_mediapipe_npy_to_csv.py b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/convert_mediapipe_npy_to_csv.pyindex 7343e612..ee7dcf76 100644--- a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/convert_mediapipe_npy_to_csv.py+++ b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/convert_mediapipe_npy_to_csv.py@@ -7,8 +7,11 @@ import numpy as npimport pandas as pdfrom mediapipe.python.solutions import holistic as mp_holistic-from freemocap.system.paths_and_filenames.file_and_folder_names import MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME, \- MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME, MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME+from freemocap.system.paths_and_filenames.file_and_folder_names import (+ MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME,+ MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME,+ MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME,+)logger = logging.getLogger(__name__)@@ -22,12 +25,8 @@ def convert_mediapipe_npy_to_csv()# %%- mediapipe_pose_landmark_names = [- landmark.name.lower() for landmark in mp_holistic.PoseLandmark- ]- mediapipe_hand_landmark_names = [- landmark.name.lower() for landmark in mp_holistic.HandLandmark- ]+ mediapipe_pose_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark]+ mediapipe_hand_landmark_names = [landmark.name.lower() for landmark in mp_holistic.HandLandmark]# face_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark] #gonna have the clever for the face# logger.info(f"Body tracked point names: {mediapipe_pose_landmark_names}")# logger.info(mediapipe_hand_landmark_names)@@ -45,9 +44,7 @@ def convert_mediapipe_npy_to_csv(last_right_hand_marker_index = number_of_body_points + number_of_hand_points - 1first_left_hand_marker_index = last_right_hand_marker_index + 1- last_left_hand_marker_index = (- last_right_hand_marker_index + 1 + number_of_hand_points - 1- )+ last_left_hand_marker_index = last_right_hand_marker_index + 1 + number_of_hand_points - 1first_face_marker_index = last_left_hand_marker_index + 1last_face_marker_index = mediapipe_3d_frame_trackedPoint_xyz.shape[1]@@ -81,18 +78,14 @@ def convert_mediapipe_npy_to_csv(# )# %%- body_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[- :, first_body_marker_index : last_body_marker_index + 1, :- ]+ body_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_body_marker_index : last_body_marker_index + 1, :]right_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_right_hand_marker_index : last_right_hand_marker_index + 1, :]left_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_left_hand_marker_index : last_left_hand_marker_index + 1, :]- face_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[- :, first_face_marker_index : last_face_marker_index + 1, :- ]+ face_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_face_marker_index : last_face_marker_index + 1, :]# logger.info(f"body 3d xyz shape: {body_3d_xyz.shape}")# logger.info(f"right hand 3d xyz shape: {right_hand_3d_xyz.shape}")@@ -101,9 +94,7 @@ def convert_mediapipe_npy_to_csv(# %%# save broken up npy files- np.save(- str(Path(output_data_folder_path) / "mediapipe_body_3d_xyz.npy"), body_3d_xyz- )+ np.save(str(Path(output_data_folder_path) / "mediapipe_body_3d_xyz.npy"), body_3d_xyz)np.save(str(Path(output_data_folder_path) / "mediapipe_right_hand_3d_xyz.npy"),right_hand_3d_xyz,@@ -112,9 +103,7 @@ def convert_mediapipe_npy_to_csv(str(Path(output_data_folder_path) / "mediapipe_left_hand_3d_xyz.npy"),left_hand_3d_xyz,)- np.save(- str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.npy"), face_3d_xyz- )+ np.save(str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.npy"), face_3d_xyz)# %%# create pandas data frame headers@@ -161,24 +150,16 @@ def convert_mediapipe_npy_to_csv(body_flat = body_3d_xyz.reshape(number_of_frames, number_of_body_points * 3)body_dataframe = pd.DataFrame(body_flat, columns=body_3d_xyz_header)- body_dataframe.to_csv(- str(Path(output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME), index=False- )+ body_dataframe.to_csv(str(Path(output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME), index=False)- right_hand_flat = right_hand_3d_xyz.reshape(- number_of_frames, number_of_hand_points * 3- )- right_hand_dataframe = pd.DataFrame(- right_hand_flat, columns=right_hand_3d_xyz_header- )+ right_hand_flat = right_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points * 3)+ right_hand_dataframe = pd.DataFrame(right_hand_flat, columns=right_hand_3d_xyz_header)right_hand_dataframe.to_csv(str(Path(output_data_folder_path) / MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME),index=False,)- left_hand_flat = left_hand_3d_xyz.reshape(- number_of_frames, number_of_hand_points * 3- )+ left_hand_flat = left_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points * 3)left_hand_dataframe = pd.DataFrame(left_hand_flat, columns=left_hand_3d_xyz_header)left_hand_dataframe.to_csv(str(Path(output_data_folder_path) / MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME),@@ -187,19 +168,13 @@ def convert_mediapipe_npy_to_csv(face_flat = face_3d_xyz.reshape(number_of_frames, number_of_face_points * 3)face_dataframe = pd.DataFrame(face_flat, columns=face_3d_xyz_header)- face_dataframe.to_csv(- str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.csv"), index=False- )+ face_dataframe.to_csv(str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.csv"), index=False)# %%# %%- mediapipe_pose_landmark_names = [- landmark.name.lower() for landmark in mp_holistic.PoseLandmark- ]- mediapipe_hand_landmark_names = [- landmark.name.lower() for landmark in mp_holistic.HandLandmark- ]+ mediapipe_pose_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark]+ mediapipe_hand_landmark_names = [landmark.name.lower() for landmark in mp_holistic.HandLandmark]# face_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark] #gonna have the clever for the face# logger.debug(f"Body tracked point names: {mediapipe_pose_landmark_names}")@@ -218,9 +193,7 @@ def convert_mediapipe_npy_to_csv(last_right_hand_marker_index = number_of_body_points + number_of_hand_points - 1first_left_hand_marker_index = last_right_hand_marker_index + 1- last_left_hand_marker_index = (- last_right_hand_marker_index + 1 + number_of_hand_points - 1- )+ last_left_hand_marker_index = last_right_hand_marker_index + 1 + number_of_hand_points - 1first_face_marker_index = last_left_hand_marker_index + 1last_face_marker_index = mediapipe_3d_frame_trackedPoint_xyz.shape[1]@@ -254,18 +227,14 @@ def convert_mediapipe_npy_to_csv(# )# %%- body_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[- :, first_body_marker_index : last_body_marker_index + 1, :- ]+ body_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_body_marker_index : last_body_marker_index + 1, :]right_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_right_hand_marker_index : last_right_hand_marker_index + 1, :]left_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_left_hand_marker_index : last_left_hand_marker_index + 1, :]- face_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[- :, first_face_marker_index : last_face_marker_index + 1, :- ]+ face_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:, first_face_marker_index : last_face_marker_index + 1, :]logger.debug(f"body 3d xyz shape: {body_3d_xyz.shape}")logger.debug(f"right hand 3d xyz shape: {right_hand_3d_xyz.shape}")@@ -274,9 +243,7 @@ def convert_mediapipe_npy_to_csv(# %%# save broken up npy files- np.save(- str(Path(output_data_folder_path) / "mediapipe_body_3d_xyz.npy"), body_3d_xyz- )+ np.save(str(Path(output_data_folder_path) / "mediapipe_body_3d_xyz.npy"), body_3d_xyz)np.save(str(Path(output_data_folder_path) / "mediapipe_right_hand_3d_xyz.npy"),right_hand_3d_xyz,@@ -285,9 +252,7 @@ def convert_mediapipe_npy_to_csv(str(Path(output_data_folder_path) / "mediapipe_left_hand_3d_xyz.npy"),left_hand_3d_xyz,)- np.save(- str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.npy"), face_3d_xyz- )+ np.save(str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.npy"), face_3d_xyz)# %%# create pandas data frame headers@@ -334,24 +299,16 @@ def convert_mediapipe_npy_to_csv(body_flat = body_3d_xyz.reshape(number_of_frames, number_of_body_points * 3)body_dataframe = pd.DataFrame(body_flat, columns=body_3d_xyz_header)- body_dataframe.to_csv(- str(Path(output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME), index=False- )+ body_dataframe.to_csv(str(Path(output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME), index=False)- right_hand_flat = right_hand_3d_xyz.reshape(- number_of_frames, number_of_hand_points * 3- )- right_hand_dataframe = pd.DataFrame(- right_hand_flat, columns=right_hand_3d_xyz_header- )+ right_hand_flat = right_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points * 3)+ right_hand_dataframe = pd.DataFrame(right_hand_flat, columns=right_hand_3d_xyz_header)right_hand_dataframe.to_csv(str(Path(output_data_folder_path) / MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME),index=False,)- left_hand_flat = left_hand_3d_xyz.reshape(- number_of_frames, number_of_hand_points * 3- )+ left_hand_flat = left_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points * 3)left_hand_dataframe = pd.DataFrame(left_hand_flat, columns=left_hand_3d_xyz_header)left_hand_dataframe.to_csv(str(Path(output_data_folder_path) / MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME),@@ -360,9 +317,7 @@ def convert_mediapipe_npy_to_csv(face_flat = face_3d_xyz.reshape(number_of_frames, number_of_face_points * 3)face_dataframe = pd.DataFrame(face_flat, columns=face_3d_xyz_header)- face_dataframe.to_csv(- str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.csv"), index=False- )+ face_dataframe.to_csv(str(Path(output_data_folder_path) / "mediapipe_face_3d_xyz.csv"), index=False)logger.info("Done saving out `csv` and broken up `npy` files")@@ -371,10 +326,6 @@ if __name__ == "__main__":mediapipe_3d_frame_trackedPoint_xyz = np.load(r"C:\Users\jonma\freemocap_data\session_10-15-2022-09_50_10\output_data\post_processed_data\mediaPipeSkel_3d_origin_aligned.npy")- output_data_folder_path = (- r"C:\Users\jonma\freemocap_data\session_10-15-2022-09_50_10\output_data"- )+ output_data_folder_path = r"C:\Users\jonma\freemocap_data\session_10-15-2022-09_50_10\output_data"- convert_mediapipe_npy_to_csv(- mediapipe_3d_frame_trackedPoint_xyz, output_data_folder_path- )+ convert_mediapipe_npy_to_csv(mediapipe_3d_frame_trackedPoint_xyz, output_data_folder_path)diff --git a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_dataclasses.py b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_dataclasses.pyindex 68696b93..14b88588 100644--- a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_dataclasses.py+++ b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_dataclasses.py@@ -6,6 +6,8 @@ import numpy as npfrom skellycam.detection.models.frame_payload import FramePayloadlogger = logging.getLogger(__name__)++@dataclassclass Mediapipe2dNumpyArrays:body_frameNumber_trackedPointNumber_XYZ: np.ndarray = Nonediff --git a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_skeleton_names_and_connections.py b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_skeleton_names_and_connections.pyindex 6c7cba2e..5f104200 100644--- a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_skeleton_names_and_connections.py+++ b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/data_models/mediapipe_skeleton_names_and_connections.py@@ -1,7 +1,6 @@from mediapipe.python.solutions import holistic as mp_holistic-mediapipe_body_connections = [connection for connection in mp_holistic.POSE_CONNECTIONS]mediapipe_hand_connections = [connection for connection in mp_holistic.HAND_CONNECTIONS]@@ -72,7 +71,7 @@ mediapipe_skeleton_schema = {"point_names": mediapipe_body_landmark_names,"connections": mediapipe_body_connections,"virtual_marker_definitions": mediapipe_virtual_marker_definitions_dict,- "parent": "hips_center"+ "parent": "hips_center",},"hands": {"right": {@@ -90,15 +89,16 @@ mediapipe_skeleton_schema = {"point_names": mediapipe_face_landmark_names,"connections": mediapipe_face_connections,"parent": "nose",- }+ },}if __name__ == "__main__":import pprint+## print("mediapipe_body_connections:")# pprint.pp(mediapipe_tracked_point_names_dict)print("=====================================================")print("mediapipe_skeleton_schema:")- pprint.pp(mediapipe_skeleton_schema)\ No newline at end of file+ pprint.pp(mediapipe_skeleton_schema)diff --git a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_detector.py b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_detector.pyindex 457e8641..f64c15ec 100644--- a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_detector.py+++ b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_detector.py@@ -9,15 +9,18 @@ import numpy as npfrom skellycam.opencv.video_recorder.video_recorder import VideoRecorderfrom tqdm import tqdm-from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_dataclasses import \- Mediapipe2dNumpyArrays+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_dataclasses import (+ Mediapipe2dNumpyArrays,+)from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import (mediapipe_tracked_point_names_dict,)from freemocap.data_layer.recording_models.post_processing_parameter_models import MediapipeParametersModel-from freemocap.system.paths_and_filenames.file_and_folder_names import MEDIAPIPE_2D_NPY_FILE_NAME, \- ANNOTATED_VIDEOS_FOLDER_NAME, \- MEDIAPIPE_BODY_WORLD_FILE_NAME+from freemocap.system.paths_and_filenames.file_and_folder_names import (+ MEDIAPIPE_2D_NPY_FILE_NAME,+ ANNOTATED_VIDEOS_FOLDER_NAME,+ MEDIAPIPE_BODY_WORLD_FILE_NAME,+)from freemocap.utilities.get_video_paths import get_video_pathslogger = logging.getLogger(__name__)@@ -33,9 +36,9 @@ face_drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=1)class MediaPipeSkeletonDetector:def __init__(- self,- parameter_model=MediapipeParametersModel(),- use_tqdm: bool = True,+ self,+ parameter_model=MediapipeParametersModel(),+ use_tqdm: bool = True,):self._parameter_model = parameter_modelself._use_tqdm = use_tqdm@@ -56,21 +59,21 @@ class MediaPipeSkeletonDetector:self.number_of_face_tracked_points = mp.solutions.face_mesh.FACEMESH_NUM_LANDMARKS_WITH_IRISESself.number_of_tracked_points_total = (- self.number_of_body_tracked_points- + self.number_of_left_hand_tracked_points- + self.number_of_right_hand_tracked_points- + self.number_of_face_tracked_points+ self.number_of_body_tracked_points+ + self.number_of_left_hand_tracked_points+ + self.number_of_right_hand_tracked_points+ + self.number_of_face_tracked_points)@staticmethoddef process_single_video(- synchronized_video_file_path: Path,- output_data_folder_path: Path,- mediapipe_parameters_model: MediapipeParametersModel,- annotate_image: Callable,- list_of_mediapipe_results_to_npy_arrays: Callable,- use_tqdm: bool = True,):-+ synchronized_video_file_path: Path,+ output_data_folder_path: Path,+ mediapipe_parameters_model: MediapipeParametersModel,+ annotate_image: Callable,+ list_of_mediapipe_results_to_npy_arrays: Callable,+ use_tqdm: bool = True,+ ):logger.info(f"Running `mediapipe` skeleton detection on video: {str(synchronized_video_file_path)}")holistic_tracker = mp_holistic.Holistic(@@ -99,7 +102,8 @@ class MediaPipeSkeletonDetector:total=number_of_frames,colour="magenta",unit="frames",- dynamic_ncols=True, )+ dynamic_ncols=True,+ )else:iterator = range(number_of_frames)@@ -120,7 +124,9 @@ class MediaPipeSkeletonDetector:confidence_threshold = 0.5- threshold_mask = mediapipe_single_frame_npy_data.body_frameNumber_trackedPointNumber_confidence < confidence_threshold+ threshold_mask = (+ mediapipe_single_frame_npy_data.body_frameNumber_trackedPointNumber_confidence < confidence_threshold+ )mediapipe_single_frame_npy_data.body_frameNumber_trackedPointNumber_XYZ[threshold_mask, :] = np.nanvideo_mediapipe_results_list.append(mediapipe_results)@@ -130,7 +136,6 @@ class MediaPipeSkeletonDetector:success, image = video_capture_object.read()try:-annotated_video_path = output_data_folder_path.parent.parent / ANNOTATED_VIDEOS_FOLDER_NAMEannotated_video_path.mkdir(exist_ok=True, parents=True)annotated_video_name = synchronized_video_file_path.stem + "_mediapipe.mp4"@@ -159,26 +164,28 @@ class MediaPipeSkeletonDetector:return camera_mediapipe_2d_single_camera_npy_arraysdef process_folder_full_of_videos(- self,- path_to_folder_of_videos_to_process: Union[Path, str],- output_data_folder_path: Union[str, Path],- save_annotated_videos: bool = True,- kill_event: multiprocessing.Event = None,+ self,+ path_to_folder_of_videos_to_process: Union[Path, str],+ output_data_folder_path: Union[str, Path],+ save_annotated_videos: bool = True,+ kill_event: multiprocessing.Event = None,) -> Union[np.ndarray, None]:-path_to_folder_of_videos_to_process = Path(path_to_folder_of_videos_to_process)logger.info(f"processing videos from: {path_to_folder_of_videos_to_process}")with multiprocessing.Pool() as pool:video_paths = get_video_paths(path_to_folder_of_videos_to_process)- tasks = [(video_path,- output_data_folder_path,- self._parameter_model,- self._annotate_image,- self._list_of_mediapipe_results_to_npy_arrays,+ tasks = [+ (+ video_path,+ output_data_folder_path,+ self._parameter_model,+ self._annotate_image,+ self._list_of_mediapipe_results_to_npy_arrays,self._use_tqdm,- ) for video_path in- video_paths]+ )+ for video_path in video_paths+ ]mediapipe2d_single_camera_npy_arrays_list = pool.starmap(self.process_single_video, tasks)all_cameras_data2d_list = [@@ -234,16 +241,14 @@ class MediaPipeSkeletonDetector:left_hand_3d = all_cameras_left_hand_world_data_list[cam_num]face_3d = all_cameras_face_world_data_list[cam_num]- body_world_numCams_numFrames_numTrackedPts_XYZ[cam_num, :, :, :] = np.concatenate((- pose_3d,- right_hand_3d,- left_hand_3d,- face_3d),- axis=1)+ body_world_numCams_numFrames_numTrackedPts_XYZ[cam_num, :, :, :] = np.concatenate(+ (pose_3d, right_hand_3d, left_hand_3d, face_3d), axis=1+ )logger.info(f"The shape of body_world_numCams_numFrames_numTrackedPts_XYZ is "- f"{body_world_numCams_numFrames_numTrackedPts_XYZ.shape}")+ f"{body_world_numCams_numFrames_numTrackedPts_XYZ.shape}"+ )self._save_mediapipe2d_data_to_npy(data2d_numCams_numFrames_numTrackedPts_XY=data2d_numCams_numFrames_numTrackedPts_XY,@@ -253,10 +258,10 @@ class MediaPipeSkeletonDetector:return data2d_numCams_numFrames_numTrackedPts_XYdef _save_mediapipe2d_data_to_npy(- self,- data2d_numCams_numFrames_numTrackedPts_XY: np.ndarray,- body_world_numCams_numFrames_numTrackedPts_XYZ: np.ndarray,- output_data_folder_path: Union[str, Path],+ self,+ data2d_numCams_numFrames_numTrackedPts_XY: np.ndarray,+ body_world_numCams_numFrames_numTrackedPts_XYZ: np.ndarray,+ output_data_folder_path: Union[str, Path],):mediapipe_2dData_save_path = Path(output_data_folder_path) / MEDIAPIPE_2D_NPY_FILE_NAMEmediapipe_2dData_save_path.parent.mkdir(exist_ok=True, parents=True)@@ -269,8 +274,7 @@ class MediaPipeSkeletonDetector:np.save(str(mediapipe_body_world_save_path), body_world_numCams_numFrames_numTrackedPts_XYZ)@staticmethod- def _annotate_image(image,- mediapipe_results):+ def _annotate_image(image, mediapipe_results):mp_drawing.draw_landmarks(image=image,landmark_list=mediapipe_results.face_landmarks,@@ -309,12 +313,11 @@ class MediaPipeSkeletonDetector:return imagedef _list_of_mediapipe_results_to_npy_arrays(- self,- mediapipe_results_list: List,- image_width: Union[int, float],- image_height: Union[int, float],+ self,+ mediapipe_results_list: List,+ image_width: Union[int, float],+ image_height: Union[int, float],) -> Mediapipe2dNumpyArrays:-number_of_frames = len(mediapipe_results_list)number_of_spatial_dimensions = 3 # this will be 2d XY pixel data, with mediapipe's estimate of Z@@ -375,19 +378,18 @@ class MediaPipeSkeletonDetector:all_tracked_points_visible_on_frame_list = []for frame_number, frame_results in enumerate(mediapipe_results_list):-# get the Body data (aka 'pose')if frame_results.pose_landmarks is not None:-for landmark_number, landmark_data in enumerate(frame_results.pose_landmarks.landmark):body_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 0] = (- landmark_data.x * image_width+ landmark_data.x * image_width)body_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 1] = (- landmark_data.y * image_height+ landmark_data.y * image_height)body_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 2] = (- landmark_data.z * image_width+ landmark_data.z+ * image_width# z is on roughly the same scale as x, according to mediapipe docs)body_frameNumber_trackedPointNumber_confidence[@@ -396,52 +398,52 @@ class MediaPipeSkeletonDetector:for landmark_number, landmark_data in enumerate(frame_results.pose_world_landmarks.landmark):body_world_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 0] = (- landmark_data.x * image_width+ landmark_data.x * image_width)body_world_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 1] = (- landmark_data.y * image_height+ landmark_data.y * image_height)body_world_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 2] = (- landmark_data.z * image_width+ landmark_data.z * image_width)# get Right Hand dataif frame_results.right_hand_landmarks is not None:for landmark_number, landmark_data in enumerate(frame_results.right_hand_landmarks.landmark):rightHand_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 0] = (- landmark_data.x * image_width+ landmark_data.x * image_width)rightHand_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 1] = (- landmark_data.y * image_height+ landmark_data.y * image_height)rightHand_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 2] = (- landmark_data.z * image_width+ landmark_data.z * image_width)# get Left Hand dataif frame_results.left_hand_landmarks is not None:for landmark_number, landmark_data in enumerate(frame_results.left_hand_landmarks.landmark):leftHand_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 0] = (- landmark_data.x * image_width+ landmark_data.x * image_width)leftHand_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 1] = (- landmark_data.y * image_height+ landmark_data.y * image_height)leftHand_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 2] = (- landmark_data.z * image_width+ landmark_data.z * image_width)# get Face dataif frame_results.face_landmarks is not None:for landmark_number, landmark_data in enumerate(frame_results.face_landmarks.landmark):face_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 0] = (- landmark_data.x * image_width+ landmark_data.x * image_width)face_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 1] = (- landmark_data.y * image_height+ landmark_data.y * image_height)face_frameNumber_trackedPointNumber_XYZ[frame_number, landmark_number, 2] = (- landmark_data.z * image_width+ landmark_data.z * image_width)# check if all tracked points are visible on this frame@@ -478,7 +480,5 @@ class MediaPipeSkeletonDetector:rightHand_frameNumber_trackedPointNumber_XYZ=np.squeeze(rightHand_frameNumber_trackedPointNumber_XYZ),leftHand_frameNumber_trackedPointNumber_XYZ=np.squeeze(leftHand_frameNumber_trackedPointNumber_XYZ),face_frameNumber_trackedPointNumber_XYZ=np.squeeze(face_frameNumber_trackedPointNumber_XYZ),- body_frameNumber_trackedPointNumber_confidence=np.squeeze(- body_frameNumber_trackedPointNumber_confidence- ),+ body_frameNumber_trackedPointNumber_confidence=np.squeeze(body_frameNumber_trackedPointNumber_confidence),)diff --git a/freemocap/core_processes/post_process_skeleton_data/calculate_center_of_mass.py b/freemocap/core_processes/post_process_skeleton_data/calculate_center_of_mass.pyindex 14fd23d4..1ea71537 100644--- a/freemocap/core_processes/post_process_skeleton_data/calculate_center_of_mass.py+++ b/freemocap/core_processes/post_process_skeleton_data/calculate_center_of_mass.py@@ -5,8 +5,9 @@ import numpy as npimport pandas as pdfrom rich.progress import track-from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import \- mediapipe_body_landmark_names+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import (+ mediapipe_body_landmark_names,+)logger = logging.getLogger(__name__)@@ -113,7 +114,6 @@ def build_mediapipe_skeleton(mediapipe_pose_data, segment_dataframe, mediapipe_imediapipe_frame_segment_joint_XYZ = [] # empty list to hold all the skeleton XYZ coordinates/framefor frame in track(num_frame_range, description="Building a MediaPipe Skeleton"):-trunk_joint_connection = ["left_shoulder","right_shoulder",@@ -126,13 +126,12 @@ def build_mediapipe_skeleton(mediapipe_pose_data, segment_dataframe, mediapipe_imediapipe_pose_skeleton_coordinates = {}for (- segment,- segment_info,+ segment,+ segment_info,) in (- segment_dataframe.iterrows()+ segment_dataframe.iterrows()): # iterate through the data frame by the segment name and all the info for that segmentif segment == "trunk":-# based on index, extract coordinate data from fmc mediapipe datamediapipe_pose_skeleton_coordinates[segment] = [trunk_virtual_markers[0],@@ -266,9 +265,9 @@ segment_COM_percentages = [# %%def calculate_segment_COM(- segment_conn_len_perc_dataframe,- skelcoordinates_frame_segment_joint_XYZ,- num_frame_range,+ segment_conn_len_perc_dataframe,+ skelcoordinates_frame_segment_joint_XYZ,+ num_frame_range,):segment_COM_frame_dict = []for frame in track(num_frame_range, description="Calculating Segment Center of Mass"):@@ -282,7 +281,7 @@ def calculate_segment_COM(this_segment_COM_length = segment_info["Segment_COM_Length"]this_segment_COM = this_segment_proximal + this_segment_COM_length * (- this_segment_distal - this_segment_proximal+ this_segment_distal - this_segment_proximal)segment_COM_dict[segment] = this_segment_COMsegment_COM_frame_dict.append(segment_COM_dict)@@ -309,7 +308,6 @@ def calculate_total_body_COM(segment_conn_len_perc_dataframe, segment_COM_frame_totalBodyCOM_frame_XYZ = np.empty([int(len(num_frame_range)), 3])for frame in track(num_frame_range, description="Calculating Total Body Center of Mass..."):-this_frame_total_body_percentages = []this_frame_skeleton = segment_COM_frame_dict[frame]@@ -332,10 +330,10 @@ def calculate_total_body_COM(segment_conn_len_perc_dataframe, segment_COM_frame_def build_anthropometric_dataframe(- segments: list,- joint_connections: list,- segment_COM_lengths: list,- segment_COM_percentages: list,+ segments: list,+ joint_connections: list,+ segment_COM_lengths: list,+ segment_COM_percentages: list,) -> pd.DataFrame:# load anthropometric data into a pandas dataframedf = pd.DataFrame(@@ -359,9 +357,9 @@ def build_anthropometric_dataframe(def calculate_center_of_mass(- freemocap_marker_data_array: np.ndarray,- pose_estimation_skeleton: list,- anthropometric_info_dataframe: pd.DataFrame,+ freemocap_marker_data_array: np.ndarray,+ pose_estimation_skeleton: list,+ anthropometric_info_dataframe: pd.DataFrame,):num_frames = freemocap_marker_data_array.shape[0]num_frame_range = range(num_frames)@@ -387,14 +385,20 @@ def run_center_of_mass_calculations(processed_skel3d_frame_marker_xyz: np.ndarraBODY_SEGMENT_NAMES, joint_connections, segment_COM_lengths, segment_COM_percentages)if not mediapipe_body_names_match_expected(mediapipe_body_landmark_names):- raise ValueError("Mediapipe body landmark names do not match expected names - Perhaps they altered the names in a new version? This code will need to be updated")+ raise ValueError(+ "Mediapipe body landmark names do not match expected names - Perhaps they altered the names in a new version? This code will need to be updated"+ )skelcoordinates_frame_segment_joint_XYZ = build_mediapipe_skeleton(processed_skel3d_frame_marker_xyz,anthropometric_info_dataframe,mediapipe_body_landmark_names,)- (segment_COM_frame_dict, segment_COM_frame_imgPoint_XYZ, totalBodyCOM_frame_XYZ,) = calculate_center_of_mass(+ (+ segment_COM_frame_dict,+ segment_COM_frame_imgPoint_XYZ,+ totalBodyCOM_frame_XYZ,+ ) = calculate_center_of_mass(processed_skel3d_frame_marker_xyz,skelcoordinates_frame_segment_joint_XYZ,anthropometric_info_dataframe,diff --git a/freemocap/core_processes/post_process_skeleton_data/post_process_skeleton.py b/freemocap/core_processes/post_process_skeleton_data/post_process_skeleton.pyindex f051e9db..7dfe51c8 100644--- a/freemocap/core_processes/post_process_skeleton_data/post_process_skeleton.py+++ b/freemocap/core_processes/post_process_skeleton_data/post_process_skeleton.py@@ -5,12 +5,21 @@ from pathlib import Pathimport loggingfrom skellyforge.freemocap_utils.config import default_settings-from skellyforge.freemocap_utils.constants import TASK_FILTERING, PARAM_CUTOFF_FREQUENCY, PARAM_SAMPLING_RATE, \- PARAM_ORDER, PARAM_ROTATE_DATA, TASK_SKELETON_ROTATION, TASK_INTERPOLATION, TASK_FINDING_GOOD_FRAME+from skellyforge.freemocap_utils.constants import (+ TASK_FILTERING,+ PARAM_CUTOFF_FREQUENCY,+ PARAM_SAMPLING_RATE,+ PARAM_ORDER,+ PARAM_ROTATE_DATA,+ TASK_SKELETON_ROTATION,+ TASK_INTERPOLATION,+ TASK_FINDING_GOOD_FRAME,+)from skellyforge.freemocap_utils.postprocessing_widgets.task_worker_thread import TaskWorkerThreadlogger = logging.getLogger(__name__)+class PostProcessedDataHandler:def __init__(self):self.processed_skeleton = None@@ -19,9 +28,9 @@ class PostProcessedDataHandler:self.processed_skeleton = processed_skeleton-def save_skeleton_array_to_npy(array_to_save: np.ndarray,- skeleton_file_name: str,- path_to_folder_where_we_will_save_this_data: Union[str,Path]):+def save_skeleton_array_to_npy(+ array_to_save: np.ndarray, skeleton_file_name: str, path_to_folder_where_we_will_save_this_data: Union[str, Path]+):if not skeleton_file_name.endswith(".npy"):skeleton_file_name += ".npy"Path(path_to_folder_where_we_will_save_this_data).mkdir(parents=True, exist_ok=True)@@ -30,6 +39,7 @@ def save_skeleton_array_to_npy(array_to_save: np.ndarray,array_to_save,)+def get_settings_from_parameter_tree(recording_processing_parameter_model):rec = recording_processing_parameter_model@@ -52,10 +62,9 @@ def adjust_default_settings(filter_sampling_rate, filter_cutoff_frequency, filtedef run_post_processing_worker(raw_skel3d_frame_marker_xyz: np.ndarray, settings_dictionary: dict):-- def handle_thread_finished(results,post_processed_data_handler:PostProcessedDataHandler):- processed_skeleton = results[TASK_FILTERING]['result']- post_processed_data_handler.data_callback(processed_skeleton =processed_skeleton)+ def handle_thread_finished(results, post_processed_data_handler: PostProcessedDataHandler):+ processed_skeleton = results[TASK_FILTERING]["result"]+ post_processed_data_handler.data_callback(processed_skeleton=processed_skeleton)task_list = [TASK_INTERPOLATION, TASK_FILTERING, TASK_FINDING_GOOD_FRAME, TASK_SKELETON_ROTATION]@@ -67,7 +76,7 @@ def run_post_processing_worker(raw_skel3d_frame_marker_xyz: np.ndarray, settingsraw_skeleton_data=raw_skel3d_frame_marker_xyz,task_list=task_list,settings=settings_dictionary,- all_tasks_finished_callback=lambda results: handle_thread_finished(results, post_processed_data_handler)+ all_tasks_finished_callback=lambda results: handle_thread_finished(results, post_processed_data_handler),)worker_thread.start()worker_thread.join()@@ -75,12 +84,14 @@ def run_post_processing_worker(raw_skel3d_frame_marker_xyz: np.ndarray, settingsreturn post_processed_data_handler.processed_skeleton+def post_process_data(recording_processing_parameter_model, raw_skel3d_frame_marker_xyz: np.ndarray):filter_sampling_rate, filter_cutoff_frequency, filter_order = get_settings_from_parameter_tree(- recording_processing_parameter_model)+ recording_processing_parameter_model+ )adjusted_settings = adjust_default_settings(filter_sampling_rate, filter_cutoff_frequency, filter_order)processed_skeleton_array = run_post_processing_worker(- raw_skel3d_frame_marker_xyz=raw_skel3d_frame_marker_xyz,- settings_dictionary=adjusted_settings)+ raw_skel3d_frame_marker_xyz=raw_skel3d_frame_marker_xyz, settings_dictionary=adjusted_settings+ )return processed_skeleton_arraydiff --git a/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.py b/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.pyindex 8b57952e..7d71fa45 100644--- a/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.py+++ b/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.py@@ -10,19 +10,21 @@ from freemocap.utilities.geometry.project_3d_data_to_z_plane import project_3d_dlogger = logging.getLogger(__name__)-def process_single_camera_skeleton_data(input_image_data_frame_marker_xyz: np.ndarray,- raw_data_folder_path: Union[str, Path],- project_to_z_plane: bool = True) -> [np.ndarray, np.ndarray]:-+def process_single_camera_skeleton_data(+ input_image_data_frame_marker_xyz: np.ndarray,+ raw_data_folder_path: Union[str, Path],+ project_to_z_plane: bool = True,+) -> [np.ndarray, np.ndarray]:if project_to_z_plane:-- logger.info("Single camera detected - "- "Altering image-derived 3d data to resemble multi-camera reconstructed data.")+ logger.info(+ "Single camera detected - " "Altering image-derived 3d data to resemble multi-camera reconstructed data."+ )skeleton_reprojection_error_fr_mar = np.zeros(input_image_data_frame_marker_xyz.shape[0:2])raw_skel3d_frame_marker_xyz = project_3d_data_to_z_plane(- skel3d_frame_marker_xyz=input_image_data_frame_marker_xyz)+ skel3d_frame_marker_xyz=input_image_data_frame_marker_xyz+ )save_mediapipe_3d_data_to_npy(data3d_numFrames_numTrackedPoints_XYZ=raw_skel3d_frame_marker_xyz,diff --git a/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.py b/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.pyindex a85b6fd2..ffc156bb 100644--- a/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.py+++ b/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.py@@ -25,16 +25,23 @@ from freemocap.core_processes.post_process_skeleton_data.estimate_skeleton_segmeestimate_skeleton_segment_lengths,mediapipe_skeleton_segment_definitions,)-from freemocap.core_processes.post_process_skeleton_data.post_process_skeleton import post_process_data, \- save_skeleton_array_to_npy-from freemocap.core_processes.post_process_skeleton_data.process_single_camera_skeleton_data import \- process_single_camera_skeleton_data+from freemocap.core_processes.post_process_skeleton_data.post_process_skeleton import (+ post_process_data,+ save_skeleton_array_to_npy,+)+from freemocap.core_processes.post_process_skeleton_data.process_single_camera_skeleton_data import (+ process_single_camera_skeleton_data,+)from freemocap.data_layer.data_saver.data_saver import DataSaverfrom freemocap.data_layer.recording_models.post_processing_parameter_models import PostProcessingParameterModelfrom freemocap.system.logging.queue_logger import DirectQueueHandler-from freemocap.system.paths_and_filenames.file_and_folder_names import RAW_DATA_FOLDER_NAME, \- SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME, CENTER_OF_MASS_FOLDER_NAME, TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME, \- MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME+from freemocap.system.paths_and_filenames.file_and_folder_names import (+ RAW_DATA_FOLDER_NAME,+ SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME,+ CENTER_OF_MASS_FOLDER_NAME,+ TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME,+ MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME,+)from freemocap.tests.test_image_tracking_data_shape import (test_image_tracking_data_shape,)@@ -45,11 +52,12 @@ from freemocap.system.logging.configure_logging import log_view_logging_format_slogger = logging.getLogger(__name__)+def process_recording_folder(- recording_processing_parameter_model: PostProcessingParameterModel,- kill_event: multiprocessing.Event = None,- queue: multiprocessing.Queue = None,- use_tqdm: bool = True,+ recording_processing_parameter_model: PostProcessingParameterModel,+ kill_event: multiprocessing.Event = None,+ queue: multiprocessing.Queue = None,+ use_tqdm: bool = True,):"""@@ -72,11 +80,14 @@ def process_recording_folder(f"Could not find synchronized_videos folder at {rec.recording_info_model.synchronized_videos_folder_path}")-if rec.mediapipe_parameters_model.skip_2d_image_tracking:- logger.info(f"Skipping 2d skeleton detection and loading data from: {rec.recording_info_model.mediapipe_2d_data_npy_file_path}")+ logger.info(+ f"Skipping 2d skeleton detection and loading data from: {rec.recording_info_model.mediapipe_2d_data_npy_file_path}"+ )try:- mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ = np.load(rec.recording_info_model.mediapipe_2d_data_npy_file_path)+ mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ = np.load(+ rec.recording_info_model.mediapipe_2d_data_npy_file_path+ )except Exception as e:logger.error("Failed to load 2D data, cannot continue processing", exc_info=True)return@@ -88,10 +99,12 @@ def process_recording_folder(use_tqdm=use_tqdm,)- mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ = mediapipe_skeleton_detector.process_folder_full_of_videos(- rec.recording_info_model.synchronized_videos_folder_path,- Path(rec.recording_info_model.output_data_folder_path) / RAW_DATA_FOLDER_NAME,- kill_event=kill_event,+ mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ = (+ mediapipe_skeleton_detector.process_folder_full_of_videos(+ rec.recording_info_model.synchronized_videos_folder_path,+ Path(rec.recording_info_model.output_data_folder_path) / RAW_DATA_FOLDER_NAME,+ kill_event=kill_event,+ ))if kill_event is not None and kill_event.is_set():@@ -110,25 +123,36 @@ def process_recording_folder(# spoof 3D data if single camera(raw_skel3d_frame_marker_xyz, skeleton_reprojection_error_fr_mar) = process_single_camera_skeleton_data(input_image_data_frame_marker_xyz=mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ[0],- raw_data_folder_path=Path(rec.recording_info_model.raw_data_folder_path))+ raw_data_folder_path=Path(rec.recording_info_model.raw_data_folder_path),+ )else:if rec.anipose_triangulate_3d_parameters_model.skip_3d_triangulation:- logger.info(f"Skipping 3d triangulation and loading data from: {rec.recording_info_model.raw_mediapipe_3d_data_npy_file_path}")+ logger.info(+ f"Skipping 3d triangulation and loading data from: {rec.recording_info_model.raw_mediapipe_3d_data_npy_file_path}"+ )raw_skel3d_frame_marker_xyz = np.load(rec.recording_info_model.raw_mediapipe_3d_data_npy_file_path)skeleton_reprojection_error_fr_mar = np.load(- rec.recording_info_model.mediapipe_reprojection_error_data_npy_file_path)+ rec.recording_info_model.mediapipe_reprojection_error_data_npy_file_path+ )else:logger.info("Triangulating 3d skeletons...")- assert rec.recording_info_model.calibration_toml_check, f"No calibration file found at: {rec.recording_info_model.calibration_toml_path}"- assert rec.recording_info_model.data2d_status_check, f"No mediapipe 2d data found at: {rec.recording_info_model.mediapipe_2d_data_npy_file_path}"+ assert (+ rec.recording_info_model.calibration_toml_check+ ), f"No calibration file found at: {rec.recording_info_model.calibration_toml_path}"+ assert (+ rec.recording_info_model.data2d_status_check+ ), f"No mediapipe 2d data found at: {rec.recording_info_model.mediapipe_2d_data_npy_file_path}"anipose_calibration_object = load_anipose_calibration_toml_from_path(camera_calibration_data_toml_path=rec.recording_info_model.calibration_toml_path,save_copy_of_calibration_to_this_path=rec.recording_info_model.path,)- (raw_skel3d_frame_marker_xyz, skeleton_reprojection_error_fr_mar,) = triangulate_3d_data(+ (+ raw_skel3d_frame_marker_xyz,+ skeleton_reprojection_error_fr_mar,+ ) = triangulate_3d_data(anipose_calibration_object=anipose_calibration_object,mediapipe_2d_data=mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ[:, :, :, :2],output_data_folder_path=rec.recording_info_model.raw_data_folder_path,@@ -151,32 +175,41 @@ def process_recording_folder(logger.info("Using SkellyForge Post-Processing to clean up data...")-rotated_raw_skel3d_frame_marker_xyz = rotate_by_90_degrees_around_x_axis(raw_skel3d_frame_marker_xyz)skel3d_frame_marker_xyz = post_process_data(recording_processing_parameter_model=recording_processing_parameter_model,- raw_skel3d_frame_marker_xyz= rotated_raw_skel3d_frame_marker_xyz)+ raw_skel3d_frame_marker_xyz=rotated_raw_skel3d_frame_marker_xyz,+ )path_to_folder_where_we_will_save_this_data = rec.recording_info_model.output_data_folder_path---logger.info("Saving post-processed data")- save_skeleton_array_to_npy(array_to_save=skel3d_frame_marker_xyz, skeleton_file_name="mediaPipeSkel_3d_body_hands_face.npy",- path_to_folder_where_we_will_save_this_data=path_to_folder_where_we_will_save_this_data)+ save_skeleton_array_to_npy(+ array_to_save=skel3d_frame_marker_xyz,+ skeleton_file_name="mediaPipeSkel_3d_body_hands_face.npy",+ path_to_folder_where_we_will_save_this_data=path_to_folder_where_we_will_save_this_data,+ )- segment_COM_frame_imgPoint_XYZ, totalBodyCOM_frame_XYZ = run_center_of_mass_calculations(processed_skel3d_frame_marker_xyz=skel3d_frame_marker_xyz)+ segment_COM_frame_imgPoint_XYZ, totalBodyCOM_frame_XYZ = run_center_of_mass_calculations(+ processed_skel3d_frame_marker_xyz=skel3d_frame_marker_xyz+ )logger.info("Saving segment center of mass data")- save_skeleton_array_to_npy(array_to_save=segment_COM_frame_imgPoint_XYZ, skeleton_file_name=SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME,- path_to_folder_where_we_will_save_this_data= Path(path_to_folder_where_we_will_save_this_data)/CENTER_OF_MASS_FOLDER_NAME)+ save_skeleton_array_to_npy(+ array_to_save=segment_COM_frame_imgPoint_XYZ,+ skeleton_file_name=SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME,+ path_to_folder_where_we_will_save_this_data=Path(path_to_folder_where_we_will_save_this_data)+ / CENTER_OF_MASS_FOLDER_NAME,+ )logger.info("Saving total body center of mass data")- save_skeleton_array_to_npy(array_to_save=totalBodyCOM_frame_XYZ, skeleton_file_name=TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME,- path_to_folder_where_we_will_save_this_data= Path(path_to_folder_where_we_will_save_this_data)/CENTER_OF_MASS_FOLDER_NAME)-+ save_skeleton_array_to_npy(+ array_to_save=totalBodyCOM_frame_XYZ,+ skeleton_file_name=TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME,+ path_to_folder_where_we_will_save_this_data=Path(path_to_folder_where_we_will_save_this_data)+ / CENTER_OF_MASS_FOLDER_NAME,+ )try:test_mediapipe_skeleton_data_shape(@@ -195,7 +228,7 @@ def process_recording_folder()path_to_skeleton_body_csv = (- Path(rec.recording_info_model.output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME+ Path(rec.recording_info_model.output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME)skeleton_dataframe = pd.read_csv(path_to_skeleton_body_csv)@@ -217,7 +250,7 @@ def process_recording_folder(dictionary=mediapipe_names_and_connections_dict,)- #TODO - move this data output method *above* the sloppy stuff above and deprecate the sloppy stuff (gracefully enough not to bork hypothetical users' workflows)+ # TODO - move this data output method *above* the sloppy stuff above and deprecate the sloppy stuff (gracefully enough not to bork hypothetical users' workflows)DataSaver(recording_folder_path=rec.recording_info_model.path).save_all()- logger.info(f"Done processing {rec.recording_info_model.path}")\ No newline at end of file+ logger.info(f"Done processing {rec.recording_info_model.path}")diff --git a/freemocap/core_processes/process_motion_capture_videos/process_recording_headless.py b/freemocap/core_processes/process_motion_capture_videos/process_recording_headless.pyindex 00b3a68e..aadd3037 100644--- a/freemocap/core_processes/process_motion_capture_videos/process_recording_headless.py+++ b/freemocap/core_processes/process_motion_capture_videos/process_recording_headless.py@@ -5,7 +5,9 @@ from typing import Optional, Unionfrom freemocap.core_processes.process_motion_capture_videos.process_recording_folder import process_recording_folderfrom freemocap.data_layer.export_data.blender_stuff.export_to_blender import export_to_blenderfrom freemocap.data_layer.export_data.blender_stuff.get_best_guess_of_blender_path import get_best_guess_of_blender_path-from freemocap.data_layer.export_data.generate_jupyter_notebook.generate_jupyter_notebook import generate_jupyter_notebook+from freemocap.data_layer.export_data.generate_jupyter_notebook.generate_jupyter_notebook import (+ generate_jupyter_notebook,+)from freemocap.data_layer.recording_models.post_processing_parameter_models import PostProcessingParameterModelfrom freemocap.data_layer.recording_models.recording_info_model import RecordingInfoModelfrom freemocap.system.paths_and_filenames.file_and_folder_names import RECORDING_PARAMETERS_JSON_FILE_NAME@@ -18,20 +20,21 @@ logger = logging.getLogger(__name__)def process_recording_headless(- recording_path: Union[str, Path],- path_to_camera_calibration_toml: Optional[Union[str, Path]] = None,- path_to_blender_executable: Optional[Union[str, Path]] = get_best_guess_of_blender_path(),- recording_processing_parameter_model: Optional[- PostProcessingParameterModel] = PostProcessingParameterModel(),- use_tqdm: bool = True,+ recording_path: Union[str, Path],+ path_to_camera_calibration_toml: Optional[Union[str, Path]] = None,+ path_to_blender_executable: Optional[Union[str, Path]] = get_best_guess_of_blender_path(),+ recording_processing_parameter_model: Optional[PostProcessingParameterModel] = PostProcessingParameterModel(),+ use_tqdm: bool = True,):rec = recording_processing_parameter_model- logger.info(f"Processing recording:\n"- f"Recording path: {recording_path}\n"- f"Camera calibration toml path: {path_to_camera_calibration_toml}\n"- f"Blender executable path: {path_to_blender_executable}\n"- f"Recording processing parameter model: {rec.dict()}")+ logger.info(+ f"Processing recording:\n"+ f"Recording path: {recording_path}\n"+ f"Camera calibration toml path: {path_to_camera_calibration_toml}\n"+ f"Blender executable path: {path_to_blender_executable}\n"+ f"Recording processing parameter model: {rec.dict()}"+ )rec.recording_info_model = RecordingInfoModel(recording_folder_path=Path(recording_path))@@ -42,10 +45,10 @@ def process_recording_headless(number_of_videos = len(get_video_paths(rec.recording_info_model.synchronized_videos_folder_path))if number_of_videos > 1:raise ValueError(- f"There are {number_of_videos} videos. Must provide a calibration toml file for multicamera recordings.")-+ f"There are {number_of_videos} videos. Must provide a calibration toml file for multicamera recordings."+ )- recording_info_dict = rec.dict(exclude={'recording_info_model'})+ recording_info_dict = rec.dict(exclude={"recording_info_model"})Path(rec.recording_info_model.output_data_folder_path).mkdir(parents=True, exist_ok=True)@@ -56,8 +59,7 @@ def process_recording_headless()logger.info("Starting core processing pipeline...")- process_recording_folder(recording_processing_parameter_model=rec,- use_tqdm=use_tqdm)+ process_recording_folder(recording_processing_parameter_model=rec, use_tqdm=use_tqdm)logger.info("Generating jupyter notebook...")generate_jupyter_notebook(path_to_recording=recording_path)@@ -75,7 +77,7 @@ def process_recording_headless(def find_calibration_toml_path(recording_path: Union[str, Path]) -> Path:- for file in Path(recording_path).glob('*calibration.toml'):+ for file in Path(recording_path).glob("*calibration.toml"):return Path(file)diff --git a/freemocap/data_layer/data_saver/data_loader.py b/freemocap/data_layer/data_saver/data_loader.pyindex ba18e533..6e99c611 100644--- a/freemocap/data_layer/data_saver/data_loader.py+++ b/freemocap/data_layer/data_saver/data_loader.py@@ -6,25 +6,35 @@ from typing import Union, Dict, Anyimport numpy as npimport pandas as pd-from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import \- mediapipe_skeleton_schema-from freemocap.core_processes.post_process_skeleton_data.calculate_center_of_mass import \- BODY_SEGMENT_NAMES+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import (+ mediapipe_skeleton_schema,+)+from freemocap.core_processes.post_process_skeleton_data.calculate_center_of_mass import BODY_SEGMENT_NAMESfrom freemocap.data_layer.data_saver.data_models import FrameData, Timestamps, Point, SkeletonSchema-from freemocap.system.paths_and_filenames.file_and_folder_names import MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME, \- MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME, MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME, \- MEDIAPIPE_FACE_3D_DATAFRAME_CSV_FILE_NAME-from freemocap.system.paths_and_filenames.path_getters import get_output_data_folder_path, get_timestamps_directory, \- get_total_body_center_of_mass_file_path, get_segment_center_of_mass_file_path, get_full_npy_file_path+from freemocap.system.paths_and_filenames.file_and_folder_names import (+ MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME,+ MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME,+ MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME,+ MEDIAPIPE_FACE_3D_DATAFRAME_CSV_FILE_NAME,+)+from freemocap.system.paths_and_filenames.path_getters import (+ get_output_data_folder_path,+ get_timestamps_directory,+ get_total_body_center_of_mass_file_path,+ get_segment_center_of_mass_file_path,+ get_full_npy_file_path,+)logger = logging.getLogger(__name__)-class DataLoader:- def __init__(self,- recording_folder_path: Union[str, Path],- include_hands: bool = True,- include_face: bool = True, ):+class DataLoader:+ def __init__(+ self,+ recording_folder_path: Union[str, Path],+ include_hands: bool = True,+ include_face: bool = True,+ ):self._recording_folder_path = Path(recording_folder_path)self.include_hands = include_handsself.include_face = include_face@@ -57,21 +67,23 @@ class DataLoader:return pd.read_csv(self._output_folder_path / filename)def _validate_data(self):- self._validate_dataframe(self.right_hand_dataframe, 'right hand')- self._validate_dataframe(self.left_hand_dataframe, 'left hand')- self._validate_dataframe(self.face_dataframe, 'face')- self._validate_numpy_array(self.center_of_mass_xyz, 'center of mass')- self._validate_numpy_array(self.segment_center_of_mass_segment_xyz, 'segment center of mass')+ self._validate_dataframe(self.right_hand_dataframe, "right hand")+ self._validate_dataframe(self.left_hand_dataframe, "left hand")+ self._validate_dataframe(self.face_dataframe, "face")+ self._validate_numpy_array(self.center_of_mass_xyz, "center of mass")+ self._validate_numpy_array(self.segment_center_of_mass_segment_xyz, "segment center of mass")def _validate_dataframe(self, df, df_name):if df is not None and len(df) != self.number_of_frames:raise ValueError(- f"The number of frames in the {df_name} dataframe is different from the number of frames in the body dataframe.")+ f"The number of frames in the {df_name} dataframe is different from the number of frames in the body dataframe."+ )def _validate_numpy_array(self, np_array, np_array_name):if np_array is not None and np_array.shape[0] != self.number_of_frames:raise ValueError(- f"The number of frames in the {np_array_name} data is different from the number of frames in the body dataframe.")+ f"The number of frames in the {np_array_name} data is different from the number of frames in the body dataframe."+ )def _load_timestamps(self):timestamps_directory = get_timestamps_directory(recording_directory=self._recording_folder_path)@@ -93,35 +105,41 @@ class DataLoader:Load additional data like center of mass and segment lengths."""self.center_of_mass_xyz = np.load(- get_total_body_center_of_mass_file_path(output_data_folder=self._output_folder_path))+ get_total_body_center_of_mass_file_path(output_data_folder=self._output_folder_path)+ )self.segment_center_of_mass_segment_xyz = np.load(- get_segment_center_of_mass_file_path(output_data_folder=self._output_folder_path))+ get_segment_center_of_mass_file_path(output_data_folder=self._output_folder_path)+ )def _load_full_npy_data(self):self.data_frame_name_xyz = np.load(get_full_npy_file_path(output_data_folder=self._output_folder_path))def _load_names_and_connections(self):- with open(self._output_folder_path / "mediapipe_names_and_connections_dict.json", 'r') as file:+ with open(self._output_folder_path / "mediapipe_names_and_connections_dict.json", "r") as file:self.names_and_connections = json.loads(file.read())def _load_segment_lengths(self):- with open(self._output_folder_path / "mediapipe_skeleton_segment_lengths.json", 'r') as file:+ with open(self._output_folder_path / "mediapipe_skeleton_segment_lengths.json", "r") as file:self.segment_lengths = json.loads(file.read())def load_frame_data(self, frame_number: int) -> FrameData:- return FrameData(timestamps=self.get_timestamps(frame_number),- tracked_points=self.get_tracked_points(frame_number))+ return FrameData(+ timestamps=self.get_timestamps(frame_number), tracked_points=self.get_tracked_points(frame_number)+ )def get_timestamps(self, frame_number):try:- return Timestamps(mean=self._timestamps_mean_per_frame[frame_number],- by_camera={camera_name: timestamps[frame_number] for camera_name, timestamps in- self._timestamps_by_camera.items()})+ return Timestamps(+ mean=self._timestamps_mean_per_frame[frame_number],+ by_camera={+ camera_name: timestamps[frame_number]+ for camera_name, timestamps in self._timestamps_by_camera.items()+ },+ )except AttributeError:return Timestamps()def get_tracked_points(self, frame_number) -> Dict[str, Point]:-right_hand_points = {}left_hand_points = {}face_points = {}@@ -154,14 +172,18 @@ class DataLoader:Calculate the center of mass for a given frame number."""com_data = {}- com_data['full_body_com'] = Point(x=self.center_of_mass_xyz[frame_number, 0],- y=self.center_of_mass_xyz[frame_number, 1],- z=self.center_of_mass_xyz[frame_number, 2])+ com_data["full_body_com"] = Point(+ x=self.center_of_mass_xyz[frame_number, 0],+ y=self.center_of_mass_xyz[frame_number, 1],+ z=self.center_of_mass_xyz[frame_number, 2],+ )for segment_number, segment_name in enumerate(BODY_SEGMENT_NAMES):- com_data[segment_name] = Point(x=self.segment_center_of_mass_segment_xyz[frame_number, segment_number, 0],- y=self.segment_center_of_mass_segment_xyz[frame_number, segment_number, 1],- z=self.segment_center_of_mass_segment_xyz[frame_number, segment_number, 2])+ com_data[segment_name] = Point(+ x=self.segment_center_of_mass_segment_xyz[frame_number, segment_number, 0],+ y=self.segment_center_of_mass_segment_xyz[frame_number, segment_number, 1],+ z=self.segment_center_of_mass_segment_xyz[frame_number, segment_number, 2],+ )return com_datadiff --git a/freemocap/data_layer/data_saver/data_models.py b/freemocap/data_layer/data_saver/data_models.pyindex dc1aca7c..fe49a402 100644--- a/freemocap/data_layer/data_saver/data_models.py+++ b/freemocap/data_layer/data_saver/data_models.py@@ -4,24 +4,32 @@ from typing import Optional, Anyfrom pydantic import BaseModel, Field, root_validator-from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import \- mediapipe_skeleton_schema+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import (+ mediapipe_skeleton_schema,+)class Point(BaseModel):"""A point in 3D space at a particular time"""+x: Optional[float] = Field(None, description="The X-coordinate of the point")y: Optional[float] = Field(None, description="The Y-coordinate of the point")z: Optional[float] = Field(None, description="The Z-coordinate of the point")+class VirtualMarkerDefinition(BaseModel):"""A virtual marker, defined by combining multiple markers with weights to generate a new marker/point"""- marker_names: List[str] = Field(default_factory=list, description="The names of the markers that define this virtual marker")- marker_weights: List[float] = Field(default_factory=list, description="The weights of the markers that define this virtual marker, must sum to 1")++ marker_names: List[str] = Field(+ default_factory=list, description="The names of the markers that define this virtual marker"+ )+ marker_weights: List[float] = Field(+ default_factory=list, description="The weights of the markers that define this virtual marker, must sum to 1"+ )@root_validatordef check_weights(cls, values):@@ -30,18 +38,29 @@ class VirtualMarkerDefinition(BaseModel):raise ValueError(f"Marker weights must sum to 1, got {marker_weights}")return values+class SegmentSchema(BaseModel):"""A schema for a segment of a skeleton, defined by a set of tracked points and connections between them"""- point_names: List[str] = Field(default_factory=list, description="The names of the tracked points that define this segment")- virtual_marker_definitions: Optional[Dict[str, VirtualMarkerDefinition]] = Field(default_factory=dict, description="The virtual markers that define this segment")- connections: List[Tuple[int, int]] = Field(default_factory=list, description="The connections between the tracked points")++ point_names: List[str] = Field(+ default_factory=list, description="The names of the tracked points that define this segment"+ )+ virtual_marker_definitions: Optional[Dict[str, VirtualMarkerDefinition]] = Field(+ default_factory=dict, description="The virtual markers that define this segment"+ )+ connections: List[Tuple[int, int]] = Field(+ default_factory=list, description="The connections between the tracked points"+ )parent: Optional[str] = Field(None, description="The name of the parent of this segment")+class SkeletonSchema(BaseModel):- body: SegmentSchema = Field(default_factory=SegmentSchema, description="The tracked points that define the body")- hands: Dict[str, SegmentSchema] = Field(default_factory=dict, description="The tracked points that define the hands: keys - (left, right)")+ body: SegmentSchema = Field(default_factory=SegmentSchema, description="The tracked points that define the body")+ hands: Dict[str, SegmentSchema] = Field(+ default_factory=dict, description="The tracked points that define the hands: keys - (left, right)"+ )face: SegmentSchema = Field(default_factory=SegmentSchema, description="The tracked points that define the face")def __init__(self, schema_dict: Dict[str, Dict[str, Any]]):@@ -61,14 +80,19 @@ class SkeletonSchema(BaseModel):class Timestamps(BaseModel):# TODO - Add Unix time and ISO format stuff and whatnotmean: Optional[float] = Field(None, description="The mean timestamp for this frame")- by_camera: Dict[str, Any] = Field(default_factory=dict, description="Timestamps for each camera on this frame (key is video name)")+ by_camera: Dict[str, Any] = Field(+ default_factory=dict, description="Timestamps for each camera on this frame (key is video name)"+ )+class FrameData(BaseModel):"""The data for a single frame"""+timestamps: Timestamps = Field(default_factory=Timestamps, description="Timestamp data")tracked_points: Dict[str, Point] = Field(default_factory=dict, description="The points being tracked")+@propertydef tracked_point_names(self):return list(self.tracked_points.keys())@@ -83,10 +107,12 @@ class FrameData(BaseModel):d["tracked_points"] = {name: point.dict() for name, point in self.tracked_points.items()}return d+class InfoDict(BaseModel):"""A dictionary of information about this recording, such as the measured segement lengths and the schemas that we can use to interpret the tracked points (i.e./e.g. how to connect the dots of skeleton)"""+segment_lengths: Dict[str, Any] = Field(default_factory=dict, description="The lengths of the segments of the body")schemas: List[BaseModel] = Field(default_factory=list, description="The schemas for the tracked points")@@ -100,4 +126,3 @@ if __name__ == "__main__":skeleton_schema = SkeletonSchema(schema_dict=mediapipe_skeleton_schema)pprint.pp(skeleton_schema.dict())-diff --git a/freemocap/data_layer/data_saver/data_saver.py b/freemocap/data_layer/data_saver/data_saver.pyindex ca03b712..7401b09f 100644--- a/freemocap/data_layer/data_saver/data_saver.py+++ b/freemocap/data_layer/data_saver/data_saver.py@@ -15,11 +15,7 @@ from typing import Any, Dictclass DataSaver:-- def __init__(self,- recording_folder_path: Union[Path, str],- include_hands: bool = True,- include_face: bool = True):+ def __init__(self, recording_folder_path: Union[Path, str], include_hands: bool = True, include_face: bool = True):"""Initialize DataFrameManager with the given recording_folder_path.@@ -31,9 +27,9 @@ class DataSaver:self.recording_folder_path = Path(recording_folder_path)self._recording_name = self.recording_folder_path.name- self._data_loader = DataLoader(recording_folder_path=self.recording_folder_path,- include_hands=include_hands,- include_face=include_face)+ self._data_loader = DataLoader(+ recording_folder_path=self.recording_folder_path, include_hands=include_hands, include_face=include_face+ )self.recording_data_by_frame = Noneself.number_of_frames = None@@ -54,15 +50,15 @@ class DataSaver:def save_to_json(self, save_path: Union[str, Path] = None):dict_to_save = {}- dict_to_save['info'] = self._get_info_dict().dict()- dict_to_save['data_by_frame'] = self.recording_data_by_frame+ dict_to_save["info"] = self._get_info_dict().dict()+ dict_to_save["data_by_frame"] = self.recording_data_by_frameif save_path is None:save_path = Path(self.recording_folder_path) / f"{self._recording_name}_by_frame.json"logger.info(f"Saving recording data to {save_path}")- save_path.write_text(json.dumps(dict_to_save, indent=4), encoding='utf-8')+ save_path.write_text(json.dumps(dict_to_save, indent=4), encoding="utf-8")def save_to_csv(self, save_path: Union[str, Path] = None):data_for_dataframe = []@@ -91,10 +87,10 @@ class DataSaver:"""frame_data_row = {}- frame_data_row['timestamp'] = frame_data['timestamps']['mean']- frame_data_row['timestamp_by_camera'] = str(frame_data['timestamps']['by_camera'])+ frame_data_row["timestamp"] = frame_data["timestamps"]["mean"]+ frame_data_row["timestamp_by_camera"] = str(frame_data["timestamps"]["by_camera"])- for key, tracked_point in frame_data['tracked_points'].items():+ for key, tracked_point in frame_data["tracked_points"].items():frame_data_row[f"{key}_x"] = tracked_point["x"]frame_data_row[f"{key}_y"] = tracked_point["y"]frame_data_row[f"{key}_z"] = tracked_point["z"]@@ -108,8 +104,9 @@ class DataSaver:)-if __name__ == '__main__':+if __name__ == "__main__":# recording_data_saver = DataSaver(recording_folder_path=get_sample_data_path())recording_data_saver = DataSaver(- recording_folder_path=r"C:\Users\jonma\freemocap_data\recording_sessions\session_2023-04-14_15_29_45\recording_15_47_37_gmt-4")+ recording_folder_path=r"C:\Users\jonma\freemocap_data\recording_sessions\session_2023-04-14_15_29_45\recording_15_47_37_gmt-4"+ )recording_data_by_frame_number = recording_data_saver.save_all()diff --git a/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/alpha_freemocap_blender_megascript.py b/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/alpha_freemocap_blender_megascript.pyindex 553f3972..a989b6b5 100644--- a/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/alpha_freemocap_blender_megascript.py+++ b/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/alpha_freemocap_blender_megascript.py@@ -13,6 +13,7 @@ bpy.ops.preferences.addon_enable(module="rigify")#######################################################################+def get_video_paths(path_to_video_folder: Path) -> list:"""Search the folder for 'mp4' files (case insensitive) and return them as a list"""@@ -31,6 +32,7 @@ def get_unique_list(list: list) -> list:return unique_list+try:##% Session path# #get session path as command line argument@@ -1541,7 +1543,6 @@ try:tail_name = this_bone_dict[1]["tail"]try:-head_index = mediapipe_tracked_point_names.index(head_name)tail_index = mediapipe_tracked_point_names.index(tail_name)diff --git a/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/freemocap_blender_megascript_take2.py b/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/freemocap_blender_megascript_take2.pyindex 8eef08fc..311515e1 100644--- a/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/freemocap_blender_megascript_take2.py+++ b/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/freemocap_blender_megascript_take2.py@@ -21,11 +21,12 @@ logger = logging.getLogger(__name__)###############################################################-def main(recording_path: Union[str, Path],- blender_file_save_path: Union[str, Path],- mediapipe_empty_names: Dict[str, List[str]],- create_rig: bool = True,- ):+def main(+ recording_path: Union[str, Path],+ blender_file_save_path: Union[str, Path],+ mediapipe_empty_names: Dict[str, List[str]],+ create_rig: bool = True,+):###%% clear the scene - Scorch the earth \o/print("Clearing scene...")try:@@ -50,7 +51,9 @@ def main(recording_path: Union[str, Path],path_to_face_npy = path_to_data_arrays_folder / "mediapipe_face_3d_xyz.npy"path_to_center_of_mass_npy = path_to_data_arrays_folder / "center_of_mass" / "total_body_center_of_mass_xyz.npy"- path_to_body_segment_centers_npy = path_to_data_arrays_folder / "center_of_mass" / "segmentCOM_frame_joint_xyz.npy"+ path_to_body_segment_centers_npy = (+ path_to_data_arrays_folder / "center_of_mass" / "segmentCOM_frame_joint_xyz.npy"+ )mediapipe_body_fr_mar_xyz = np.load(str(path_to_body_npy)) / 1000 # load and convert to metersmediapipe_right_hand_fr_mar_xyz = np.load(str(path_to_right_hand_npy)) / 1000@@ -62,7 +65,7 @@ def main(recording_path: Union[str, Path],# load reprojection errorpath_to_reprojection_error_npy = (- path_to_data_arrays_folder / "raw_data" / "mediapipe3dData_numFrames_numTrackedPoints_reprojectionError.npy"+ path_to_data_arrays_folder / "raw_data" / "mediapipe3dData_numFrames_numTrackedPoints_reprojectionError.npy")mediapipe_reprojection_error_fr_mar = np.load(str(path_to_reprojection_error_npy))@@ -105,10 +108,12 @@ def main(recording_path: Union[str, Path],############################### Load mocap data as empty markers- print("_________________________\n"- "__________________________\n"- "Loading freemocap trajectory data as empty markers..."- "_________________________\n")+ print(+ "_________________________\n"+ "__________________________\n"+ "Loading freemocap trajectory data as empty markers..."+ "_________________________\n"+ )mediapipe_body_trajectory_names = [empty_name for empty_name in mediapipe_empty_names["body"]]@@ -117,8 +122,7 @@ def main(recording_path: Union[str, Path],# mediapipe_face_trajectory_names = [f"face_{number}:{empty_name}" for number, empty_name in# face_contour_marker_indices]- try: #load as much of the data as you can, but if there's an error keep going-+ try: # load as much of the data as you can, but if there's an error keep going# create empty markers for bodybody_empty_scale = 0.03for marker_number in range(mediapipe_body_fr_mar_xyz.shape[1]):@@ -133,7 +137,7 @@ def main(recording_path: Union[str, Path],)# create empty markers for right hand- hand_empty_scale = body_empty_scale * 0.5+ hand_empty_scale = body_empty_scale * 0.5for marker_number in range(mediapipe_right_hand_fr_mar_xyz.shape[1]):trajectory_name = mediapipe_right_hand_trajectory_names[marker_number]trajectory_fr_xyz = mediapipe_right_hand_fr_mar_xyz[:, marker_number, :]@@ -173,12 +177,12 @@ def main(recording_path: Union[str, Path],# create empty markers for full body center of massfull_body_center_of_mass_empty_scale = body_empty_scale * 1.5create_keyframed_empty_from_3d_trajectory_data(- trajectory_fr_xyz=center_of_mass_fr_xyz,- trajectory_name=FULL_BODY_CENTER_OF_MASS_NAME,- parent_origin=freemocap_origin_axes,- empty_scale=full_body_center_of_mass_empty_scale,- empty_type="SPHERE",- )+ trajectory_fr_xyz=center_of_mass_fr_xyz,+ trajectory_name=FULL_BODY_CENTER_OF_MASS_NAME,+ parent_origin=freemocap_origin_axes,+ empty_scale=full_body_center_of_mass_empty_scale,+ empty_type="SPHERE",+ )# # create empty markers for face# face_empty_scale = 0.005@@ -202,9 +206,7 @@ def main(recording_path: Union[str, Path],######################################################################## %% create virtual markers- print("_________________________\n"- "-------------------------\n"- "Creating virtual markers...")+ print("_________________________\n" "-------------------------\n" "Creating virtual markers...")# verify that the virtual marker definition dictionary is validtest_virtual_marker_definitions(mediapipe_virtual_marker_definitions_dict)@@ -217,7 +219,8 @@ def main(recording_path: Union[str, Path],print(f"Calculating virtual marker trajectory: {virtual_marker_name} \n"f"Component trajectories: {component_trajectory_names} \n"- f" weights: {trajectory_weights}\n")+ f" weights: {trajectory_weights}\n"+ )virtual_marker_xyz = calculate_virtual_marker_trajectory(trajectory_3d_frame_marker_xyz=mediapipe_body_fr_mar_xyz,@@ -239,14 +242,14 @@ def main(recording_path: Union[str, Path],######################################################################## put sphere meshes on empty markers for visualization- try: # try to create sphere meshes on empty markers, if it fails, print the error and continue+ try: # try to create sphere meshes on empty markers, if it fails, print the error and continue# bodyput_sphere_meshes_on_empties(empty_names_list=mediapipe_body_trajectory_names,parent_object=freemocap_origin_axes,- sphere_scale=body_empty_scale*0.8,+ sphere_scale=body_empty_scale * 0.8,marker_type="body",- color = '#33FF66'+ color="#33FF66",)# create_stick_meshes_between_emtpies(@@ -260,17 +263,17 @@ def main(recording_path: Union[str, Path],put_sphere_meshes_on_empties(empty_names_list=mediapipe_right_hand_trajectory_names,parent_object=freemocap_origin_axes,- sphere_scale=hand_empty_scale*0.8,+ sphere_scale=hand_empty_scale * 0.8,marker_type="right_hand",- color='#FF0000'+ color="#FF0000",)put_sphere_meshes_on_empties(empty_names_list=mediapipe_left_hand_trajectory_names,parent_object=freemocap_origin_axes,- sphere_scale=hand_empty_scale*0.8,+ sphere_scale=hand_empty_scale * 0.8,marker_type="left_hand",- color='#0000FF'+ color="#0000FF",)# # face@@ -283,20 +286,18 @@ def main(recording_path: Union[str, Path],put_sphere_meshes_on_empties(empty_names_list=BODY_SEGMENT_NAMES,parent_object=freemocap_origin_axes,- sphere_scale=body_segment_center_empty_scale*0.8,+ sphere_scale=body_segment_center_empty_scale * 0.8,marker_type="body_segment_center",- color='#CCCC00'-+ color="#CCCC00",)put_sphere_meshes_on_empties(empty_names_list=[FULL_BODY_CENTER_OF_MASS_NAME],parent_object=freemocap_origin_axes,- sphere_scale=body_empty_scale*1.25,+ sphere_scale=body_empty_scale * 1.25,marker_type="center_of_mass",- color='#FF00FF',+ color="#FF00FF",emission_strength=30,-)except Exception as e:print(f"Error creating sphere meshes on empties: {e}")@@ -352,17 +353,15 @@ def main(recording_path: Union[str, Path],human_metarig = bpy.context.editable_objects[-1]human_metarig.data.display_type = "WIRE"-##################### Scale armaturebpy.ops.object.mode_set(mode="EDIT")for (- segment_name,- rigify_bones_list,+ segment_name,+ rigify_bones_list,) in rigify_bone_to_skeleton_segment_name_correspondance.items():-for rigify_bone_name in rigify_bones_list:median_segment_length = skeleton_segment_lengths_dict[segment_name]["median"]median_segment_length *= 0.001 # scale to meters@@ -373,19 +372,21 @@ def main(recording_path: Union[str, Path],print(f"setting {rigify_bone_name} length to: {segment_length:.3f} m")human_metarig.data.edit_bones[rigify_bone_name].length = segment_length- delete_bones = ["pelvis.L",- "pelvis.R",- "breast.L",- "breast.R",- "heel.02.L",- "heel.02.R",- "toe.L",- "toe.R", ]+ delete_bones = [+ "pelvis.L",+ "pelvis.R",+ "breast.L",+ "breast.R",+ "heel.02.L",+ "heel.02.R",+ "toe.L",+ "toe.R",+ ]for bone in delete_bones:human_metarig.data.edit_bones.remove(human_metarig.data.edit_bones[bone])- extra_scale_bones = {"spine.005": .2}+ extra_scale_bones = {"spine.005": 0.2}for bone, scale in extra_scale_bones.items():human_metarig.data.edit_bones[bone].length *= scale@@ -411,7 +412,6 @@ def main(recording_path: Union[str, Path],"____________________________________________________________________________",)-except Exception as e:print("Error creating rig!! (You might need to manually activate the `rigify` addon in Blender)")print(e)@@ -432,7 +432,6 @@ def main(recording_path: Union[str, Path],# human_metarig.hide_set = Truebpy.ops.wm.save_as_mainfile(filepath=str(blender_file_save_path))-print("____________________________________________________________________________\n","____________________________________________________________________________\n",@@ -450,8 +449,8 @@ def add_videos_to_scene(videos_path: Union[Path, str], parent_object: bpy.types.number_of_videos = len(list(get_video_paths(videos_path)))print(f"Found {number_of_videos} videos in {videos_path}")for (- video_number,- video_path,+ video_number,+ video_path,) in enumerate(get_video_paths(videos_path)):print(f"Adding video: {video_path.name} to scene")@@ -479,11 +478,11 @@ def add_videos_to_scene(videos_path: Union[Path, str], parent_object: bpy.types.def create_keyframed_empty_from_3d_trajectory_data(- trajectory_fr_xyz: np.ndarray,- trajectory_name: str,- parent_origin: bpy.types.Object = None,- empty_scale: float = 0.1,- empty_type: str = "PLAIN_AXES",+ trajectory_fr_xyz: np.ndarray,+ trajectory_name: str,+ parent_origin: bpy.types.Object = None,+ empty_scale: float = 0.1,+ empty_type: str = "PLAIN_AXES",):"""Create a key framed empty from 3d trajectory data@@ -507,10 +506,11 @@ def create_keyframed_empty_from_3d_trajectory_data(empty_object.keyframe_insert(data_path="location", frame=frame_number)--def create_material(name: str = "Generic",- color: Union[str, Tuple, List] = "#00FFFF",- emission_strength: float = 1.0,):+def create_material(+ name: str = "Generic",+ color: Union[str, Tuple, List] = "#00FFFF",+ emission_strength: float = 1.0,+):"""Create a material with the given name and color, with a strong emission.@@ -527,10 +527,10 @@ def create_material(name: str = "Generic",nodes.clear()# Create necessary nodes- output = nodes.new(type='ShaderNodeOutputMaterial')- emission = nodes.new(type='ShaderNodeEmission')- bsdf = nodes.new(type='ShaderNodeBsdfPrincipled')- mix = nodes.new(type='ShaderNodeMixShader')+ output = nodes.new(type="ShaderNodeOutputMaterial")+ emission = nodes.new(type="ShaderNodeEmission")+ bsdf = nodes.new(type="ShaderNodeBsdfPrincipled")+ mix = nodes.new(type="ShaderNodeMixShader")# Set the locationsoutput.location = (300, 0)@@ -545,7 +545,7 @@ def create_material(name: str = "Generic",# Convert color from hex to RGBif isinstance(color, str) and color.startswith("#"):- color_rgb = [int(color[i:i+2], 16) / 255 for i in (1, 3, 5)] # skips the "#" and separates R, G, and B+ color_rgb = [int(color[i : i + 2], 16) / 255 for i in (1, 3, 5)] # skips the "#" and separates R, G, and Belif isinstance(color, list) or isinstance(color, tuple):color_rgb = color@@ -558,15 +558,15 @@ def create_material(name: str = "Generic",return material-def put_sphere_meshes_on_empties(- empty_names_list: list,- parent_object: bpy.types.Object,- sphere_scale: float = 0.02,- material: Union[bpy.types.Material, str] = None,- color: str = "#00FFFF",- marker_type: str = "generic",- emission_strength: float = 1.0,+def put_sphere_meshes_on_empties(+ empty_names_list: list,+ parent_object: bpy.types.Object,+ sphere_scale: float = 0.02,+ material: Union[bpy.types.Material, str] = None,+ color: str = "#00FFFF",+ marker_type: str = "generic",+ emission_strength: float = 1.0,):"""Put uv sphere meshes on the empties in `empty_names_list` with a scale of `sphere_scale`.@@ -578,10 +578,11 @@ def put_sphere_meshes_on_empties("""# If material is None, create a default materialif material is None:- material = create_material(color=color,- name=marker_type,- emission_strength=emission_strength,- )+ material = create_material(+ color=color,+ name=marker_type,+ emission_strength=emission_strength,+ )# Ensure the provided material is a bpy.types.Material objectassert isinstance(material, bpy.types.Material), "Material must be a bpy.types.Material object or a color string"@@ -596,10 +597,13 @@ def put_sphere_meshes_on_empties(constraint = sphere.constraints.new(type="COPY_LOCATION")constraint.target = bpy.data.objects[empty_name]-def create_stick_meshes_between_emtpies(body_frame_marker_xyz: np.ndarray,- empty_names: List[str],- body_connections: Dict[int, int],- parent_object: bpy.types.Object, ):++def create_stick_meshes_between_emtpies(+ body_frame_marker_xyz: np.ndarray,+ empty_names: List[str],+ body_connections: Dict[int, int],+ parent_object: bpy.types.Object,+):"""make cylinder meshes between the empties as defined in `body_connections`"""for origin_marker_index, target_marker_index in body_connections.items():origin_marker_name = empty_names[origin_marker_index]@@ -619,36 +623,40 @@ def create_stick_meshes_between_emtpies(body_frame_marker_xyz: np.ndarray,for frame_number in range(body_frame_marker_xyz.shape[0]):distance_between_markers = np.linalg.norm(- body_frame_marker_xyz[frame_number, origin_marker_index, :] -- body_frame_marker_xyz[frame_number, target_marker_index, :]+ body_frame_marker_xyz[frame_number, origin_marker_index, :]+ - body_frame_marker_xyz[frame_number, target_marker_index, :])stick.scale = [1, 1, distance_between_markers]stick.keyframe_insert(data_path="scale", frame=frame_number)-def create_stick_mesh(vertices: int = 12,- radius: float = 0.02,- depth: float = 1.0,- location=(0, 0, 0),- rotation=(0, 0, 0),- scale=(1, 1, 1),- end_fill_type='TRIFAN',- enter_editmode=False,- align='WORLD'):- bpy.ops.mesh.primitive_cylinder_add(radius=radius,- depth=depth,- vertices=vertices,- location=location,- rotation=rotation,- scale=scale,- end_fill_type=end_fill_type,- enter_editmode=enter_editmode,- align=align)+def create_stick_mesh(+ vertices: int = 12,+ radius: float = 0.02,+ depth: float = 1.0,+ location=(0, 0, 0),+ rotation=(0, 0, 0),+ scale=(1, 1, 1),+ end_fill_type="TRIFAN",+ enter_editmode=False,+ align="WORLD",+):+ bpy.ops.mesh.primitive_cylinder_add(+ radius=radius,+ depth=depth,+ vertices=vertices,+ location=location,+ rotation=rotation,+ scale=scale,+ end_fill_type=end_fill_type,+ enter_editmode=enter_editmode,+ align=align,+ )# give 3dcursor new coordinatesbpy.context.scene.cursor.location = (0.0, 0.0, -0.5)# set the origin on the current object to the 3dcursor location- bpy.ops.object.origin_set(type='ORIGIN_CURSOR')+ bpy.ops.object.origin_set(type="ORIGIN_CURSOR")return bpy.context.editable_objects[-1]@@ -657,8 +665,8 @@ def apply_constraints_to_bone(bone_name: str, bone_constraint_dict: dict, armatuApply constraints to a bone (that exists in `armature_rig` based on a dictionary of constraints"""for (- constraint_name,- constrain_parameters_dict,+ constraint_name,+ constrain_parameters_dict,) in bone_constraint_dict.items():constraint_name = constraint_name.split(".")[0@@ -673,7 +681,6 @@ def apply_constraints_to_bone(bone_name: str, bone_constraint_dict: dict, armatu# generic constraint settingsif "target" in constrain_parameters_dict:-if constrain_parameters_dict["target"] == "armature":constraint.target = armature_rigconstraint.subtarget = constrain_parameters_dict["subtarget"]@@ -712,22 +719,22 @@ def test_virtual_marker_definitions(virtual_marker_definitions_dict: dict):"""for (- virtual_marker_name,- virtual_marker_definition,+ virtual_marker_name,+ virtual_marker_definition,) in virtual_marker_definitions_dict.items():assert len(virtual_marker_definition["marker_names"]) == len(virtual_marker_definition["marker_weights"]), f"marker_names and marker_weights must be the same length for virtual marker {virtual_marker_name}"assert (- sum(virtual_marker_definition["marker_weights"]) == 1+ sum(virtual_marker_definition["marker_weights"]) == 1), f"marker_weights must sum to 1 for virtual marker {virtual_marker_name}"def calculate_virtual_marker_trajectory(- trajectory_3d_frame_marker_xyz: np.ndarray,- all_trajectory_names: list,- component_trajectory_names: List,- trajectory_weights: List,+ trajectory_3d_frame_marker_xyz: np.ndarray,+ all_trajectory_names: list,+ component_trajectory_names: List,+ trajectory_weights: List,) -> np.ndarray:"""Create a virtual marker from a set of component markers. A 'Virtual Marker' is a 'fake' marker created by combining the data from 'real' (measured) marker/trajectory data@@ -739,14 +746,16 @@ def calculate_virtual_marker_trajectory(# double check that the weights scale to one, otherwise this function will return screwy resultsassert np.sum(trajectory_weights) == 1, "Error - Trajectory_weights must sum to 1!"- assert len(component_trajectory_names) == len(trajectory_weights), \- "Error - component_trajectory_names and trajectory_weights must be the same length!"+ assert len(component_trajectory_names) == len(+ trajectory_weights+ ), "Error - component_trajectory_names and trajectory_weights must be the same length!"virtual_marker_xyz = np.zeros((trajectory_3d_frame_marker_xyz.shape[0], 3))for trajectory_name, weight in zip(component_trajectory_names, trajectory_weights):# pull out the trajectory data for this component trajectory and scale by it's `weight`component_trajectory_xyz = copy(- trajectory_3d_frame_marker_xyz[:, all_trajectory_names.index(trajectory_name), :] * weight)+ trajectory_3d_frame_marker_xyz[:, all_trajectory_names.index(trajectory_name), :] * weight+ )# add it to the virtual markervirtual_marker_xyz += component_trajectory_xyz@@ -754,12 +763,14 @@ def calculate_virtual_marker_trajectory(return virtual_marker_xyz-def creating_stick_figure_mesh_from_bone_dictionary(trajectory_frame_marker_xyz: np.ndarray,- body_connections: Dict[int, int]):+def creating_stick_figure_mesh_from_bone_dictionary(+ trajectory_frame_marker_xyz: np.ndarray, body_connections: Dict[int, int]+):print("creating_stick_figure_mesh_from_bone_dictionary")assert (- len(trajectory_frame_marker_xyz.shape) == 3), "trajectory_frame_marker_xyz must have three axes - [frame, marker, xyz] (e.g. skeleton data from a single frame"+ len(trajectory_frame_marker_xyz.shape) == 3+ ), "trajectory_frame_marker_xyz must have three axes - [frame, marker, xyz] (e.g. skeleton data from a single frame"mesh = bpy.data.meshes.new("stick_figure_mesh")init_zero_vertices = np.zeros((trajectory_frame_marker_xyz.shape[1], 3))@@ -772,9 +783,9 @@ def creating_stick_figure_mesh_from_bone_dictionary(trajectory_frame_marker_xyz:mesh.validate(verbose=True)mesh.update()- skin_radius = .025+ skin_radius = 0.025print(f"Skinning stick figure mesh with radius {skin_radius}...")- bpy.data.objects['stick_figure_mesh'].modifiers.new('stick_figure_mesh_skin', 'SKIN')+ bpy.data.objects["stick_figure_mesh"].modifiers.new("stick_figure_mesh_skin", "SKIN")bpy.ops.transform.skin_resize(value=(skin_radius, skin_radius, skin_radius))for frame_number in range(trajectory_frame_marker_xyz.shape[0]):@@ -783,6 +794,7 @@ def creating_stick_figure_mesh_from_bone_dictionary(trajectory_frame_marker_xyz:vertex.keyframe_insert(data_path="co", frame=frame_number) # keyframe the vertex locationmesh.update()+def get_video_paths(path_to_video_folder: Path) -> list:"""Search the folder for 'mp4' files (case insensitive) and return them as a list"""@@ -804,118 +816,244 @@ def get_unique_list(list: list) -> list:mediapipe_empty_names = {# generated by: freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_names_and_connections.py- 'body': ['nose',- 'left_eye_inner',- 'left_eye',- 'left_eye_outer',- 'right_eye_inner',- 'right_eye',- 'right_eye_outer',- 'left_ear',- 'right_ear',- 'mouth_left',- 'mouth_right',- 'left_shoulder',- 'right_shoulder',- 'left_elbow',- 'right_elbow',- 'left_wrist',- 'right_wrist',- 'left_pinky',- 'right_pinky',- 'left_index',- 'right_index',- 'left_thumb',- 'right_thumb',- 'left_hip',- 'right_hip',- 'left_knee',- 'right_knee',- 'left_ankle',- 'right_ankle',- 'left_heel',- 'right_heel',- 'left_foot_index',- 'right_foot_index'],- 'hand': ['wrist',- 'thumb_cmc',- 'thumb_mcp',- 'thumb_ip',- 'thumb_tip',- 'index_finger_mcp',- 'index_finger_pip',- 'index_finger_dip',- 'index_finger_tip',- 'middle_finger_mcp',- 'middle_finger_pip',- 'middle_finger_dip',- 'middle_finger_tip',- 'ring_finger_mcp',- 'ring_finger_pip',- 'ring_finger_dip',- 'ring_finger_tip',- 'pinky_mcp',- 'pinky_pip',- 'pinky_dip',- 'pinky_tip'],-- 'face': ['right_eye',- 'left_eye',- 'nose_tip',- 'mouth_center',- 'right_ear_tragion',- 'left_ear_tragion']}+ "body": [+ "nose",+ "left_eye_inner",+ "left_eye",+ "left_eye_outer",+ "right_eye_inner",+ "right_eye",+ "right_eye_outer",+ "left_ear",+ "right_ear",+ "mouth_left",+ "mouth_right",+ "left_shoulder",+ "right_shoulder",+ "left_elbow",+ "right_elbow",+ "left_wrist",+ "right_wrist",+ "left_pinky",+ "right_pinky",+ "left_index",+ "right_index",+ "left_thumb",+ "right_thumb",+ "left_hip",+ "right_hip",+ "left_knee",+ "right_knee",+ "left_ankle",+ "right_ankle",+ "left_heel",+ "right_heel",+ "left_foot_index",+ "right_foot_index",+ ],+ "hand": [+ "wrist",+ "thumb_cmc",+ "thumb_mcp",+ "thumb_ip",+ "thumb_tip",+ "index_finger_mcp",+ "index_finger_pip",+ "index_finger_dip",+ "index_finger_tip",+ "middle_finger_mcp",+ "middle_finger_pip",+ "middle_finger_dip",+ "middle_finger_tip",+ "ring_finger_mcp",+ "ring_finger_pip",+ "ring_finger_dip",+ "ring_finger_tip",+ "pinky_mcp",+ "pinky_pip",+ "pinky_dip",+ "pinky_tip",+ ],+ "face": ["right_eye", "left_eye", "nose_tip", "mouth_center", "right_ear_tragion", "left_ear_tragion"],+}# NOTE - numbers refer to the index of the name in the relevant list above-body_connections = {15: 19,- 16: 18,- 18: 20,- 3: 7,- 14: 16,- 23: 24,- 28: 32,- 11: 12,- 27: 29,- 6: 8,- 24: 26,- 4: 5,- 5: 6,- 29: 31,- 12: 14,- 0: 4,- 9: 10,- 1: 2,- 30: 32,- 25: 27,- 26: 28,- 17: 19,- 2: 3,- 13: 15}--hand_connections = {3: 4,- 0: 1,- 17: 18,- 13: 17,- 18: 19,- 5: 9,- 14: 15,- 9: 13,- 1: 2,- 10: 11,- 19: 20,- 6: 7,- 15: 16,- 2: 3,- 11: 12,- 7: 8}+body_connections = {+ 15: 19,+ 16: 18,+ 18: 20,+ 3: 7,+ 14: 16,+ 23: 24,+ 28: 32,+ 11: 12,+ 27: 29,+ 6: 8,+ 24: 26,+ 4: 5,+ 5: 6,+ 29: 31,+ 12: 14,+ 0: 4,+ 9: 10,+ 1: 2,+ 30: 32,+ 25: 27,+ 26: 28,+ 17: 19,+ 2: 3,+ 13: 15,+}++hand_connections = {+ 3: 4,+ 0: 1,+ 17: 18,+ 13: 17,+ 18: 19,+ 5: 9,+ 14: 15,+ 9: 13,+ 1: 2,+ 10: 11,+ 19: 20,+ 6: 7,+ 15: 16,+ 2: 3,+ 11: 12,+ 7: 8,+}# boy howdy mediapipe did not make it easy to get this info...-face_contour_marker_indices = [0, 7, 10, 13, 14, 17, 21, 33, 37, 39, 40, 46, 52, 53, 54, 55, 58, 61, 63, 65, 66, 67, 70,- 78, 80, 81, 82, 84, 87, 88, 91, 93, 95, 103, 105, 107, 109, 127, 132, 133, 136, 144, 145,- 146, 148, 149, 150, 152, 153, 154, 155, 157, 158, 159, 160, 161, 162, 163, 172, 173, 176,- 178, 181, 185, 191, 234, 246, 249, 251, 263, 267, 269, 270, 276, 282, 283, 284, 285, 288,- 291, 293, 295, 296, 297, 300, 308, 310, 311, 312, 314, 317, 318, 321, 323, 324, 332, 334,- 336, 338, 356, 361, 362, 365, 373, 374, 375, 377, 378, 379, 380, 381, 382, 384, 385, 386,- 387, 388, 389, 390, 397, 398, 400, 402, 405, 409, 415, 454, 466]+face_contour_marker_indices = [+ 0,+ 7,+ 10,+ 13,+ 14,+ 17,+ 21,+ 33,+ 37,+ 39,+ 40,+ 46,+ 52,+ 53,+ 54,+ 55,+ 58,+ 61,+ 63,+ 65,+ 66,+ 67,+ 70,+ 78,+ 80,+ 81,+ 82,+ 84,+ 87,+ 88,+ 91,+ 93,+ 95,+ 103,+ 105,+ 107,+ 109,+ 127,+ 132,+ 133,+ 136,+ 144,+ 145,+ 146,+ 148,+ 149,+ 150,+ 152,+ 153,+ 154,+ 155,+ 157,+ 158,+ 159,+ 160,+ 161,+ 162,+ 163,+ 172,+ 173,+ 176,+ 178,+ 181,+ 185,+ 191,+ 234,+ 246,+ 249,+ 251,+ 263,+ 267,+ 269,+ 270,+ 276,+ 282,+ 283,+ 284,+ 285,+ 288,+ 291,+ 293,+ 295,+ 296,+ 297,+ 300,+ 308,+ 310,+ 311,+ 312,+ 314,+ 317,+ 318,+ 321,+ 323,+ 324,+ 332,+ 334,+ 336,+ 338,+ 356,+ 361,+ 362,+ 365,+ 373,+ 374,+ 375,+ 377,+ 378,+ 379,+ 380,+ 381,+ 382,+ 384,+ 385,+ 386,+ 387,+ 388,+ 389,+ 390,+ 397,+ 398,+ 400,+ 402,+ 405,+ 409,+ 415,+ 454,+ 466,+]mediapipe_virtual_marker_definitions_dict = {"head_center": {@@ -1054,12 +1192,13 @@ BODY_SEGMENT_NAMES = []-FULL_BODY_CENTER_OF_MASS_NAME = "_full_body_center_of_mass" #leading underscore to make it easier to find in the outliner+FULL_BODY_CENTER_OF_MASS_NAME = (+ "_full_body_center_of_mass" # leading underscore to make it easier to find in the outliner+)print(f"__name__: {__name__}")if __name__ == "__main__" or __name__ == "<run_path>":-# this is the part that actually runs the scriptargv = sys.argvcreate_rig_input = True@@ -1069,7 +1208,7 @@ if __name__ == "__main__" or __name__ == "<run_path>":# Session path# get session path as command line argumentprint(f"Received command line arguments: {argv}")- argv = argv[argv.index("--") + 1:]+ argv = argv[argv.index("--") + 1 :]recording_path_input = Path(argv[0])blender_file_save_path_input = Path(argv[1])@@ -1078,7 +1217,6 @@ if __name__ == "__main__" or __name__ == "<run_path>":print(f"There was a problem loading command line arguments: {e}. Using hardcoded values instead.")if len(argv) == 0:-##### Change the path below (`recording_path_input`) to the path to your recording session folder####@@ -1088,11 +1226,15 @@ if __name__ == "__main__" or __name__ == "<run_path>":blender_file_save_path_input = Path(recording_path_input) / f"{Path(recording_path_input).name}_.blend"create_rig = True- print(f"recording_path_input: {recording_path_input}, \n"- f"blender_file_save_path_input: {blender_file_save_path_input}, \n"- f"create_rig_input: {create_rig_input}")+ print(+ f"recording_path_input: {recording_path_input}, \n"+ f"blender_file_save_path_input: {blender_file_save_path_input}, \n"+ f"create_rig_input: {create_rig_input}"+ )- main(recording_path=recording_path_input,- blender_file_save_path=blender_file_save_path_input,- mediapipe_empty_names=mediapipe_empty_names,- create_rig=create_rig_input,)+ main(+ recording_path=recording_path_input,+ blender_file_save_path=blender_file_save_path_input,+ mediapipe_empty_names=mediapipe_empty_names,+ create_rig=create_rig_input,+ )diff --git a/freemocap/data_layer/export_data/blender_stuff/export_to_blender.py b/freemocap/data_layer/export_data/blender_stuff/export_to_blender.pyindex d4994f66..48d847bc 100644--- a/freemocap/data_layer/export_data/blender_stuff/export_to_blender.py+++ b/freemocap/data_layer/export_data/blender_stuff/export_to_blender.py@@ -20,7 +20,6 @@ def export_to_blender(blender_exe_path: Union[str, Path],method: str = "megascript_take2",):-logger.info(f"Exporting session data to a Blender scene at: {str(blender_file_path)} using Blender executable at {str(blender_exe_path)}")@@ -48,8 +47,5 @@ def export_to_blender(if __name__ == "__main__":-recording_path = r"D:\Dropbox\FreeMoCapProject\FreeMocap_Data\old\sesh_2022-09-19_16_16_50_in_class_jsm"- export_to_blender(recording_path,- recording_path,- get_best_guess_of_blender_path())+ export_to_blender(recording_path, recording_path, get_best_guess_of_blender_path())diff --git a/freemocap/data_layer/export_data/blender_stuff/get_best_guess_of_blender_path.py b/freemocap/data_layer/export_data/blender_stuff/get_best_guess_of_blender_path.pyindex b133b0da..a6af237f 100644--- a/freemocap/data_layer/export_data/blender_stuff/get_best_guess_of_blender_path.py+++ b/freemocap/data_layer/export_data/blender_stuff/get_best_guess_of_blender_path.py@@ -16,7 +16,6 @@ def guess_blender_exe_path_from_path(base_path: Union[str, Path]) -> Path:def get_best_guess_of_blender_path():if platform.system() == "Windows":-base_path = Path(r"C:\Program Files\Blender Foundation")blender_exe_path = guess_blender_exe_path_from_path(base_path)@@ -36,9 +35,8 @@ def get_best_guess_of_blender_path():return Noneif platform.system() == "Darwin":-blender_app_path = Path("/Applications/Blender.app")-+if blender_app_path.exists():logger.info(f"Mac machine detected - guessing that `blender` is installed at: {str(blender_app_path)}")@@ -49,7 +47,7 @@ def get_best_guess_of_blender_path():f"Could not find Blender executable in the applications folder. Please locate it manually (or install Blender, if it isn't installed).")return None-+if platform.system() == "Linux":blender_path_list = [Path("/usr/bin"),@@ -66,11 +64,12 @@ def get_best_guess_of_blender_path():logger.info(f"Linux machine detected - guessing that `blender` is installed at: {str(blender_path)}")return str(blender_path)-- logger.info(f"Could not find Blender executable in bin. Please locate it manually (or install Blender, if it isn't installed).")++ logger.info(+ f"Could not find Blender executable in bin. Please locate it manually (or install Blender, if it isn't installed)."+ )return Noneelse:logger.info(f"Machine system not detected, please locate Blender path manually.")return None-diff --git a/freemocap/data_layer/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py b/freemocap/data_layer/export_data/generate_jupyter_notebook/generate_jupyter_notebook.pyindex 847e34b5..731427c1 100644--- a/freemocap/data_layer/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py+++ b/freemocap/data_layer/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py@@ -4,7 +4,7 @@ from typing import Unionimport papermill as pm-logging.getLogger('papermill').setLevel(logging.WARNING)+logging.getLogger("papermill").setLevel(logging.WARNING)logger = logging.getLogger(__name__)@@ -14,13 +14,13 @@ def generate_jupyter_notebook(path_to_recording: Union[str, Path]):path_to_output_notebook = Path(path_to_recording) / f"{recording_name}.ipynb"logger.info(f"Jupyter notebook generated at {path_to_output_notebook}")- success = pm.execute_notebook(+ success = pm.execute_notebook(input_path=path_to_template_notebook,output_path=path_to_output_notebook,- parameters=dict(path_to_recording=str(path_to_recording))+ parameters=dict(path_to_recording=str(path_to_recording)),)-if __name__ == '__main__':- path_to_recording = r'C:\Users\aaron\FreeMocap_Data\recording_sessions\recording_15_19_00_gmt-4__brit_baseline'+if __name__ == "__main__":+ path_to_recording = r"C:\Users\aaron\FreeMocap_Data\recording_sessions\recording_15_19_00_gmt-4__brit_baseline"generate_jupyter_notebook(path_to_recording)diff --git a/freemocap/data_layer/recording_models/recording_info_model.py b/freemocap/data_layer/recording_models/recording_info_model.pyindex 2a09d231..e787e4de 100644--- a/freemocap/data_layer/recording_models/recording_info_model.py+++ b/freemocap/data_layer/recording_models/recording_info_model.py@@ -14,7 +14,8 @@ from freemocap.system.paths_and_filenames.file_and_folder_names import (MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME,SYNCHRONIZED_VIDEOS_FOLDER_NAME,ANNOTATED_VIDEOS_FOLDER_NAME,- MEDIAPIPE_3D_NPY_FILE_NAME, )+ MEDIAPIPE_3D_NPY_FILE_NAME,+)from freemocap.system.paths_and_filenames.path_getters import create_camera_calibration_file_name, get_blender_file_pathfrom freemocap.tests.test_image_tracking_data_shape import test_image_tracking_data_shapefrom freemocap.tests.test_mediapipe_skeleton_data_shape import test_mediapipe_skeleton_data_shape@@ -26,19 +27,24 @@ logger = logging.getLogger(__name__)class RecordingInfoModel:def __init__(- self,- recording_folder_path: Union[Path, str],+ self,+ recording_folder_path: Union[Path, str],):- if any([Path(recording_folder_path).name == SYNCHRONIZED_VIDEOS_FOLDER_NAME,+ if any(+ [+ Path(recording_folder_path).name == SYNCHRONIZED_VIDEOS_FOLDER_NAME,Path(recording_folder_path).name == ANNOTATED_VIDEOS_FOLDER_NAME,- Path(recording_folder_path).name == OUTPUT_DATA_FOLDER_NAME]):+ Path(recording_folder_path).name == OUTPUT_DATA_FOLDER_NAME,+ ]+ ):recording_folder_path = Path(recording_folder_path).parentself._path = Path(recording_folder_path)self._name = self._path.nameself._calibration_toml_path = str(- Path(self._path) / create_camera_calibration_file_name(recording_name=self._name))+ Path(self._path) / create_camera_calibration_file_name(recording_name=self._name)+ )self._recording_folder_status_checker = RecordingFolderStatusChecker(recording_info_model=self)@@ -137,27 +143,23 @@ class RecordingInfoModel:return self._recording_folder_status_checker.check_center_of_mass_data_status()---class RecordingFolderStatusChecker:def __init__(self, recording_info_model: RecordingInfoModel):-self.recording_info_model = recording_info_model@propertydef status_check(self) -> Dict[str, Union[bool, str, float]]:return {- 'synchronized_videos_status_check': self.check_synchronized_videos_status(),- 'data2d_status_check': self.check_data2d_status(),- 'data3d_status_check': self.check_data3d_status(),- 'center_of_mass_data_status_check': self.check_center_of_mass_data_status(),- 'blender_file_status_check': self.check_blender_file_status(),- 'video_and_camera_info': {- 'number_of_synchronized_videos': self.get_number_of_mp4s_in_synched_videos_directory(),- 'number_of_frames_in_videos': self.get_number_of_frames_in_videos(),+ "synchronized_videos_status_check": self.check_synchronized_videos_status(),+ "data2d_status_check": self.check_data2d_status(),+ "data3d_status_check": self.check_data3d_status(),+ "center_of_mass_data_status_check": self.check_center_of_mass_data_status(),+ "blender_file_status_check": self.check_blender_file_status(),+ "video_and_camera_info": {+ "number_of_synchronized_videos": self.get_number_of_mp4s_in_synched_videos_directory(),+ "number_of_frames_in_videos": self.get_number_of_frames_in_videos(),# 'camera_rotation_and_translation': self.get_camera_rotation_and_translation_from_calibration_toml()- }+ },}def check_synchronized_videos_status(self) -> bool:@@ -168,7 +170,6 @@ class RecordingFolderStatusChecker:return Falsedef check_data2d_status(self) -> bool:-try:test_image_tracking_data_shape(synchronized_video_folder_path=self.recording_info_model.synchronized_videos_folder_path,@@ -188,7 +189,6 @@ class RecordingFolderStatusChecker:)return Trueexcept AssertionError as e:-return Falsedef check_center_of_mass_data_status(self) -> bool:@@ -215,7 +215,7 @@ class RecordingFolderStatusChecker:return video_countfor file in synchronized_directory_path.iterdir():- if file.is_file() and file.suffix.lower() == '.mp4':+ if file.is_file() and file.suffix.lower() == ".mp4":video_count += 1logger.info(f"Number of `.mp4`'s in {self.recording_info_model.synchronized_videos_folder_path}: {video_count}")@@ -227,12 +227,12 @@ class RecordingFolderStatusChecker:if not timestamps_directory_path.exists():return "No 'timestamps' directory found"- if timestamps_directory_path.exists() :+ if timestamps_directory_path.exists():frame_counts = {}for npy_file in timestamps_directory_path.iterdir():- if npy_file.is_file() and npy_file.suffix.lower() == '.npy':+ if npy_file.is_file() and npy_file.suffix.lower() == ".npy":video_npy = np.load(str(npy_file))- frame_counts[npy_file.name] = str(len(video_npy)-1)+ frame_counts[npy_file.name] = str(len(video_npy) - 1)return frame_countsdiff --git a/freemocap/gui/qt/actions_and_menus/actions.py b/freemocap/gui/qt/actions_and_menus/actions.pyindex 9f852abc..bfeed700 100644--- a/freemocap/gui/qt/actions_and_menus/actions.py+++ b/freemocap/gui/qt/actions_and_menus/actions.py@@ -63,10 +63,14 @@ class Actions:# Helpself.open_docs_action = QAction(OPEN_DOCS_ACTION_NAME, parent=freemocap_main_window)- self.open_docs_action.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("https://freemocap.readthedocs.io/en/latest/")))-+ self.open_docs_action.triggered.connect(+ lambda: QDesktopServices.openUrl(QUrl("https://freemocap.readthedocs.io/en/latest/"))+ )+self.freemocap_foundation_action = QAction(FREEMOCAP_FOUNDATION_ACTION_NAME, parent=freemocap_main_window)- self.freemocap_foundation_action.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("https://freemocap.org/about-us.html")))+ self.freemocap_foundation_action.triggered.connect(+ lambda: QDesktopServices.openUrl(QUrl("https://freemocap.org/about-us.html"))+ )# # Navigation# show_camera_control_panel_action = QAction("&1 - Show Camera Control Panel", parent=main_window)@@ -82,6 +86,8 @@ class Actions:## Supportself.donate_action = QAction(DONATE_ACTION_NAME, parent=freemocap_main_window)- self.donate_action.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("https://freemocap.org/about-us.html#donate")))+ self.donate_action.triggered.connect(+ lambda: QDesktopServices.openUrl(QUrl("https://freemocap.org/about-us.html#donate"))+ )# self.send_usage_statistics_action = QAction("Send &User Statistics", parent=freemocap_main_window)# self.user_survey_action = QAction("&User Survey", parent=freemocap_main_window)diff --git a/freemocap/gui/qt/actions_and_menus/menu_bar.py b/freemocap/gui/qt/actions_and_menus/menu_bar.pyindex 2b7a877d..3c015bbc 100644--- a/freemocap/gui/qt/actions_and_menus/menu_bar.py+++ b/freemocap/gui/qt/actions_and_menus/menu_bar.py@@ -44,7 +44,7 @@ class MenuBar(QMenuBar):## support menusupport_menu = self.addMenu("&Support the Freemocap Project")-+support_menu.addAction(actions.donate_action)# support_menu.addAction(actions.send_usage_statistics_action)# support_menu.addAction(actions.user_survey_action)diff --git a/freemocap/gui/qt/freemocap_main.py b/freemocap/gui/qt/freemocap_main.pyindex f28fcab8..42d15cbb 100644--- a/freemocap/gui/qt/freemocap_main.py+++ b/freemocap/gui/qt/freemocap_main.py@@ -8,7 +8,7 @@ from PyQt6.QtWidgets import QApplicationfrom freemocap.gui.qt.main_window.freemocap_main_window import MainWindow, EXIT_CODE_REBOOT-logging.getLogger('matplotlib').setLevel(logging.WARNING)+logging.getLogger("matplotlib").setLevel(logging.WARNING)from freemocap.gui.qt.utilities.get_qt_app import get_qt_appfrom freemocap.system.paths_and_filenames.path_getters import get_freemocap_data_folder_path@@ -35,8 +35,9 @@ def qt_gui_main():pipedream_pings = PipedreamPings()while True:- freemocap_main_window = MainWindow(freemocap_data_folder_path=get_freemocap_data_folder_path(),- pipedream_pings=pipedream_pings)+ freemocap_main_window = MainWindow(+ freemocap_data_folder_path=get_freemocap_data_folder_path(), pipedream_pings=pipedream_pings+ )logger.info("Showing main window - Ready to start!")logger.info("Welcome to FreeMoCap πβ¨")freemocap_main_window.show()diff --git a/freemocap/gui/qt/main_window/freemocap_main_window.py b/freemocap/gui/qt/main_window/freemocap_main_window.pyindex 8a7f747d..34af65cd 100644--- a/freemocap/gui/qt/main_window/freemocap_main_window.py+++ b/freemocap/gui/qt/main_window/freemocap_main_window.py@@ -11,18 +11,22 @@ from PyQt6.QtWidgets import (QDockWidget,QMainWindow,QFileDialog,- QWidget, QHBoxLayout, )+ QWidget,+ QHBoxLayout,+)from skelly_viewer import SkellyViewerfrom skellycam import (SkellyCamParameterTreeWidget,- SkellyCamWidget, SkellyCamControllerWidget,+ SkellyCamWidget,+ SkellyCamControllerWidget,)from tqdm import tqdmfrom freemocap.data_layer.export_data.blender_stuff.export_to_blender import export_to_blenderfrom freemocap.data_layer.export_data.blender_stuff.get_best_guess_of_blender_path import get_best_guess_of_blender_path-from freemocap.data_layer.export_data.generate_jupyter_notebook.generate_jupyter_notebook import \- generate_jupyter_notebook+from freemocap.data_layer.export_data.generate_jupyter_notebook.generate_jupyter_notebook import (+ generate_jupyter_notebook,+)from freemocap.data_layer.recording_models.post_processing_parameter_models import (PostProcessingParameterModel,)@@ -62,11 +66,12 @@ from freemocap.gui.qt.utilities.save_and_load_gui_state import (GuiState,load_gui_state,)+# reboot GUI method based on this - https://stackoverflow.com/a/56563926/14662833from freemocap.system.open_file import open_filefrom freemocap.system.paths_and_filenames.file_and_folder_names import (PATH_TO_FREEMOCAP_LOGO_SVG,- FIGSHARE_SAMPLE_ZIP_FILE_URL+ FIGSHARE_SAMPLE_ZIP_FILE_URL,)from freemocap.system.paths_and_filenames.path_getters import (get_blender_file_path,@@ -75,16 +80,19 @@ from freemocap.system.paths_and_filenames.path_getters import (from freemocap.system.paths_and_filenames.path_getters import (get_blender_file_path,get_recording_session_folder_path,- get_gui_state_json_path+ get_gui_state_json_path,)-from freemocap.system.paths_and_filenames.path_getters import get_recording_session_folder_path, \- get_css_stylesheet_path, get_scss_stylesheet_path, get_blender_file_path, get_most_recent_recording_path+from freemocap.system.paths_and_filenames.path_getters import (+ get_recording_session_folder_path,+ get_css_stylesheet_path,+ get_scss_stylesheet_path,+ get_blender_file_path,+ get_most_recent_recording_path,+)from freemocap.system.user_data.pipedream_pings import PipedreamPings-from freemocap.gui.qt.workers.download_sample_data_thread_worker import (- DownloadSampleDataThreadWorker-)+from freemocap.gui.qt.workers.download_sample_data_thread_worker import DownloadSampleDataThreadWorkerfrom freemocap.utilities.remove_empty_directories import remove_empty_directoriesEXIT_CODE_REBOOT = -123456789@@ -94,16 +102,15 @@ logger = logging.getLogger(__name__)class MainWindow(QMainWindow):def __init__(- self,- freemocap_data_folder_path: Union[str, Path],- pipedream_pings: PipedreamPings,- parent=None,+ self,+ freemocap_data_folder_path: Union[str, Path],+ pipedream_pings: PipedreamPings,+ parent=None,):super().__init__(parent=parent)self._log_view_widget = LogViewWidget(parent=self) # start this first so it will grab the setup logslogger.info("Initializing FreeMoCap MainWindow")-self.setGeometry(100, 100, 1280, 720)self.setWindowIcon(QIcon(PATH_TO_FREEMOCAP_LOGO_SVG))self.setWindowTitle(f"freemocap \U0001F480 \U00002728")@@ -143,7 +150,8 @@ class MainWindow(QMainWindow):self.setMenuBar(self._menu_bar)self.statusBar().showMessage(- "Watch the terminal output for status updates, we're working on integrating better status updates into the GUI")+ "Watch the terminal output for status updates, we're working on integrating better status updates into the GUI"+ )self._central_tab_widget = self._create_central_tab_widget()self.setCentralWidget(self._central_tab_widget)@@ -204,8 +212,8 @@ class MainWindow(QMainWindow):self._active_recording_info_widget.set_active_recording(recording_folder_path=folder_path)if (- self._controller_group_box.auto_process_videos_checked- and self._controller_group_box.mocap_videos_radio_button_checked+ self._controller_group_box.auto_process_videos_checked+ and self._controller_group_box.mocap_videos_radio_button_checked):logger.info("'Auto process videos' checkbox is checked - triggering 'Process Motion Capture Data' button")self._process_motion_capture_data_panel.process_motion_capture_data_button.click()@@ -241,8 +249,9 @@ class MainWindow(QMainWindow):def _set_up_stylesheet(self):apply_css_style_sheet(self, get_css_stylesheet_path())- scss_file_watcher = SCSSFileWatcher(path_to_scss_file=get_scss_stylesheet_path(),- path_to_css_file=get_css_stylesheet_path(), parent=self)+ scss_file_watcher = SCSSFileWatcher(+ path_to_scss_file=get_scss_stylesheet_path(), path_to_css_file=get_css_stylesheet_path(), parent=self+ )css_file_watcher = CSSFileWatcher(path_to_css_file=get_css_stylesheet_path(), parent=self)return css_file_watcher@@ -253,7 +262,6 @@ class MainWindow(QMainWindow):return self._active_recording_info_widget.active_recording_info.synchronized_videos_folder_pathdef _create_central_tab_widget(self):-self._home_widget = HomeWidget(actions=self._actions, gui_state=self._gui_state, parent=self)self._skellycam_widget = SkellyCamWidget(@@ -265,9 +273,7 @@ class MainWindow(QMainWindow):)self._controller_group_box = CameraControllerGroupBox(- skellycam_widget=self._skellycam_widget,- gui_state=self._gui_state,- parent=self+ skellycam_widget=self._skellycam_widget, gui_state=self._gui_state, parent=self)self._skelly_viewer_widget = SkellyViewer()@@ -279,7 +285,7 @@ class MainWindow(QMainWindow):welcome_to_freemocap_widget=self._home_widget,skelly_viewer_widget=self._skelly_viewer_widget,directory_view_widget=self._directory_view_widget,- active_recording_info_widget=self._active_recording_info_widget+ active_recording_info_widget=self._active_recording_info_widget,)center_tab_widget.set_welcome_tab_enabled(True)@@ -329,8 +335,9 @@ class MainWindow(QMainWindow):self._handle_processing_finished_signal)- self._visualization_control_panel = VisualizationControlPanel(parent=self,- blender_executable_path=get_best_guess_of_blender_path())+ self._visualization_control_panel = VisualizationControlPanel(+ parent=self, blender_executable_path=get_best_guess_of_blender_path()+ )self._visualization_control_panel.export_to_blender_button.clicked.connect(self._export_active_recording_to_blender)@@ -364,29 +371,29 @@ class MainWindow(QMainWindow):)if (- self._controller_group_box.auto_open_in_blender_checked- # or self._visualization_control_panel.open_in_blender_automatically_box_is_checked+ self._controller_group_box.auto_open_in_blender_checked+ # or self._visualization_control_panel.open_in_blender_automatically_box_is_checked):if Path(self._active_recording_info_widget.active_recording_info.blender_file_path).exists():open_file(self._active_recording_info_widget.active_recording_info.blender_file_path)else:logger.error(- "Blender file does not exist! Did something go wrong in the `export_to_blender` call above?")+ "Blender file does not exist! Did something go wrong in the `export_to_blender` call above?"+ )def _generate_jupyter_notebook(self):logger.info("Exporting active recording to a Jupyter notebook...")recording_path = self._active_recording_info_widget.get_active_recording_info(return_path=True)# TODO: Need to include jupyter notebook in recording files that we keep track of (2023-05-15)- generate_jupyter_notebook(- path_to_recording=recording_path- )+ generate_jupyter_notebook(path_to_recording=recording_path)def _handle_new_active_recording_selected(self, recording_info_model: RecordingInfoModel):logger.info(f"New active recording selected: {recording_info_model.path}")# self._calibration_control_panel.update_calibrate_from_active_recording_button_text()- self._pipedream_pings.update_pings_dict(key=recording_info_model.name,- value=self._active_recording_info_widget.active_recording_info.status_check)+ self._pipedream_pings.update_pings_dict(+ key=recording_info_model.name, value=self._active_recording_info_widget.active_recording_info.status_check+ )path = Path(recording_info_model.path)path.mkdir(parents=True, exist_ok=True)@@ -426,7 +433,6 @@ class MainWindow(QMainWindow):video_folder_path=active_recording_info.annotated_videos_folder_path)-elif active_recording_info.synchronized_videos_status_check:self._skelly_viewer_widget.generate_video_display(video_folder_path=active_recording_info.synchronized_videos_folder_path@@ -475,10 +481,14 @@ class MainWindow(QMainWindow):self._home_widget._send_pings_checkbox.setChecked(self._gui_state.send_user_pings)self._controller_group_box._auto_process_videos_checkbox.setChecked(self._gui_state.auto_process_videos_on_save)- self._controller_group_box._generate_jupyter_notebook_checkbox.setChecked(self._gui_state.generate_jupyter_notebook)+ self._controller_group_box._generate_jupyter_notebook_checkbox.setChecked(+ self._gui_state.generate_jupyter_notebook+ )self._controller_group_box._auto_open_in_blender_checkbox.setChecked(self._gui_state.auto_open_in_blender)self._controller_group_box._charuco_square_size_line_edit.setText(str(self._gui_state.charuco_square_size))- self._process_motion_capture_data_panel._calibration_control_panel._charuco_square_size_line_edit.setText(str(self._gui_state.charuco_square_size))+ self._process_motion_capture_data_panel._calibration_control_panel._charuco_square_size_line_edit.setText(+ str(self._gui_state.charuco_square_size)+ )def open_import_videos_dialog(self):# from this tutorial - https://www.youtube.com/watch?v=gg5TepTc2Jg&t=649s@@ -494,15 +504,19 @@ class MainWindow(QMainWindow):logger.info("User cancelled `Import Videos` dialog")return- self._import_videos_window = ImportVideosWizard(parent=self,- import_videos_path=import_videos_path, kill_thread_event=self._kill_thread_event,- )+ self._import_videos_window = ImportVideosWizard(+ parent=self,+ import_videos_path=import_videos_path,+ kill_thread_event=self._kill_thread_event,+ )self._import_videos_window.folder_to_save_videos_to_selected.connect(self._handle_import_videos)text = self._import_videos_window.exec()def download_sample_data(self):logger.info("Downloading sample data")- self.download_sample_data_thread_worker = DownloadSampleDataThreadWorker(kill_thread_event=self._kill_thread_event, parent=self)+ self.download_sample_data_thread_worker = DownloadSampleDataThreadWorker(+ kill_thread_event=self._kill_thread_event, parent=self+ )self.download_sample_data_thread_worker.start()self.download_sample_data_thread_worker.finished.connect(self._handle_download_sample_data_finished)@@ -514,23 +528,22 @@ class MainWindow(QMainWindow):@pyqtSlot(list, str, bool)def _handle_import_videos(self, video_paths: List[str], folder_to_save_videos: str, synchronization_bool: bool):-folder_to_save_videos = Path(folder_to_save_videos)folder_to_save_videos.mkdir(parents=True, exist_ok=True)if len(video_paths) == 0:logger.error("No videos to import!")return-- if not synchronization_bool:- for video_path in tqdm(video_paths,- desc="Importing videos...",- colour=[255, 128, 0],- unit="video",- unit_scale=True,- leave=False- ):+ if not synchronization_bool:+ for video_path in tqdm(+ video_paths,+ desc="Importing videos...",+ colour=[255, 128, 0],+ unit="video",+ unit_scale=True,+ leave=False,+ ):if not Path(video_path).exists():logger.error(f"{video_path} does not exist!")return@@ -540,8 +553,9 @@ class MainWindow(QMainWindow):shutil.copy(video_path, destination_path)- timestamps_copied = copy_directory_if_contains_timestamps(source_dir=Path(video_paths[0]).parent,- destination_dir=folder_to_save_videos)+ timestamps_copied = copy_directory_if_contains_timestamps(+ source_dir=Path(video_paths[0]).parent, destination_dir=folder_to_save_videos+ )if timestamps_copied:logger.info(f"Copied timestamps from {Path(video_paths[0]).parent} to {folder_to_save_videos}")@@ -549,7 +563,8 @@ class MainWindow(QMainWindow):logger.info(f"No timestamps found in {Path(video_paths[0]).parent}")self._active_recording_info_widget.set_active_recording(- recording_folder_path=Path(folder_to_save_videos).parent)+ recording_folder_path=Path(folder_to_save_videos).parent+ )def reboot_gui(self):logger.info("Rebooting GUI... ")@@ -560,8 +575,10 @@ class MainWindow(QMainWindow):if self._home_widget.consent_to_send_usage_information:self._pipedream_pings.update_pings_dict(key="gui_closed", value=True)- self._pipedream_pings.update_pings_dict(key="active recording status on close",- value=self._active_recording_info_widget.active_recording_info.status_check)+ self._pipedream_pings.update_pings_dict(+ key="active recording status on close",+ value=self._active_recording_info_widget.active_recording_info.status_check,+ )self._pipedream_pings.send_pipedream_ping()try:diff --git a/freemocap/gui/qt/style_sheet/compile_scss_to_css.py b/freemocap/gui/qt/style_sheet/compile_scss_to_css.pyindex 9ea9cdc1..a842d3f5 100644--- a/freemocap/gui/qt/style_sheet/compile_scss_to_css.py+++ b/freemocap/gui/qt/style_sheet/compile_scss_to_css.py@@ -10,5 +10,5 @@ def compile_scss_to_css(scss_path: Union[str, Path], css_path: Union[str, Path])compiled_css = sass.compile(string=scss_contents)- with open(css_path, 'w') as css_file:+ with open(css_path, "w") as css_file:css_file.write(compiled_css)diff --git a/freemocap/gui/qt/style_sheet/scss_file_watcher.py b/freemocap/gui/qt/style_sheet/scss_file_watcher.pyindex dcaa84b7..92a4c91a 100644--- a/freemocap/gui/qt/style_sheet/scss_file_watcher.py+++ b/freemocap/gui/qt/style_sheet/scss_file_watcher.py@@ -9,6 +9,7 @@ from freemocap.gui.qt.style_sheet.compile_scss_to_css import compile_scss_to_csslogger = logging.getLogger(__name__)+class SCSSFileWatcher(QFileSystemWatcher):def __init__(self, path_to_scss_file: Union[str, Path], path_to_css_file: Union[str, Path], parent=None):super().__init__(parent)@@ -28,9 +29,13 @@ class SCSSFileWatcher(QFileSystemWatcher):except Exception as e:logger.error(f"Error in SCSS compilation: {e}")+if __name__ == "__main__":app = QtCore.QCoreApplication([])- qt_file_system_watcher = SCSSFileWatcher(path_to_scss_file=Path(__file__).parent / "qt_style_sheet.scss", path_to_css_file=Path(__file__).parent / "qt_style_sheet.css")+ qt_file_system_watcher = SCSSFileWatcher(+ path_to_scss_file=Path(__file__).parent / "qt_style_sheet.scss",+ path_to_css_file=Path(__file__).parent / "qt_style_sheet.css",+ )print(f"watching directories - {qt_file_system_watcher.directories()})")print(f"watching files - {qt_file_system_watcher.files()})")app.exec()diff --git a/freemocap/gui/qt/utilities/copy_timestamps_folder.py b/freemocap/gui/qt/utilities/copy_timestamps_folder.pyindex fd36f6e7..4adc012b 100644--- a/freemocap/gui/qt/utilities/copy_timestamps_folder.py+++ b/freemocap/gui/qt/utilities/copy_timestamps_folder.py@@ -4,6 +4,8 @@ from pathlib import Pathfrom typing import Unionlogger = logging.getLogger(__name__)++def copy_directory_if_contains_timestamps(source_dir: Union[Path, str], destination_dir: Union[Path, str]) -> bool:source_path = Path(source_dir)destination_path = Path(destination_dir)@@ -18,7 +20,6 @@ def copy_directory_if_contains_timestamps(source_dir: Union[Path, str], destinatlogger.info(f"{source_dir} does not contain a 'timestamps' directory or file.")return False-# Create the destination directory if it doesn't existdestination_path.mkdir(parents=True, exist_ok=True)@@ -27,4 +28,4 @@ def copy_directory_if_contains_timestamps(source_dir: Union[Path, str], destinat# Copy the 'timestamps' directory/file to the destination directoryshutil.copytree(timestamps_path, destination_path / "timestamps", dirs_exist_ok=True)- return True\ No newline at end of file+ return Truediff --git a/freemocap/gui/qt/widgets/active_recording_widget.py b/freemocap/gui/qt/widgets/active_recording_widget.pyindex c1749efa..4ee2f8b1 100644--- a/freemocap/gui/qt/widgets/active_recording_widget.py+++ b/freemocap/gui/qt/widgets/active_recording_widget.py@@ -84,7 +84,6 @@ class ActiveRecordingInfoWidget(QWidget):self._directory_watcher.addPath(folder_to_watch)def _create_directory_watcher(self):-directory_watcher = QFileSystemWatcher()directory_watcher.fileChanged.connect(self._handle_directory_changed)directory_watcher.directoryChanged.connect(self._handle_directory_changed)diff --git a/freemocap/gui/qt/widgets/camera_controller_group_box.py b/freemocap/gui/qt/widgets/camera_controller_group_box.pyindex 83045451..e8d4848f 100644--- a/freemocap/gui/qt/widgets/camera_controller_group_box.py+++ b/freemocap/gui/qt/widgets/camera_controller_group_box.py@@ -11,14 +11,18 @@ from PyQt6.QtWidgets import (QFormLayout,QLabel,QRadioButton,- QCheckBox, QFrame,+ QCheckBox,+ QFrame,)from skellycam import SkellyCamControllerWidget, SkellyCamWidgetfrom freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, save_gui_statefrom freemocap.system.paths_and_filenames.file_and_folder_names import SPARKLES_EMOJI_STRING, SKULL_EMOJI_STRING-from freemocap.system.paths_and_filenames.path_getters import create_new_recording_folder_path, \- create_new_default_recording_name, get_gui_state_json_path+from freemocap.system.paths_and_filenames.path_getters import (+ create_new_recording_folder_path,+ create_new_default_recording_name,+ get_gui_state_json_path,+)CALIBRATION_RECORDING_BUTTON_TEXT = "\U0001F534 \U0001F4D0 Start Calibration Recording"MOCAP_RECORDING_BUTTON_TEXT = f"{SKULL_EMOJI_STRING} {SPARKLES_EMOJI_STRING} Start Motion Capture Recording"@@ -26,9 +30,6 @@ MOCAP_RECORDING_BUTTON_TEXT = f"{SKULL_EMOJI_STRING} {SPARKLES_EMOJI_STRING} Stalogger = logging.getLogger(__name__)---class CameraControllerGroupBox(QGroupBox):def __init__(self, skellycam_widget: SkellyCamWidget, gui_state: GuiState, parent=None):super().__init__(parent=parent)@@ -38,7 +39,7 @@ class CameraControllerGroupBox(QGroupBox):camera_viewer_widget=skellycam_widget,parent=self,)- self._skellycam_controller.check_recording_type = self.check_recording_type,+ self._skellycam_controller.check_recording_type = (self.check_recording_type,)self.gui_state = gui_state@@ -51,7 +52,6 @@ class CameraControllerGroupBox(QGroupBox):self._layout.addLayout(self._make_options_layout())-self._calibration_videos_radio_button.toggled.connect(self._set_record_button_text)self._mocap_videos_radio_button.toggled.connect(self._set_record_button_text)self._skellycam_widget.cameras_connected_signal.connect(lambda: self._start_recording_button.setEnabled(True))@@ -62,7 +62,6 @@ class CameraControllerGroupBox(QGroupBox):self._auto_open_in_blender_checkbox.toggled.connect(self._on_auto_open_in_blender_checkbox_changed)self._charuco_square_size_line_edit.textChanged.connect(self._on_charuco_square_size_line_edit_changed)-@propertydef mocap_videos_radio_button_checked(self) -> bool:return self._mocap_videos_radio_button.isChecked()@@ -109,7 +108,7 @@ class CameraControllerGroupBox(QGroupBox):self._auto_process_videos_checkbox.setChecked(self.gui_state.auto_process_videos_on_save)hbox.addWidget(self._auto_process_videos_checkbox)- self._generate_jupyter_notebook_checkbox = QCheckBox('Generate Jupyter Notebook')+ self._generate_jupyter_notebook_checkbox = QCheckBox("Generate Jupyter Notebook")self._generate_jupyter_notebook_checkbox.setChecked(self.gui_state.generate_jupyter_notebook)hbox.addWidget(self._generate_jupyter_notebook_checkbox)@@ -236,27 +235,16 @@ class CameraControllerGroupBox(QGroupBox):def _on_auto_process_videos_checkbox_changed(self):self.gui_state.auto_process_videos_on_save = self._auto_process_videos_checkbox.isChecked()- save_gui_state(- gui_state=self.gui_state,- file_pathstring=get_gui_state_json_path())-+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())+def _on_generate_jupyter_notebook_checkbox_changed(self):self.gui_state.generate_jupyter_notebook = self._generate_jupyter_notebook_checkbox.isChecked()- save_gui_state(- gui_state=self.gui_state,- file_pathstring=get_gui_state_json_path()- )+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())def _on_auto_open_in_blender_checkbox_changed(self):self.gui_state.auto_open_in_blender = self._auto_open_in_blender_checkbox.isChecked()- save_gui_state(- gui_state=self.gui_state,- file_pathstring=get_gui_state_json_path()- )+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())def _on_charuco_square_size_line_edit_changed(self):self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())- save_gui_state(- gui_state=self.gui_state,- file_pathstring=get_gui_state_json_path()- )+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())diff --git a/freemocap/gui/qt/widgets/central_tab_widget.py b/freemocap/gui/qt/widgets/central_tab_widget.pyindex fad20eb5..f6a3a0c0 100644--- a/freemocap/gui/qt/widgets/central_tab_widget.py+++ b/freemocap/gui/qt/widgets/central_tab_widget.py@@ -2,6 +2,7 @@ import loggingfrom PyQt6.QtCore import Qtfrom PyQt6.QtWidgets import QTabWidget, QVBoxLayout, QWidget, QLabel+# from skelly_viewer import SkellyViewerfrom skellycam import SkellyCamWidget@@ -68,7 +69,9 @@ class CentralTabWidget(QTabWidget):self._camera_view_layout.addWidget(self._skelly_cam_widget)- lag_note_label = QLabel("NOTE: If you experience lag in your camera views, decrease the resolution and/or use fewer cameras. The frames are likely being being recorded properly, its just the viewer that is lagging. A fix is incoming soon!")+ lag_note_label = QLabel(+ "NOTE: If you experience lag in your camera views, decrease the resolution and/or use fewer cameras. The frames are likely being being recorded properly, its just the viewer that is lagging. A fix is incoming soon!"+ )lag_note_label.setStyleSheet("font-size: 10px;")lag_note_label.setWordWrap(True)layout = QVBoxLayout()@@ -88,4 +91,3 @@ class CentralTabWidget(QTabWidget):def _create_active_recording_info_tab(self, tab_widget: QTabWidget):logger.info("Creating active recording info tab")tab_widget.addTab(self._active_recording_info_widget, f"Active Recording Info")-diff --git a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.pyindex 91bf2253..e5ce6d34 100644--- a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py+++ b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py@@ -15,25 +15,26 @@ from PyQt6.QtWidgets import (QVBoxLayout,QWidget,QHBoxLayout,- QLayout, )+ QLayout,+)from freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, save_gui_statefrom freemocap.gui.qt.workers.anipose_calibration_thread_worker import (AniposeCalibrationThreadWorker,)-from freemocap.system.paths_and_filenames.path_getters import get_gui_state_json_path, get_last_successful_calibration_toml_path+from freemocap.system.paths_and_filenames.path_getters import (+ get_gui_state_json_path,+ get_last_successful_calibration_toml_path,+)logger = logging.getLogger(__name__)class CalibrationControlPanel(QWidget):- def __init__(self,- get_active_recording_info: Callable,- kill_thread_event: threading.Event,- gui_state: GuiState,- parent=None):-+ def __init__(+ self, get_active_recording_info: Callable, kill_thread_event: threading.Event, gui_state: GuiState, parent=None+ ):super().__init__(parent=parent)self.gui_state = gui_stateself._has_a_toml_path = False@@ -100,7 +101,6 @@ class CalibrationControlPanel(QWidget):return vbox_layoutdef update_calibration_toml_path(self, toml_path: str = None):-if toml_path is None:if self._load_calibration_from_file_radio_button.isChecked():if self._user_selected_toml_path is not None:@@ -114,7 +114,7 @@ class CalibrationControlPanel(QWidget):elif self._calibrate_from_active_recording_radio_button.isChecked():toml_path = self._check_active_recording_for_calibration_toml()- else: #no button checked -> initialize+ else: # no button checked -> initializetoml_path = self._check_active_recording_for_calibration_toml()if toml_path is not None:self._load_calibration_from_file_radio_button.setChecked(True)@@ -128,7 +128,7 @@ class CalibrationControlPanel(QWidget):logger.info(f"Setting calibration TOML path: {self._calibration_toml_path}")self._show_selected_calibration_toml_path(self._calibration_toml_path)else:- self._show_selected_calibration_toml_path('-Calibration File Not Found-')+ self._show_selected_calibration_toml_path("-Calibration File Not Found-")def _add_calibrate_from_active_recording_radio_button(self):vbox = QVBoxLayout()@@ -158,7 +158,6 @@ class CalibrationControlPanel(QWidget):return vboxdef _create_use_most_recent_calibration_radio_button(self):-self._use_most_recent_calibration_radio_button = QRadioButton(f"Use most recent calibration")self._use_most_recent_calibration_radio_button.toggled.connect(self._handle_use_most_recent_calibration_toggled)@@ -236,7 +235,6 @@ class CalibrationControlPanel(QWidget):self.update_calibration_toml_path(toml_path=self._user_selected_toml_path)return self._user_selected_toml_path-def _show_selected_calibration_toml_path(self, calibration_toml_path_str: str):self._calibration_toml_path = calibration_toml_path_strpath = calibration_toml_path_str.replace(os.sep, "/ ")@@ -261,17 +259,12 @@ class CalibrationControlPanel(QWidget):charuco_square_size_form_layout.addRow(self._charuco_square_size_label, self._charuco_square_size_line_edit)charuco_square_size_form_layout.setAlignment(Qt.AlignmentFlag.AlignRight)return charuco_square_size_form_layout-+def _on_charuco_square_size_line_edit_changed(self):self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())- save_gui_state(- gui_state=self.gui_state,- file_pathstring=get_gui_state_json_path()- )-+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())def calibrate_from_active_recording(self, charuco_square_size_mm: float = None):-if not charuco_square_size_mm:charuco_square_size_mm = float(self._charuco_square_size_line_edit.text())diff --git a/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py b/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.pyindex 17ebc78c..f4188846 100644--- a/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py+++ b/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py@@ -51,9 +51,7 @@ class ControlPanelWidget(QWidget):f"Camera Configuration",)# self._tool_box.addTab(calibration_control_panel, "Capture Volume Calibration")- self._tab_widget.addTab(- process_motion_capture_data_panel, f"Process Data"- )+ self._tab_widget.addTab(process_motion_capture_data_panel, f"Process Data")self._tab_widget.addTab(visualize_data_widget, f"Export Data")self._tab_widget.setProperty("control_panel_tabs", True)diff --git a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_3d_triangulation_parameter_group.py b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_3d_triangulation_parameter_group.pyindex 139597f9..8b137891 100644--- a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_3d_triangulation_parameter_group.py+++ b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_3d_triangulation_parameter_group.py@@ -1,2 +1 @@-diff --git a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_parameter_groups.py b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_parameter_groups.pyindex 0d4227c8..ece1699b 100644--- a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_parameter_groups.py+++ b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/parameter_groups/create_parameter_groups.py@@ -1,8 +1,12 @@from pyqtgraph.parametertree import Parameter-from freemocap.data_layer.recording_models.post_processing_parameter_models import MediapipeParametersModel, \- PostProcessingParameterModel, AniposeTriangulate3DParametersModel, PostProcessingParametersModel, \- ButterworthFilterParametersModel+from freemocap.data_layer.recording_models.post_processing_parameter_models import (+ MediapipeParametersModel,+ PostProcessingParameterModel,+ AniposeTriangulate3DParametersModel,+ PostProcessingParametersModel,+ ButterworthFilterParametersModel,+)BUTTERWORTH_ORDER = "Order"@@ -36,7 +40,7 @@ SKIP_BUTTERWORTH_FILTER_NAME = "Skip butterworth filter?"def create_mediapipe_parameter_group(- parameter_model: MediapipeParametersModel = MediapipeParametersModel(),+ parameter_model: MediapipeParametersModel = MediapipeParametersModel(),) -> Parameter:mediapipe_model_complexity_list = ["0 (Fastest/Least accurate)",@@ -53,7 +57,7 @@ def create_mediapipe_parameter_group(limits=mediapipe_model_complexity_list,value=mediapipe_model_complexity_list[parameter_model.mediapipe_model_complexity],tip="Which Mediapipe model to use - higher complexity is slower but more accurate. "- "Variable name in `mediapipe` code: `mediapipe_model_complexity`",+ "Variable name in `mediapipe` code: `mediapipe_model_complexity`",),dict(name=MINIMUM_DETECTION_CONFIDENCE,@@ -62,8 +66,8 @@ def create_mediapipe_parameter_group(step=0.05,limits=(0.0, 1.0),tip="Minimum confidence for a skeleton detection to be considered valid. "- "Variable name in `mediapipe` code: `min_detection_confidence`."- "NOTE - Never trust a machine learning model's estimates of their own confidence!",+ "Variable name in `mediapipe` code: `min_detection_confidence`."+ "NOTE - Never trust a machine learning model's estimates of their own confidence!",),dict(name=MINIUMUM_TRACKING_CONFIDENCE,@@ -72,22 +76,22 @@ def create_mediapipe_parameter_group(step=0.05,limits=(0.0, 1.0),tip="Minimum confidence needed to use the previous frame's skeleton estiamte to predict the next one"- "Variable name in `mediapipe` code: `min_tracking_confidence`.",+ "Variable name in `mediapipe` code: `min_tracking_confidence`.",),dict(name=STATIC_IMAGE_MODE,type="bool",value=parameter_model.static_image_mode,tip="If true, the model will process each image independently, without tracking across frames."- "I think this is equivalent to setting `min_tracking_confidence` to 0.0"- "Variable name in `mediapipe` code: `static_image_mode`",+ "I think this is equivalent to setting `min_tracking_confidence` to 0.0"+ "Variable name in `mediapipe` code: `static_image_mode`",),],)def create_3d_triangulation_prarameter_group(- parameter_model: AniposeTriangulate3DParametersModel = AniposeTriangulate3DParametersModel(),+ parameter_model: AniposeTriangulate3DParametersModel = AniposeTriangulate3DParametersModel(),) -> Parameter:return Parameter.create(name=ANIPOSE_TREE_NAME,@@ -98,22 +102,22 @@ def create_3d_triangulation_prarameter_group(type="float",value=parameter_model.confidence_threshold_cutoff,tip="Confidence threshold cut-off for triangulation. "- "NOTE - Never trust a machine learning model's estimates of their own confidence! "- "TODO - Something similar that uses `reprojection_error` instead of `confidence`",+ "NOTE - Never trust a machine learning model's estimates of their own confidence! "+ "TODO - Something similar that uses `reprojection_error` instead of `confidence`",),dict(name=USE_RANSAC_METHOD,type="bool",value=parameter_model.use_triangulate_ransac_method,tip="If true, use `anipose`'s `triangulate_ransac` method instead of the default `triangulate_simple` method. "- "NOTE - Much slower than the 'simple' method, but might be more accurate and better at rejecting bad camera views. Needs more testing and evaluation to see if it's worth it. ",+ "NOTE - Much slower than the 'simple' method, but might be more accurate and better at rejecting bad camera views. Needs more testing and evaluation to see if it's worth it. ",),],)def create_post_processing_parameter_group(- parameter_model: PostProcessingParametersModel = PostProcessingParametersModel(),+ parameter_model: PostProcessingParametersModel = PostProcessingParametersModel(),) -> Parameter:return Parameter.create(name=BUTTERWORTH_FILTER_TREE_NAME,@@ -136,7 +140,7 @@ def create_post_processing_parameter_group(type="int",value=parameter_model.butterworth_filter_parameters.order,tip="Order of the filter."- "NOTE - I'm not really sure what this parameter does, but this is what I see in other people's Methods sections so.... lol",+ "NOTE - I'm not really sure what this parameter does, but this is what I see in other people's Methods sections so.... lol",),],tip="Low-pass, zero-lag, Butterworth filter to remove high frequency oscillations/noise from the data. ",@@ -144,11 +148,13 @@ def create_post_processing_parameter_group(def extract_parameter_model_from_parameter_tree(- parameter_object: Parameter,+ parameter_object: Parameter,) -> PostProcessingParameterModel:parameter_values_dictionary = extract_processing_parameter_model_from_tree(parameter_object=parameter_object)- mediapipe_model_complexity_integer = get_integer_from_mediapipe_model_complexity(parameter_values_dictionary[MEDIAPIPE_MODEL_COMPLEXITY])+ mediapipe_model_complexity_integer = get_integer_from_mediapipe_model_complexity(+ parameter_values_dictionary[MEDIAPIPE_MODEL_COMPLEXITY]+ )return PostProcessingParameterModel(mediapipe_parameters_model=MediapipeParametersModel(@@ -156,23 +162,24 @@ def extract_parameter_model_from_parameter_tree(min_detection_confidence=parameter_values_dictionary[MINIMUM_DETECTION_CONFIDENCE],min_tracking_confidence=parameter_values_dictionary[MINIUMUM_TRACKING_CONFIDENCE],static_image_mode=parameter_values_dictionary[STATIC_IMAGE_MODE],- skip_2d_image_tracking=parameter_values_dictionary[SKIP_2D_IMAGE_TRACKING_NAME], ),-+ skip_2d_image_tracking=parameter_values_dictionary[SKIP_2D_IMAGE_TRACKING_NAME],+ ),anipose_triangulate_3d_parameters_model=AniposeTriangulate3DParametersModel(confidence_threshold_cutoff=parameter_values_dictionary[ANIPOSE_CONFIDENCE_CUTOFF],use_triangulate_ransac_method=parameter_values_dictionary[USE_RANSAC_METHOD],- skip_3d_triangulation=parameter_values_dictionary[SKIP_3D_TRIANGULATION_NAME]- ),+ skip_3d_triangulation=parameter_values_dictionary[SKIP_3D_TRIANGULATION_NAME],+ ),post_processing_parameters_model=PostProcessingParametersModel(framerate=parameter_values_dictionary[POST_PROCESSING_FRAME_RATE],butterworth_filter_parameters=ButterworthFilterParametersModel(sampling_rate=parameter_values_dictionary[POST_PROCESSING_FRAME_RATE],cutoff_frequency=parameter_values_dictionary[BUTTERWORTH_CUTOFF_FREQUENCY],order=parameter_values_dictionary[BUTTERWORTH_ORDER],- ),+ ),skip_butterworth_filter=parameter_values_dictionary[SKIP_BUTTERWORTH_FILTER_NAME],- )- )+ ),+ )+def get_integer_from_mediapipe_model_complexity(mediapipe_model_complexity_value: str):mediapipe_model_complexity_dictionary = {@@ -182,7 +189,8 @@ def get_integer_from_mediapipe_model_complexity(mediapipe_model_complexity_value}return mediapipe_model_complexity_dictionary[mediapipe_model_complexity_value]-def extract_processing_parameter_model_from_tree(parameter_object, value_dictionary: dict=None):++def extract_processing_parameter_model_from_tree(parameter_object, value_dictionary: dict = None):if value_dictionary is None:value_dictionary = {}@@ -191,4 +199,4 @@ def extract_processing_parameter_model_from_tree(parameter_object, value_dictionextract_processing_parameter_model_from_tree(child, value_dictionary)else:value_dictionary[child.name()] = child.value()- return value_dictionary\ No newline at end of file+ return value_dictionarydiff --git a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.py b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.pyindex b35acac8..b4cb43cc 100644--- a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.py+++ b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.py@@ -33,13 +33,13 @@ class ProcessMotionCaptureDataPanel(QWidget):processing_finished_signal = pyqtSignal()def __init__(- self,- recording_processing_parameters: PostProcessingParameterModel,- get_active_recording_info: Callable,- kill_thread_event: threading.Event,- log_update: Callable,- gui_state: GuiState,- parent=None,+ self,+ recording_processing_parameters: PostProcessingParameterModel,+ get_active_recording_info: Callable,+ kill_thread_event: threading.Event,+ log_update: Callable,+ gui_state: GuiState,+ parent=None,):super().__init__(parent=parent)@@ -48,7 +48,7 @@ class ProcessMotionCaptureDataPanel(QWidget):self._log_update = log_updateself._recording_processing_parameter_model = recording_processing_parametersself._recording_processing_parameter_model.recording_info_model = self._get_active_recording_info()-+self._layout = QVBoxLayout()self._layout.setAlignment(Qt.AlignmentFlag.AlignTop)self.setLayout(self._layout)@@ -71,7 +71,7 @@ class ProcessMotionCaptureDataPanel(QWidget):)self._process_motion_capture_data_button.setFont(QFont("Dosis", 16, QFont.Weight.Bold))self._process_motion_capture_data_button.setObjectName("process_motion_capture_button")-+self._process_motion_capture_data_button.clicked.connect(self._launch_process_motion_capture_data_thread_worker)self._layout.addWidget(self._process_motion_capture_data_button)@@ -97,9 +97,9 @@ class ProcessMotionCaptureDataPanel(QWidget):return self._calibration_control_panel.update_calibration_toml_path()def _add_parameters_to_parameter_tree_widget(- self,- parameter_tree_widget: ParameterTree,- session_processing_parameter_model: PostProcessingParameterModel,+ self,+ parameter_tree_widget: ParameterTree,+ session_processing_parameter_model: PostProcessingParameterModel,):parameter_group = self._convert_session_processing_parameter_model_to_parameter_group(session_processing_parameter_model@@ -109,10 +109,9 @@ class ProcessMotionCaptureDataPanel(QWidget):return parameter_groupdef _convert_session_processing_parameter_model_to_parameter_group(- self,- session_processing_parameter_model: PostProcessingParameterModel,+ self,+ session_processing_parameter_model: PostProcessingParameterModel,):-return Parameter.create(name="Processing Parameters",type="group",@@ -147,29 +146,35 @@ class ProcessMotionCaptureDataPanel(QWidget):),],tip="Methods for cleaning up the data (e.g. filtering/smoothing, gap filling, etc ...)"- "TODO - Add/expose more post processing methods here (e.g. gap filling, outlier removal, etc ...)",+ "TODO - Add/expose more post processing methods here (e.g. gap filling, outlier removal, etc ...)",),],)def _create_session_parameter_model(- self,+ self,) -> PostProcessingParameterModel:- recording_processing_parameter_model = extract_parameter_model_from_parameter_tree(parameter_object=self._parameter_group)+ recording_processing_parameter_model = extract_parameter_model_from_parameter_tree(+ parameter_object=self._parameter_group+ )recording_processing_parameter_model.recording_info_model = self._get_active_recording_info()if self._calibration_control_panel.calibration_toml_path:- recording_processing_parameter_model.recording_info_model.calibration_toml_path = self._calibration_control_panel.calibration_toml_path+ recording_processing_parameter_model.recording_info_model.calibration_toml_path = (+ self._calibration_control_panel.calibration_toml_path+ )else:- recording_processing_parameter_model.recording_info_model.calibration_toml_path = self._calibration_control_panel.open_load_camera_calibration_toml_dialog()+ recording_processing_parameter_model.recording_info_model.calibration_toml_path = (+ self._calibration_control_panel.open_load_camera_calibration_toml_dialog()+ )if not recording_processing_parameter_model.recording_info_model.calibration_toml_path:logger.error(- "No calibration TOML selected - Processing will fail at the '3d triangulation' step (but it will get through the 'Tracking things in 2d images' step).")+ "No calibration TOML selected - Processing will fail at the '3d triangulation' step (but it will get through the 'Tracking things in 2d images' step)."+ )return recording_processing_parameter_model-def _create_new_skip_this_step_parameter(self, skip_step_name: str):parameter = Parameter.create(name=skip_step_name,@@ -186,7 +191,9 @@ class ProcessMotionCaptureDataPanel(QWidget):parameter_group = parameter.parent()for child in parameter_group.children():if child.name().split(" ")[0] != "Skip":- logger.debug(f"{'Enabling' if not skip_this_step_bool else 'Disabling'} {child.name()} in processing pipeline")+ logger.debug(+ f"{'Enabling' if not skip_this_step_bool else 'Disabling'} {child.name()} in processing pipeline"+ )self.set_parameter_enabled(child, not skip_this_step_bool)def set_parameter_enabled(self, parameter, enabled_bool):@@ -207,10 +214,13 @@ class ProcessMotionCaptureDataPanel(QWidget):logger.error(f"Recording path does not exist: {session_parameter_model.recording_info_model.path}.")return- session_parameter_model.recording_info_model.calibration_toml_path = self._calibration_control_panel.calibration_toml_path+ session_parameter_model.recording_info_model.calibration_toml_path = (+ self._calibration_control_panel.calibration_toml_path+ )- self._process_motion_capture_data_thread_worker = ProcessMotionCaptureDataThreadWorker(session_parameter_model,- kill_event=self._kill_thread_event)+ self._process_motion_capture_data_thread_worker = ProcessMotionCaptureDataThreadWorker(+ session_parameter_model, kill_event=self._kill_thread_event+ )self._process_motion_capture_data_thread_worker.in_progress.connect(self._log_update)self._process_motion_capture_data_thread_worker.start()diff --git a/freemocap/gui/qt/widgets/home_widget.py b/freemocap/gui/qt/widgets/home_widget.pyindex 2918e32b..314cd475 100644--- a/freemocap/gui/qt/widgets/home_widget.py+++ b/freemocap/gui/qt/widgets/home_widget.py@@ -7,7 +7,8 @@ from PyQt6.QtWidgets import (QLabel,QPushButton,QVBoxLayout,- QWidget, QHBoxLayout,+ QWidget,+ QHBoxLayout,)import freemocap@@ -18,15 +19,10 @@ from freemocap.gui.qt.actions_and_menus.actions import (IMPORT_VIDEOS_ACTION_NAME,Actions,)-from freemocap.gui.qt.utilities.save_and_load_gui_state import (- GuiState,- save_gui_state-)+from freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, save_gui_statefrom freemocap.system.paths_and_filenames.file_and_folder_names import PATH_TO_FREEMOCAP_LOGO_SVG-from freemocap.system.paths_and_filenames.path_getters import (- get_gui_state_json_path-)+from freemocap.system.paths_and_filenames.path_getters import get_gui_state_json_pathlogger = logging.getLogger(__name__)@@ -57,16 +53,12 @@ class HomeWidget(QWidget):self._welcome_to_freemocap_title_widget = self._welcome_to_freemocap_title()self._layout.addWidget(self._welcome_to_freemocap_title_widget)- self._create_new_session_button = WelcomeScreenButton(- f"{CREATE_NEW_RECORDING_ACTION_NAME}"- )+ self._create_new_session_button = WelcomeScreenButton(f"{CREATE_NEW_RECORDING_ACTION_NAME}")self._create_new_session_button.clicked.connect(actions.create_new_recording_action.trigger)self._layout.addWidget(self._create_new_session_button, alignment=Qt.AlignmentFlag.AlignCenter)self._create_new_session_button.setProperty("recommended_next", True)- self._load_most_recent_session_button = WelcomeScreenButton(- f"{LOAD_MOST_RECENT_RECORDING_ACTION_NAME}"- )+ self._load_most_recent_session_button = WelcomeScreenButton(f"{LOAD_MOST_RECENT_RECORDING_ACTION_NAME}")# self._load_most_recent_session_button.clicked.connect(actions.load_most_recent_recording_action.trigger)# self._layout.addWidget(self._load_most_recent_session_button, alignment=Qt.AlignmentFlag.AlignCenter)#@@ -130,9 +122,7 @@ class HomeWidget(QWidget):def _on_send_pings_checkbox_changed(self):self.gui_state.send_user_pings = self._send_pings_checkbox.isChecked()- save_gui_state(- gui_state=self.gui_state,- file_pathstring=get_gui_state_json_path())+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())def _welcome_to_freemocap_title(self):logger.info("Creating `welcome to freemocap` layout")diff --git a/freemocap/gui/qt/widgets/import_videos_wizard.py b/freemocap/gui/qt/widgets/import_videos_wizard.pyindex bb76c5cb..d5b20855 100644--- a/freemocap/gui/qt/widgets/import_videos_wizard.py+++ b/freemocap/gui/qt/widgets/import_videos_wizard.py@@ -6,8 +6,18 @@ from skelly_synchronize import create_debug_plotsfrom PyQt6.QtCore import pyqtSignalfrom PyQt6.QtGui import QFileSystemModel-from PyQt6.QtWidgets import QVBoxLayout, QListWidget, QLabel, QFormLayout, QLineEdit, \- QTreeView, QPushButton, QDialog, QCheckBox, QHBoxLayout+from PyQt6.QtWidgets import (+ QVBoxLayout,+ QListWidget,+ QLabel,+ QFormLayout,+ QLineEdit,+ QTreeView,+ QPushButton,+ QDialog,+ QCheckBox,+ QHBoxLayout,+)from freemocap.gui.qt.workers.synchronize_videos_thread_worker import SynchronizeVideosThreadWorker@@ -21,12 +31,11 @@ no_files_found_string = "No '.mp4' video files found! \n \n Note - We only looklogger = logging.getLogger(__name__)+class ImportVideosWizard(QDialog):folder_to_save_videos_to_selected = pyqtSignal(list, str, bool)- def __init__(self,- import_videos_path: Union[str, Path],- kill_thread_event: threading.Event,- parent=None):++ def __init__(self, import_videos_path: Union[str, Path], kill_thread_event: threading.Event, parent=None):super().__init__(parent=parent)self.kill_thread_event = kill_thread_event@@ -82,7 +91,6 @@ class ImportVideosWizard(QDialog):return str(Path(get_recording_session_folder_path()) / self._folder_name / SYNCHRONIZED_VIDEOS_FOLDER_NAME)def _create_import_directory_view(self, import_videos_path: Union[str, Path]):-self._file_system_model = QFileSystemModel()self._file_system_model.setRootPath(str(import_videos_path))@@ -99,7 +107,6 @@ class ImportVideosWizard(QDialog):return self._tree_view_widget-def _open_file(self):index = self._tree_view_widget.currentIndex()file_path = self._file_system_model.filePath(index)@@ -124,15 +131,14 @@ class ImportVideosWizard(QDialog):self.synchronize_videos_thread_worker = SynchronizeVideosThreadWorker(raw_video_folder_path=Path(self.import_videos_path),synchronized_video_folder_path=Path(self._get_folder_videos_will_be_saved_to()),- kill_thread_event=self.kill_thread_event+ kill_thread_event=self.kill_thread_event,)self.synchronize_videos_thread_worker.start()self.synchronize_videos_thread_worker.finished.connect(self._handle_video_synchronization_finished)else:self.folder_to_save_videos_to_selected.emit(- self._video_file_paths,- self._get_folder_videos_will_be_saved_to(),- False)+ self._video_file_paths, self._get_folder_videos_will_be_saved_to(), False+ )self.accept()def _handle_synchronize_checkbox_toggled(self, event):@@ -143,17 +149,17 @@ class ImportVideosWizard(QDialog):def _handle_video_synchronization_finished(self):self._video_file_paths = [- str(path)+ str(path)for path in get_video_paths(path_to_video_folder=self.synchronize_videos_thread_worker.output_folder_path)]create_debug_plots(synchronized_video_folder_path=self.synchronize_videos_thread_worker.output_folder_path)self.folder_to_save_videos_to_selected.emit(- self._video_file_paths,- self._get_folder_videos_will_be_saved_to(),- True)-+ self._video_file_paths, self._get_folder_videos_will_be_saved_to(), True+ )++if __name__ == "__main__":# from PyQt6.QtWidgets import QApplication# import sys@@ -163,4 +169,3 @@ if __name__ == "__main__":import_videos_window.exec()# import_videos_window.show()# sys.exit(app.exec())-diff --git a/freemocap/gui/qt/widgets/log_view_widget.py b/freemocap/gui/qt/widgets/log_view_widget.pyindex d15c28c7..6f46d248 100644--- a/freemocap/gui/qt/widgets/log_view_widget.py+++ b/freemocap/gui/qt/widgets/log_view_widget.py@@ -26,6 +26,7 @@ process_colors = {}thread_colors = {}code_path_colors = {}+class LoggingQueueListener(QThread):log_message_signal = QtCore.pyqtSignal(object)@@ -46,8 +47,6 @@ class LoggingQueueListener(QThread):if record is None:break--self.log_message_signal.emit(record)except Exception as e:self.close()@@ -62,7 +61,6 @@ class LogViewWidget(QPlainTextEdit):def __init__(self, parent=None):super().__init__(parent)-self.setReadOnly(True)self._logging_queue = multiprocessing.Queue(-1)@@ -75,8 +73,8 @@ class LogViewWidget(QPlainTextEdit):logging_queue=self._logging_queue, exit_event=self._exit_event)self._logging_queue_listener.log_message_signal.connect(self.add_log)- self.timestamp_color_generator = rgb_color_generator((50, 255, 255), (255, 50, 255), phase_increment=.2)- self.log_message_color_generator = rgb_color_generator((128, 255, 100), (100, 255, 255), phase_increment=.7)+ self.timestamp_color_generator = rgb_color_generator((50, 255, 255), (255, 50, 255), phase_increment=0.2)+ self.log_message_color_generator = rgb_color_generator((128, 255, 100), (100, 255, 255), phase_increment=0.7)self.show_colors = Trueself.show_code_path_info = Trueself._logging_queue_listener.start()@@ -91,8 +89,6 @@ class LogViewWidget(QPlainTextEdit):code_path_str = full_message.split("||||")[0].strip()package, method, line = code_path_str.split(":")--# Set color for the levelr, g, b = level_colors.get(level.strip(), (255, 255, 255))color_level = f"<span style='color:rgb({r},{g},{b});'>{level}</span>"@@ -121,20 +117,19 @@ class LogViewWidget(QPlainTextEdit):# Choose a color for the message using the log_message_color_generator+ if package + method not in code_path_colors:+ code_path_colors[package + method] = get_next_color()- if package+method not in code_path_colors:- code_path_colors[package+method] = get_next_color()--- r, g, b = code_path_colors[package+method]+ r, g, b = code_path_colors[package + method]color_code_path = f"<span style='color:rgb({r},{g},{b});'>{code_path_str}</span>"- r,g,b = (255, 255, 255)+ r, g, b = (255, 255, 255)color_message = f"<span style='color:rgb({r},{g},{b});'>{message_content}</span>"-# Combine colored parts- colored_log_entry = f"{color_timestamp}[{color_level}] {color_process_id_thread_id} {color_code_path} ::: {color_message}"+ colored_log_entry = (+ f"{color_timestamp}[{color_level}] {color_process_id_thread_id} {color_code_path} ::: {color_message}"+ )self.appendHtml(colored_log_entry)def closeEvent(self, event):diff --git a/freemocap/gui/qt/workers/anipose_calibration_thread_worker.py b/freemocap/gui/qt/workers/anipose_calibration_thread_worker.pyindex cee28197..ac9d4357 100644--- a/freemocap/gui/qt/workers/anipose_calibration_thread_worker.py+++ b/freemocap/gui/qt/workers/anipose_calibration_thread_worker.py@@ -48,8 +48,6 @@ class AniposeCalibrationThreadWorker(QThread):logger.info("Beginning Anipose calibration with Charuco Square Size (mm): {}".format(self._charuco_square_size))try:--run_anipose_capture_volume_calibration(charuco_board_definition=self._charuco_board_definition,charuco_square_size=self._charuco_square_size,@@ -58,8 +56,6 @@ class AniposeCalibrationThreadWorker(QThread):progress_callback=self._emit_in_progress_data,)--except Exception as e:logger.exception("something went wrong in the anipose calibration")logger.exception(e)@@ -68,4 +64,3 @@ class AniposeCalibrationThreadWorker(QThread):self._work_done = Truelogger.info("Anipose Calibration Complete")-diff --git a/freemocap/gui/qt/workers/download_sample_data_thread_worker.py b/freemocap/gui/qt/workers/download_sample_data_thread_worker.pyindex 23d39b93..026af662 100644--- a/freemocap/gui/qt/workers/download_sample_data_thread_worker.py+++ b/freemocap/gui/qt/workers/download_sample_data_thread_worker.py@@ -13,15 +13,9 @@ class DownloadSampleDataThreadWorker(QThread):finished = pyqtSignal()in_progress = pyqtSignal(str)- def __init__(- self,- kill_thread_event: threading.Event,- parent=None- ):+ def __init__(self, kill_thread_event: threading.Event, parent=None):super().__init__(parent=parent)- logger.info(- f"Initializing download sample data thread worker"- )+ logger.info(f"Initializing download sample data thread worker")self._kill_thread_event = kill_thread_eventself._work_done = False@@ -39,7 +33,6 @@ class DownloadSampleDataThreadWorker(QThread):try:self.sample_data_path = download_sample_data(sample_data_zip_file_url=FIGSHARE_SAMPLE_ZIP_FILE_URL)-except Exception as e:logger.exception("Something went wrong while downloading sample data")logger.exception(e)@@ -48,4 +41,3 @@ class DownloadSampleDataThreadWorker(QThread):self._work_done = Truelogger.info("Sample data successfully downloaded")-diff --git a/freemocap/gui/qt/workers/process_motion_capture_data_thread_worker.py b/freemocap/gui/qt/workers/process_motion_capture_data_thread_worker.pyindex 57f9e5c1..9874779c 100644--- a/freemocap/gui/qt/workers/process_motion_capture_data_thread_worker.py+++ b/freemocap/gui/qt/workers/process_motion_capture_data_thread_worker.py@@ -5,7 +5,7 @@ from pathlib import Pathfrom PyQt6.QtCore import pyqtSignal, QThread-from freemocap.core_processes.process_motion_capture_videos.process_recording_folder import process_recording_folder+from freemocap.core_processes.process_motion_capture_videos.process_recording_folder import process_recording_folderfrom freemocap.data_layer.recording_models.post_processing_parameter_models import PostProcessingParameterModelfrom freemocap.system.paths_and_filenames.file_and_folder_names import RECORDING_PARAMETERS_JSON_FILE_NAME@@ -14,24 +14,22 @@ from freemocap.utilities.save_dictionary_to_json import save_dictionary_to_jsonlogger = logging.getLogger(__name__)-class ProcessMotionCaptureDataThreadWorker(QThread):finished = pyqtSignal()in_progress = pyqtSignal(object)- def __init__(self, post_processing_parameters: PostProcessingParameterModel,- kill_event: multiprocessing.Event, parent=None):+ def __init__(+ self, post_processing_parameters: PostProcessingParameterModel, kill_event: multiprocessing.Event, parent=None+ ):super().__init__()self._post_processing_parameters = post_processing_parametersself._kill_event = kill_eventself._queue = multiprocessing.Queue()- self._process = multiprocessing.Process(target=process_recording_folder,- args=(self._post_processing_parameters,- self._kill_event,- self._queue))-+ self._process = multiprocessing.Process(+ target=process_recording_folder, args=(self._post_processing_parameters, self._kill_event, self._queue)+ )def run(self):logger.info(@@ -39,9 +37,10 @@ class ProcessMotionCaptureDataThreadWorker(QThread):)self._kill_event.clear()- recording_info_dict = self._post_processing_parameters.dict(exclude={'recording_info_model'})- Path(self._post_processing_parameters.recording_info_model.output_data_folder_path).mkdir(parents=True, exist_ok=True)-+ recording_info_dict = self._post_processing_parameters.dict(exclude={"recording_info_model"})+ Path(self._post_processing_parameters.recording_info_model.output_data_folder_path).mkdir(+ parents=True, exist_ok=True+ )save_dictionary_to_json(save_path=self._post_processing_parameters.recording_info_model.output_data_folder_path,diff --git a/freemocap/gui/qt/workers/synchronize_videos_thread_worker.py b/freemocap/gui/qt/workers/synchronize_videos_thread_worker.pyindex 1339f815..00232b06 100644--- a/freemocap/gui/qt/workers/synchronize_videos_thread_worker.py+++ b/freemocap/gui/qt/workers/synchronize_videos_thread_worker.py@@ -21,9 +21,7 @@ class SynchronizeVideosThreadWorker(QThread):kill_thread_event: threading.Event,):super().__init__()- logger.info(- f"Initializing Synchronize Videos Thread Worker"- )+ logger.info(f"Initializing Synchronize Videos Thread Worker")self._kill_thread_event = kill_thread_eventself._raw_video_folder_path = raw_video_folder_pathself._synchronized_video_folder_path = synchronized_video_folder_path@@ -46,7 +44,7 @@ class SynchronizeVideosThreadWorker(QThread):self.output_folder_path = synchronize_videos_from_audio(raw_video_folder_path=self._raw_video_folder_path,synchronized_video_folder_path=self._synchronized_video_folder_path,- create_debug_plots_bool=False+ create_debug_plots_bool=False,)except Exception as e:@@ -57,4 +55,3 @@ class SynchronizeVideosThreadWorker(QThread):self._work_done = Truelogger.info("Synchronizing Videos Complete")-diff --git a/freemocap/system/logging/configure_logging.py b/freemocap/system/logging/configure_logging.pyindex 8926c63d..ba510722 100644--- a/freemocap/system/logging/configure_logging.py+++ b/freemocap/system/logging/configure_logging.py@@ -13,12 +13,11 @@ format_string = "[%(asctime)s.%(msecs)04d] [%(levelname)8s] [%(name)s] [%(funcNadefault_logging_formatter = logging.Formatter(fmt=format_string, datefmt="%Y-%m-%d %H:%M:%S")-log_view_logging_format_string = (- "[%(asctime)s.%(msecs)04d] [%(levelname)4s] [%(name)s] [Process:%(process)d Thread:%(thread)d] ::::: [%(name)s:%(funcName)s():%(lineno)s] |||| %(message)s."-)+log_view_logging_format_string = "[%(asctime)s.%(msecs)04d] [%(levelname)4s] [%(name)s] [Process:%(process)d Thread:%(thread)d] ::::: [%(name)s:%(funcName)s():%(lineno)s] |||| %(message)s."# logging.basicConfig(level=logging.WARNING)+def get_logging_handlers():dictConfig(DEFAULT_LOGGING)@@ -48,6 +47,3 @@ def configure_logging():else:logger = logging.getLogger(__name__)logger.info("Logging already configured")---diff --git a/freemocap/system/logging/queue_logger.py b/freemocap/system/logging/queue_logger.pyindex 7916fe6f..92c41832 100644--- a/freemocap/system/logging/queue_logger.py+++ b/freemocap/system/logging/queue_logger.py@@ -1,11 +1,10 @@import multiprocessingfrom logging.handlers import QueueHandler+class DirectQueueHandler(QueueHandler):def __init__(self, queue: multiprocessing.Queue):super().__init__(queue)def enqueue(self, record):self.queue.put(record)--diff --git a/freemocap/system/paths_and_filenames/file_and_folder_names.py b/freemocap/system/paths_and_filenames/file_and_folder_names.pyindex 16b6cacc..2d20eeb8 100644--- a/freemocap/system/paths_and_filenames/file_and_folder_names.py+++ b/freemocap/system/paths_and_filenames/file_and_folder_names.py@@ -60,5 +60,3 @@ GEAR_EMOJI_STRING = "\U00002699"FOLDER_EMOJI_STRING = "\U0001F4C1"DIRECTORY_EMOJI_STRING = "\U0001F4C1"COOL_EMOJI_STRING = "\U0001F60E"--diff --git a/freemocap/system/paths_and_filenames/path_getters.py b/freemocap/system/paths_and_filenames/path_getters.pyindex 3fff07dd..bded58bc 100644--- a/freemocap/system/paths_and_filenames/path_getters.py+++ b/freemocap/system/paths_and_filenames/path_getters.py@@ -6,13 +6,27 @@ from typing import Unionimport toml-from freemocap.system.paths_and_filenames.file_and_folder_names import LOGS_INFO_AND_SETTINGS_FOLDER_NAME, \- LOG_FILE_FOLDER_NAME, BASE_FREEMOCAP_DATA_FOLDER_NAME, CALIBRATIONS_FOLDER_NAME, logger, \- RECORDING_SESSIONS_FOLDER_NAME, MOST_RECENT_RECORDING_TOML_FILENAME, LAST_SUCCESSFUL_CALIBRATION_TOML_FILENAME, \- OUTPUT_DATA_FOLDER_NAME, SYNCHRONIZED_VIDEOS_FOLDER_NAME, RAW_DATA_FOLDER_NAME, RAW_MEDIAPIPE_3D_NPY_FILE_NAME, \- CENTER_OF_MASS_FOLDER_NAME, TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME, MEDIAPIPE_2D_NPY_FILE_NAME, \- MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME, SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME, MEDIAPIPE_3D_NPY_FILE_NAME, \- GUI_STATE_JSON_FILENAME+from freemocap.system.paths_and_filenames.file_and_folder_names import (+ LOGS_INFO_AND_SETTINGS_FOLDER_NAME,+ LOG_FILE_FOLDER_NAME,+ BASE_FREEMOCAP_DATA_FOLDER_NAME,+ CALIBRATIONS_FOLDER_NAME,+ logger,+ RECORDING_SESSIONS_FOLDER_NAME,+ MOST_RECENT_RECORDING_TOML_FILENAME,+ LAST_SUCCESSFUL_CALIBRATION_TOML_FILENAME,+ OUTPUT_DATA_FOLDER_NAME,+ SYNCHRONIZED_VIDEOS_FOLDER_NAME,+ RAW_DATA_FOLDER_NAME,+ RAW_MEDIAPIPE_3D_NPY_FILE_NAME,+ CENTER_OF_MASS_FOLDER_NAME,+ TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME,+ MEDIAPIPE_2D_NPY_FILE_NAME,+ MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME,+ SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME,+ MEDIAPIPE_3D_NPY_FILE_NAME,+ GUI_STATE_JSON_FILENAME,+)def os_independent_home_dir():@@ -35,6 +49,8 @@ def create_camera_calibration_file_name(recording_name: str):freemocap_data_folder_path = None++def get_freemocap_data_folder_path(create_folder: bool = True):global freemocap_data_folder_path@@ -57,7 +73,6 @@ def get_calibrations_folder_path(create_folder: bool = True):def create_new_recording_folder_path(recording_name: str):-recording_folder_path = Path(create_new_session_folder()) / recording_namereturn str(recording_folder_path)@@ -89,6 +104,7 @@ def create_new_default_recording_name():def session_time_tag_format():return "%Y-%m-%d_%H_%M_%S"+def default_session_name(string_tag: str = None):if string_tag is not None:string_tag = f"_{string_tag}"@@ -102,6 +118,8 @@ def default_session_name(string_tag: str = None):session_folder_path = None++def create_new_session_folder():global session_folder_pathif session_folder_path is None:@@ -141,6 +159,7 @@ def get_scss_stylesheet_path():def get_most_recent_recording_toml_path():return str(Path(get_logs_info_and_settings_folder_path()) / MOST_RECENT_RECORDING_TOML_FILENAME)+def get_gui_state_json_path():return str(Path(get_logs_info_and_settings_folder_path()) / GUI_STATE_JSON_FILENAME)@@ -166,7 +185,6 @@ def get_most_recent_recording_path(subfolder_str: str = None):return str(sub_folder_path)else:-return str(most_recent_recording_path)@@ -186,11 +204,11 @@ def get_blender_file_name(recording_name: str):return f"{recording_name}.blend"-def get_blender_file_path(recording_folder_path: Union[Path,str]):+def get_blender_file_path(recording_folder_path: Union[Path, str]):return str(Path(recording_folder_path) / get_blender_file_name(recording_name=Path(recording_folder_path).name))-def get_output_data_folder_path(recording_folder_path: Union[str,Path])->str:+def get_output_data_folder_path(recording_folder_path: Union[str, Path]) -> str:for subfolder_path in Path(recording_folder_path).iterdir():if subfolder_path.name == OUTPUT_DATA_FOLDER_NAME:return str(subfolder_path)@@ -205,12 +223,15 @@ def get_synchronized_videos_folder_path(recording_folder_path: Union[str, Path])raise Exception(f"Could not find a videos folder in path {str(recording_folder_path)}")-def get_timestamps_directory(recording_directory: Union[str,Path])->str:++def get_timestamps_directory(recording_directory: Union[str, Path]) -> str:synchronized_videos_path = get_synchronized_videos_folder_path(recording_folder_path=recording_directory)if "timestamps" in [path.name for path in Path(synchronized_videos_path).iterdir()]:return str(Path(synchronized_videos_path) / "timestamps")logger.warning(f"Could not find timestamps directory in {synchronized_videos_path}")-def get_raw_skeleton_npy_file_name(data_folder_name: Union[str,Path])->str:+++def get_raw_skeleton_npy_file_name(data_folder_name: Union[str, Path]) -> str:raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAMEif raw_data_subfolder_path.exists:raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]@@ -219,10 +240,13 @@ def get_raw_skeleton_npy_file_name(data_folder_name: Union[str,Path])->str:raise Exception(f"Could not find a skeleton NPY file in path {str(data_folder_name)}")-def get_full_npy_file_path(output_data_folder: Union[str,Path])->str:++def get_full_npy_file_path(output_data_folder: Union[str, Path]) -> str:path = Path(output_data_folder) / MEDIAPIPE_3D_NPY_FILE_NAMEreturn str(path)-def get_total_body_center_of_mass_file_path(output_data_folder: Union[str,Path])->str:+++def get_total_body_center_of_mass_file_path(output_data_folder: Union[str, Path]) -> str:center_of_mass_subfolder_path = Path(output_data_folder) / CENTER_OF_MASS_FOLDER_NAMEif center_of_mass_subfolder_path.exists:center_of_mass_npy_path_list = [path.name for path in center_of_mass_subfolder_path.glob("*.npy")]@@ -232,7 +256,8 @@ def get_total_body_center_of_mass_file_path(output_data_folder: Union[str,Path])raise Exception(f"Could not find a total body center of mass npy file in path {str(output_data_folder)}")-def get_segment_center_of_mass_file_path(output_data_folder: Union[str,Path])->str:++def get_segment_center_of_mass_file_path(output_data_folder: Union[str, Path]) -> str:center_of_mass_subfolder_path = Path(output_data_folder) / CENTER_OF_MASS_FOLDER_NAMEif center_of_mass_subfolder_path.exists:center_of_mass_npy_path_list = [path.name for path in center_of_mass_subfolder_path.glob("*.npy")]@@ -243,7 +268,7 @@ def get_segment_center_of_mass_file_path(output_data_folder: Union[str,Path])->sraise Exception(f"Could not find a total body center of mass npy file in path {str(output_data_folder)}")-def get_image_tracking_data_file_name(data_folder_name: Union[str,Path])->str:+def get_image_tracking_data_file_name(data_folder_name: Union[str, Path]) -> str:raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAMEif raw_data_subfolder_path.exists:raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]@@ -254,7 +279,7 @@ def get_image_tracking_data_file_name(data_folder_name: Union[str,Path])->str:raise Exception(f"Could not find a 2d data file in path {str(data_folder_name)}")-def get_reprojection_error_file_path(data_folder_name: Union[str,Path])->str:+def get_reprojection_error_file_path(data_folder_name: Union[str, Path]) -> str:raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAMEif raw_data_subfolder_path.exists:raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]@@ -263,6 +288,3 @@ def get_reprojection_error_file_path(data_folder_name: Union[str,Path])->str:return str(raw_data_subfolder_path / MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME)raise Exception(f"Could not find reprojection error data file in path {str(data_folder_name)}")---diff --git a/freemocap/system/user_data/pipedream_pings.py b/freemocap/system/user_data/pipedream_pings.pyindex 1c404e0c..cd96b3a7 100644--- a/freemocap/system/user_data/pipedream_pings.py+++ b/freemocap/system/user_data/pipedream_pings.py@@ -7,11 +7,12 @@ logger = logging.getLogger(__name__)class PipedreamPings:- def __init__(self, ):+ def __init__(+ self,+ ):self._pipedream_url = "https://eowipinr6rcpbo0.m.pipedream.net"self._pings_dict = {}- self.update_pings_dict(key="session_uuid",- value=str(uuid.uuid4()))+ self.update_pings_dict(key="session_uuid", value=str(uuid.uuid4()))def update_pings_dict(self, key, value):self._pings_dict[key] = valuediff --git a/freemocap/tests/conftest.py b/freemocap/tests/conftest.pyindex 10d1dcb5..af899a90 100644--- a/freemocap/tests/conftest.py+++ b/freemocap/tests/conftest.py@@ -1,10 +1,17 @@import pytest-from freemocap.core_processes.process_motion_capture_videos.process_recording_headless import \- process_recording_headless, find_calibration_toml_path-from freemocap.system.paths_and_filenames.path_getters import get_output_data_folder_path, \- get_synchronized_videos_folder_path, get_raw_skeleton_npy_file_name, get_total_body_center_of_mass_file_path, \- get_image_tracking_data_file_name, get_reprojection_error_file_path+from freemocap.core_processes.process_motion_capture_videos.process_recording_headless import (+ process_recording_headless,+ find_calibration_toml_path,+)+from freemocap.system.paths_and_filenames.path_getters import (+ get_output_data_folder_path,+ get_synchronized_videos_folder_path,+ get_raw_skeleton_npy_file_name,+ get_total_body_center_of_mass_file_path,+ get_image_tracking_data_file_name,+ get_reprojection_error_file_path,+)from freemocap.utilities.download_sample_data import (download_sample_data,)@@ -54,5 +61,6 @@ def image_tracking_data_file_path():def reprojection_error_file_path():return get_reprojection_error_file_path(get_output_data_folder_path(pytest.sample_session_folder_path))+if __name__ == "__main__":- pytest_sessionstart()\ No newline at end of file+ pytest_sessionstart()diff --git a/freemocap/tests/test_image_tracking_data_shape.py b/freemocap/tests/test_image_tracking_data_shape.pyindex 5c34e5f1..9fa64484 100644--- a/freemocap/tests/test_image_tracking_data_shape.py+++ b/freemocap/tests/test_image_tracking_data_shape.py@@ -13,7 +13,7 @@ from freemocap.utilities.get_video_paths import get_video_paths@pytest.mark.usefixtures("synchronized_video_folder_path", "image_tracking_data_file_path")def test_image_tracking_data_shape(synchronized_video_folder_path: Union[str, Path],- image_tracking_data_file_path,+ image_tracking_data_file_path,):"""test that the `mediapipe 2d detection` process worked correctly by checking:@@ -45,5 +45,6 @@ def test_image_tracking_data_shape(# TODO - check number of tracked points vs 'expected' number of tracked points- assert image_tracking_data.shape[3] == 3, f"Data has {image_tracking_data.shape[3]} dimensions, expected 3 dimensions"-+ assert (+ image_tracking_data.shape[3] == 3+ ), f"Data has {image_tracking_data.shape[3]} dimensions, expected 3 dimensions"diff --git a/freemocap/tests/test_mediapipe_skeleton_data_shape.py b/freemocap/tests/test_mediapipe_skeleton_data_shape.pyindex 26620b86..5a529fda 100644--- a/freemocap/tests/test_mediapipe_skeleton_data_shape.py+++ b/freemocap/tests/test_mediapipe_skeleton_data_shape.py@@ -13,7 +13,7 @@ from freemocap.utilities.get_number_of_frames_of_videos_in_a_folder import (def test_mediapipe_skeleton_data_shape(synchronized_video_folder_path: Union[str, Path],raw_skeleton_npy_file_path: Union[str, Path],- reprojection_error_file_path,+ reprojection_error_file_path,):"""test that the `mediapipe 3d detection` process worked correctly by checking:@@ -38,9 +38,7 @@ def test_mediapipe_skeleton_data_shape(reprojection_error_file_path).is_file(), f"3d skeleton reprojection error data file does not exist at {reprojection_error_file_path}"- skeleton_reprojection_error_fr_mar = np.load(- reprojection_error_file_path- )+ skeleton_reprojection_error_fr_mar = np.load(reprojection_error_file_path)assert (len(skeleton_reprojection_error_fr_mar.shape) == 2@@ -61,4 +59,3 @@ def test_mediapipe_skeleton_data_shape(assert (skel3d_frame_marker_xyz.shape[2] == 3), f"3d skeleton data file does not have 3 dimensions for X,Y,Z at {raw_skeleton_npy_file_path}"-diff --git a/freemocap/tests/test_synchronized_video_frame_counts.py b/freemocap/tests/test_synchronized_video_frame_counts.pyindex dda23745..fd219dc0 100644--- a/freemocap/tests/test_synchronized_video_frame_counts.py+++ b/freemocap/tests/test_synchronized_video_frame_counts.py@@ -23,4 +23,3 @@ def test_synchronized_video_frame_counts(synchronized_video_folder_path: Union[Passert (len(set(frame_count)) == 1), f"Videos in {synchronized_video_folder_path} have different frame counts: {frame_count}"-diff --git a/freemocap/tests/test_total_body_center_of_mass_data_shape.py b/freemocap/tests/test_total_body_center_of_mass_data_shape.pyindex 515d83f9..f01db7d9 100644--- a/freemocap/tests/test_total_body_center_of_mass_data_shape.py+++ b/freemocap/tests/test_total_body_center_of_mass_data_shape.py@@ -14,7 +14,6 @@ def test_total_body_center_of_mass_data_shape(synchronized_video_folder_path: Union[str, Path],total_body_center_of_mass_file_path: Union[str, Path],):-assert Path(total_body_center_of_mass_file_path).is_file(), f"No file found at {total_body_center_of_mass_file_path}"@@ -35,4 +34,3 @@ def test_total_body_center_of_mass_data_shape(assert (total_body_center_of_mass_fr_xyz.shape[1] == 3), f"`total_body_center_of_mass_fr_xyz.shape[1]` should have 3 dimensions (X,Y,Z) "-diff --git a/freemocap/utilities/create_nested_dict_from_pydantic.py b/freemocap/utilities/create_nested_dict_from_pydantic.pyindex 50491f01..3b9a2a2a 100644--- a/freemocap/utilities/create_nested_dict_from_pydantic.py+++ b/freemocap/utilities/create_nested_dict_from_pydantic.py@@ -4,7 +4,6 @@ from typing import get_origin, get_argsfrom pydantic import BaseModel-def create_nested_dict(pydantic_model):if not issubclass(pydantic_model, BaseModel):return str(pydantic_model)@@ -26,9 +25,12 @@ def create_nested_dict(pydantic_model):model_dict[name] = create_nested_dict(field)return model_dict+if __name__ == "__main__":- from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import \- mediapipe_skeleton_schema+ from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.data_models.mediapipe_skeleton_names_and_connections import (+ mediapipe_skeleton_schema,+ )from freemocap.data_layer.data_saver import SkeletonSchema+skeleton_schema = SkeletonSchema(schema_dict=mediapipe_skeleton_schema)- print(create_nested_dict(skeleton_schema))\ No newline at end of file+ print(create_nested_dict(skeleton_schema))diff --git a/freemocap/utilities/download_sample_data.py b/freemocap/utilities/download_sample_data.pyindex 1a84dc09..784fd535 100644--- a/freemocap/utilities/download_sample_data.py+++ b/freemocap/utilities/download_sample_data.py@@ -7,15 +7,15 @@ import requestsfrom freemocap.system.paths_and_filenames.file_and_folder_names import (FREEMOCAP_TEST_DATA_RECORDING_NAME,- FIGSHARE_TEST_ZIP_FILE_URL+ FIGSHARE_TEST_ZIP_FILE_URL,)from freemocap.system.paths_and_filenames.path_getters import get_recording_session_folder_pathlogger = logging.getLogger(__name__)-def get_sample_data_path(download_if_needed:bool=True)->str:- sample_data_path = str(Path(get_recording_session_folder_path()) / FREEMOCAP_TEST_DATA_RECORDING_NAME)+def get_sample_data_path(download_if_needed: bool = True) -> str:+ sample_data_path = str(Path(get_recording_session_folder_path()) / FREEMOCAP_TEST_DATA_RECORDING_NAME)if not Path(sample_data_path).exists():if download_if_needed:download_sample_data()diff --git a/freemocap/utilities/geometry/project_3d_data_to_z_plane.py b/freemocap/utilities/geometry/project_3d_data_to_z_plane.pyindex 273f34e8..09472f5a 100644--- a/freemocap/utilities/geometry/project_3d_data_to_z_plane.py+++ b/freemocap/utilities/geometry/project_3d_data_to_z_plane.py@@ -2,7 +2,6 @@ import numpy as npdef project_3d_data_to_z_plane(skel3d_frame_marker_xyz: np.ndarray) -> np.ndarray:-projected_skel3d_frame_marker_xyz = np.zeros(skel3d_frame_marker_xyz.shape)projected_skel3d_frame_marker_xyz[:, :, 0] = skel3d_frame_marker_xyz[:, :, 0]diff --git a/freemocap/utilities/geometry/rotate_by_90_degrees_around_x_axis.py b/freemocap/utilities/geometry/rotate_by_90_degrees_around_x_axis.pyindex 93cac3ea..a632537b 100644--- a/freemocap/utilities/geometry/rotate_by_90_degrees_around_x_axis.py+++ b/freemocap/utilities/geometry/rotate_by_90_degrees_around_x_axis.py@@ -2,7 +2,6 @@ import numpy as npdef rotate_by_90_degrees_around_x_axis(raw_skel3d_frame_marker_xyz: np.ndarray) -> np.ndarray:-swapped_skel3d_frame_marker_xyz = np.zeros(raw_skel3d_frame_marker_xyz.shape)swapped_skel3d_frame_marker_xyz[:, :, 0] = raw_skel3d_frame_marker_xyz[:, :, 0]diff --git a/freemocap/utilities/get_number_of_frames_of_videos_in_a_folder.py b/freemocap/utilities/get_number_of_frames_of_videos_in_a_folder.pyindex b2819178..30fe3a31 100644--- a/freemocap/utilities/get_number_of_frames_of_videos_in_a_folder.py+++ b/freemocap/utilities/get_number_of_frames_of_videos_in_a_folder.py@@ -26,5 +26,4 @@ def get_number_of_frames_of_videos_in_a_folder(folder_path: Union[str, Path]):frame_count.append(int(cap.get(cv2.CAP_PROP_FRAME_COUNT)))cap.release()-return frame_countdiff --git a/freemocap/utilities/get_video_paths.py b/freemocap/utilities/get_video_paths.pyindex 85ac9eed..6f3faa76 100644--- a/freemocap/utilities/get_video_paths.py+++ b/freemocap/utilities/get_video_paths.py@@ -2,7 +2,7 @@ from pathlib import Pathfrom typing import Union-def get_video_paths(path_to_video_folder: Union[str,Path]) -> list:+def get_video_paths(path_to_video_folder: Union[str, Path]) -> list:"""Search the folder for 'mp4' files (case insensitive) and return them as a list"""list_of_video_paths = list(Path(path_to_video_folder).glob("*.mp4")) + list(