Skip to content

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

TypeScript

Jon/recording data package (#422)

jonmatthisafdf71fb9892
diff --git a/bin/installer.sh b/bin/installer.sh
index 4eccb2fa..b6c6dcd3 100755
--- a/bin/installer.sh
+++ b/bin/installer.sh
@@ -1,2 +1 @@
-
-pyinstaller --name="FreeMoCap" --windowed --onefile --hidden-import pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt6 --hidden-import pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt6 --hidden-import pyqtgraph.imageview.ImageViewTemplate_pyqt6 .\freemocap\__main__.py
+pyinstaller --name="freemocap" --windowed --onefile .\RUN_ME.py
diff --git a/experimental/batch_process/batch_process.py b/experimental/batch_process/batch_process.py
index c32cd13a..74a51b1c 100644
--- a/experimental/batch_process/batch_process.py
+++ b/experimental/batch_process/batch_process.py
@@ -3,12 +3,14 @@ from pathlib import Path
from typing import Optional, Union
from freemocap.core_processes.process_motion_capture_videos.process_recording_folder import process_recording_folder
-from freemocap.export_data.blender_stuff.export_to_blender import export_to_blender
-from freemocap.parameter_info_models.recording_info_model import RecordingInfoModel
-from freemocap.parameter_info_models.recording_processing_parameter_models import RecordingProcessingParameterModel
-from freemocap.system.paths_and_files_names import RECORDING_PARAMETER_DICT_JSON_FILE_NAME, get_blender_file_path
+from freemocap.data_layer.export_data.blender_stuff.export_to_blender import export_to_blender
+from freemocap.data_layer.recording_models.post_processing_parameter_models import PostProcessingParameterModel
+from freemocap.data_layer.recording_models.recording_info_model import RecordingInfoModel
+from freemocap.system.paths_and_filenames.file_and_folder_names import RECORDING_PARAMETERS_JSON_FILE_NAME
+from freemocap.system.paths_and_filenames.path_getters import get_blender_file_path
from freemocap.utilities.save_dictionary_to_json import save_dictionary_to_json
+
def process_folder_of_session_folders(
path_to_folder_of_session_folders: Union[str, Path],
path_to_camera_calibration_toml: Optional[Union[str, Path]] = None,
@@ -49,7 +51,7 @@ def process_recording_without_gui(
path_to_camera_calibration_toml: Optional[Union[str, Path]] = None,
path_to_blender_executable: Optional[Union[str, Path]] = None,
):
- rec = RecordingProcessingParameterModel()
+ rec = PostProcessingParameterModel()
rec.recording_info_model = RecordingInfoModel(recording_folder_path=Path(recording_path))
@@ -62,7 +64,7 @@ def process_recording_without_gui(
save_dictionary_to_json(
save_path=rec.recording_info_model.output_data_folder_path,
- file_name=RECORDING_PARAMETER_DICT_JSON_FILE_NAME,
+ file_name=RECORDING_PARAMETERS_JSON_FILE_NAME,
dictionary=recording_info_dict,
)
diff --git a/experimental/python_scratch/qt_drag_and_drop.py b/experimental/python_scratch/qt_drag_and_drop.py
index e5a60912..73a8c51a 100644
--- a/experimental/python_scratch/qt_drag_and_drop.py
+++ b/experimental/python_scratch/qt_drag_and_drop.py
@@ -1,10 +1,9 @@
# from -https://gist.github.com/peace098beat/db8ef7161508e6500ebe?permalink_comment_id=3542714#gistcomment-3542714
-from PyQt6.QtWidgets import QMainWindow, QApplication
-
-
import sys
+from PyQt6.QtWidgets import QMainWindow, QApplication
+
class MainWidget(QMainWindow):
def __init__(self):
diff --git a/freemocap/__init__.py b/freemocap/__init__.py
index 1e48ee69..d2b1c8d8 100644
--- a/freemocap/__init__.py
+++ b/freemocap/__init__.py
@@ -9,15 +9,17 @@ __package_name__ = "freemocap"
__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.path
import sys
from 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 par
+#
+# 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 par
from freemocap.system.logging.configure_logging import configure_logging
-
configure_logging()
import logging
@@ -25,6 +27,7 @@ logger = logging.getLogger(__name__)
logger.info(f"Initializing {__package_name__} package, version: {__version__}, from file: {__file__}")
+# breadcrumbs for legacy/deprecated 'pre-alpha` entry point
def 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")
@@ -41,5 +44,5 @@ def RunMe(*args, **kwargs):
"(NOTE - this entry point will be removed eventually\n"
"--------------------------------\n")
- from freemocap.__main__ import main
- main()
+ from freemocap.__main__ import freemocap_main
+ freemocap_main()
diff --git a/freemocap/__main__.py b/freemocap/__main__.py
index 1f778eb4..4a617ed9 100644
--- a/freemocap/__main__.py
+++ b/freemocap/__main__.py
@@ -1,5 +1,6 @@
# __main__.py
import sys
+from multiprocessing import freeze_support
from pathlib import Path
@@ -12,14 +13,7 @@ except Exception as e:
from freemocap.gui.qt.freemocap_main import qt_gui_main
-def main():
- qt_gui_main()
-
-
-if __name__ == "__main__":
-
- print(f"Running `freemocap.__main__` from - {__file__}")
-
+def freemocap_main():
# set up so you can change the taskbar icon - https://stackoverflow.com/a/74531530/14662833
import ctypes
@@ -29,4 +23,11 @@ if __name__ == "__main__":
myappid = f"{freemocap.__package_name__}_{freemocap.__version__}" # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
- main()
+ qt_gui_main()
+
+
+if __name__ == "__main__":
+ freeze_support()
+ print(f"Running `freemocap.__main__` from - {__file__}")
+
+ freemocap_main()
diff --git a/assets/charuco/charuco_board_image.png b/freemocap/assets/charuco/charuco_board_image.png
similarity index 100%
rename from assets/charuco/charuco_board_image.png
rename to freemocap/assets/charuco/charuco_board_image.png
diff --git a/assets/charuco/charuco_board_image_highRes.png b/freemocap/assets/charuco/charuco_board_image_highRes.png
similarity index 100%
rename from assets/charuco/charuco_board_image_highRes.png
rename to freemocap/assets/charuco/charuco_board_image_highRes.png
diff --git a/assets/logo/freemocap-logo-black-border.svg b/freemocap/assets/logo/freemocap-logo-black-border.svg
similarity index 100%
rename from assets/logo/freemocap-logo-black-border.svg
rename to freemocap/assets/logo/freemocap-logo-black-border.svg
diff --git a/assets/logo/freemocap-skelly-logo-black-border-white-bkgd.png b/freemocap/assets/logo/freemocap-skelly-logo-black-border-white-bkgd.png
similarity index 100%
rename from assets/logo/freemocap-skelly-logo-black-border-white-bkgd.png
rename to freemocap/assets/logo/freemocap-skelly-logo-black-border-white-bkgd.png
diff --git a/assets/logo/freemocap_skelly_logo.ico b/freemocap/assets/logo/freemocap_skelly_logo.ico
similarity index 100%
rename from assets/logo/freemocap_skelly_logo.ico
rename to freemocap/assets/logo/freemocap_skelly_logo.ico
diff --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.py
index cf04a19d..10072161 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,10 +11,8 @@ from freemocap.core_processes.capture_volume_calibration.anipose_camera_calibrat
from freemocap.core_processes.capture_volume_calibration.charuco_stuff.charuco_board_definition import (
CharucoBoardDefinition,
)
-from freemocap.system.paths_and_files_names import (
- get_calibrations_folder_path,
- get_last_successful_calibration_toml_path, create_camera_calibration_file_name,
-)
+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_paths
logger = logging.getLogger(__name__)
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.py
index 16de22ff..4f08f2d5 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
@@ -7,9 +7,7 @@ from typing import Union
from freemocap.core_processes.capture_volume_calibration.anipose_camera_calibration import (
freemocap_anipose,
)
-from freemocap.system.paths_and_files_names import (
- get_last_successful_calibration_toml_path,
-)
+from freemocap.system.paths_and_filenames.path_getters import get_last_successful_calibration_toml_path
logger = logging.getLogger(__name__)
diff --git a/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.py b/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.py
index 68894b68..9eac95a1 100644
--- a/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.py
+++ b/freemocap/core_processes/capture_volume_calibration/triangulate_3d_data.py
@@ -5,7 +5,7 @@ from typing import Union
import numpy as np
-from freemocap.system.paths_and_files_names import (
+from freemocap.system.paths_and_filenames.file_and_folder_names import (
RAW_MEDIAPIPE_3D_NPY_FILE_NAME,
MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME,
)
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.py
index d4e1a05d..7343e612 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,6 +7,9 @@ import numpy as np
import pandas as pd
from 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
+
logger = logging.getLogger(__name__)
@@ -159,7 +162,7 @@ def convert_mediapipe_npy_to_csv(
body_dataframe = pd.DataFrame(body_flat, columns=body_3d_xyz_header)
body_dataframe.to_csv(
- str(Path(output_data_folder_path) / "mediapipe_body_3d_xyz.csv"), index=False
+ str(Path(output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME), index=False
)
right_hand_flat = right_hand_3d_xyz.reshape(
@@ -169,7 +172,7 @@ def convert_mediapipe_npy_to_csv(
right_hand_flat, columns=right_hand_3d_xyz_header
)
right_hand_dataframe.to_csv(
- str(Path(output_data_folder_path) / "mediapipe_right_hand_3d_xyz.csv"),
+ str(Path(output_data_folder_path) / MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME),
index=False,
)
@@ -178,7 +181,7 @@ def convert_mediapipe_npy_to_csv(
)
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_xyz.csv"),
+ str(Path(output_data_folder_path) / MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME),
index=False,
)
@@ -332,7 +335,7 @@ def convert_mediapipe_npy_to_csv(
body_dataframe = pd.DataFrame(body_flat, columns=body_3d_xyz_header)
body_dataframe.to_csv(
- str(Path(output_data_folder_path) / "mediapipe_body_3d_xyz.csv"), index=False
+ str(Path(output_data_folder_path) / MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME), index=False
)
right_hand_flat = right_hand_3d_xyz.reshape(
@@ -342,7 +345,7 @@ def convert_mediapipe_npy_to_csv(
right_hand_flat, columns=right_hand_3d_xyz_header
)
right_hand_dataframe.to_csv(
- str(Path(output_data_folder_path) / "mediapipe_right_hand_3d_xyz.csv"),
+ str(Path(output_data_folder_path) / MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME),
index=False,
)
@@ -351,7 +354,7 @@ def convert_mediapipe_npy_to_csv(
)
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_xyz.csv"),
+ str(Path(output_data_folder_path) / MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME),
index=False,
)
diff --git a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_data_models.py b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_data_models.py
new file mode 100644
index 00000000..68696b93
--- /dev/null
+++ b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_data_models.py
@@ -0,0 +1,58 @@
+import logging
+from dataclasses import dataclass
+from typing import Any
+
+import numpy as np
+from skellycam.detection.models.frame_payload import FramePayload
+
+logger = logging.getLogger(__name__)
+@dataclass
+class Mediapipe2dNumpyArrays:
+ body_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
+ body_world_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
+ rightHand_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
+ leftHand_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
+ face_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
+
+ body_frameNumber_trackedPointNumber_confidence: np.ndarray = None
+
+ @property
+ def has_data(self):
+ return not np.isnan(self.body_frameNumber_trackedPointNumber_XYZ).all()
+
+ @property
+ def all_data2d_nFrames_nTrackedPts_XY(self):
+ """dimensions will be [number_of_frames , number_of_markers, XY]"""
+
+ if self.body_frameNumber_trackedPointNumber_XYZ is None:
+ # if there's no body data, there's no hand or face data either
+ return
+
+ if len(self.body_frameNumber_trackedPointNumber_XYZ.shape) == 3: # multiple frames
+ return np.hstack(
+ [
+ self.body_frameNumber_trackedPointNumber_XYZ,
+ self.rightHand_frameNumber_trackedPointNumber_XYZ,
+ self.leftHand_frameNumber_trackedPointNumber_XYZ,
+ self.face_frameNumber_trackedPointNumber_XYZ,
+ ]
+ )
+ elif len(self.body_frameNumber_trackedPointNumber_XYZ.shape) == 2: # single frame
+ return np.vstack(
+ [
+ self.body_frameNumber_trackedPointNumber_XYZ,
+ self.rightHand_frameNumber_trackedPointNumber_XYZ,
+ self.leftHand_frameNumber_trackedPointNumber_XYZ,
+ self.face_frameNumber_trackedPointNumber_XYZ,
+ ]
+ )
+ else:
+ logger.error("data should have either 2 or 3 dimensions")
+
+
+@dataclass
+class Mediapipe2dDataPayload:
+ raw_frame_payload: FramePayload = None
+ mediapipe_results: Any = None
+ annotated_image: np.ndarray = None
+ pixel_data_numpy_arrays: Mediapipe2dNumpyArrays = None
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.py
index bc40423b..32953965 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
@@ -1,22 +1,23 @@
import logging
-from dataclasses import dataclass
import multiprocessing
from pathlib import Path
-from typing import Any, List, Union, Callable
+from typing import List, Union, Callable
import cv2
import mediapipe as mp
import numpy as np
-from skellycam.detection.models.frame_payload import FramePayload
from skellycam.opencv.video_recorder.video_recorder import VideoRecorder
from tqdm import tqdm
-from freemocap.system.paths_and_files_names import MEDIAPIPE_2D_NPY_FILE_NAME, ANNOTATED_VIDEOS_FOLDER_NAME, \
- MEDIAPIPE_BODY_WORLD_FILE_NAME
+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_data_models import \
+ Mediapipe2dNumpyArrays
from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_names_and_connections import (
mediapipe_tracked_point_names_dict,
)
-from freemocap.parameter_info_models.recording_processing_parameter_models import MediapipeParametersModel
+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.utilities.get_video_paths import get_video_paths
logger = logging.getLogger(__name__)
@@ -30,64 +31,14 @@ hand_drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=1)
face_drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=1)
-@dataclass
-class Mediapipe2dNumpyArrays:
- body_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
- body_world_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
- rightHand_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
- leftHand_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
- face_frameNumber_trackedPointNumber_XYZ: np.ndarray = None
-
- body_frameNumber_trackedPointNumber_confidence: np.ndarray = None
-
- @property
- def has_data(self):
- return not np.isnan(self.body_frameNumber_trackedPointNumber_XYZ).all()
-
- @property
- def all_data2d_nFrames_nTrackedPts_XY(self):
- """dimensions will be [number_of_frames , number_of_markers, XY]"""
-
- if self.body_frameNumber_trackedPointNumber_XYZ is None:
- # if there's no body data, there's no hand or face data either
- return
-
- if len(self.body_frameNumber_trackedPointNumber_XYZ.shape) == 3: # multiple frames
- return np.hstack(
- [
- self.body_frameNumber_trackedPointNumber_XYZ,
- self.rightHand_frameNumber_trackedPointNumber_XYZ,
- self.leftHand_frameNumber_trackedPointNumber_XYZ,
- self.face_frameNumber_trackedPointNumber_XYZ,
- ]
- )
- elif len(self.body_frameNumber_trackedPointNumber_XYZ.shape) == 2: # single frame
- return np.vstack(
- [
- self.body_frameNumber_trackedPointNumber_XYZ,
- self.rightHand_frameNumber_trackedPointNumber_XYZ,
- self.leftHand_frameNumber_trackedPointNumber_XYZ,
- self.face_frameNumber_trackedPointNumber_XYZ,
- ]
- )
- else:
- logger.error("data should have either 2 or 3 dimensions")
-
-
-@dataclass
-class Mediapipe2dDataPayload:
- raw_frame_payload: FramePayload = None
- mediapipe_results: Any = None
- annotated_image: np.ndarray = None
- pixel_data_numpy_arrays: Mediapipe2dNumpyArrays = None
-
-
class MediaPipeSkeletonDetector:
def __init__(
self,
parameter_model=MediapipeParametersModel(),
+ use_tqdm: bool = True,
):
self._parameter_model = parameter_model
+ self._use_tqdm = use_tqdm
self._mediapipe_payload_list = []
self._mediapipe_tracked_point_names_dict = mediapipe_tracked_point_names_dict
@@ -117,7 +68,8 @@ class MediaPipeSkeletonDetector:
output_data_folder_path: Path,
mediapipe_parameters_model: MediapipeParametersModel,
annotate_image: Callable,
- list_of_mediapipe_results_to_npy_arrays: 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)}")
@@ -140,14 +92,18 @@ class MediaPipeSkeletonDetector:
number_of_frames = int(video_capture_object.get(cv2.CAP_PROP_FRAME_COUNT))
- for frame_number in tqdm(
+ if use_tqdm:
+ iterator = tqdm(
range(number_of_frames),
desc=f"mediapiping video: {synchronized_video_file_path.name}",
total=number_of_frames,
colour="magenta",
unit="frames",
- dynamic_ncols=True,
- ):
+ dynamic_ncols=True, )
+ else:
+ iterator = range(number_of_frames)
+
+ for frame_number in iterator:
if not success or image is None:
logger.error(f"Failed to load an image from: {str(synchronized_video_file_path)}")
raise Exception
@@ -220,11 +176,11 @@ class MediaPipeSkeletonDetector:
self._parameter_model,
self._annotate_image,
self._list_of_mediapipe_results_to_npy_arrays,
+ self._use_tqdm,
) for video_path in
video_paths]
mediapipe2d_single_camera_npy_arrays_list = pool.starmap(self.process_single_video, tasks)
-
all_cameras_data2d_list = [
m2d.all_data2d_nFrames_nTrackedPts_XY for m2d in mediapipe2d_single_camera_npy_arrays_list
]
diff --git a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_names_and_connections.py b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_names_and_connections.py
index 47b89f4d..6c7cba2e 100644
--- a/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_names_and_connections.py
+++ b/freemocap/core_processes/detecting_things_in_2d_images/mediapipe_stuff/mediapipe_skeleton_names_and_connections.py
@@ -1,9 +1,12 @@
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]
+
mediapipe_face_connections = [connection for connection in mp_holistic.FACEMESH_CONTOURS]
mediapipe_body_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark]
@@ -46,9 +49,56 @@ mediapipe_names_and_connections_dict = {
"connections": mediapipe_face_connections,
},
}
-
+mediapipe_virtual_marker_definitions_dict = {
+ "head_center": {
+ "marker_names": ["left_ear", "right_ear"],
+ "marker_weights": [0.5, 0.5],
+ },
+ "neck_center": {
+ "marker_names": ["left_shoulder", "right_shoulder"],
+ "marker_weights": [0.5, 0.5],
+ },
+ "trunk_center": {
+ "marker_names": ["left_shoulder", "right_shoulder", "left_hip", "right_hip"],
+ "marker_weights": [0.25, 0.25, 0.25, 0.25],
+ },
+ "hips_center": {
+ "marker_names": ["left_hip", "right_hip"],
+ "marker_weights": [0.5, 0.5],
+ },
+}
+mediapipe_skeleton_schema = {
+ "body": {
+ "point_names": mediapipe_body_landmark_names,
+ "connections": mediapipe_body_connections,
+ "virtual_marker_definitions": mediapipe_virtual_marker_definitions_dict,
+ "parent": "hips_center"
+ },
+ "hands": {
+ "right": {
+ "point_names": [name for name in mediapipe_hand_landmark_names],
+ "connections": mediapipe_hand_connections,
+ "parent": "right_wrist",
+ },
+ "left": {
+ "point_names": [name for name in mediapipe_hand_landmark_names],
+ "connections": mediapipe_hand_connections,
+ "parent": "left_wrist",
+ },
+ },
+ "face": {
+ "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)
- pprint.pp(mediapipe_tracked_point_names_dict)
+ print("=====================================================")
+ print("mediapipe_skeleton_schema:")
+ pprint.pp(mediapipe_skeleton_schema)
\ No newline at end of file
diff --git a/freemocap/core_processes/post_process_skeleton_data/gap_fill_filter_and_origin_align_skeleton_data.py b/freemocap/core_processes/post_process_skeleton_data/gap_fill_filter_and_origin_align_skeleton_data.py
index 3ae39066..e9f82484 100644
--- a/freemocap/core_processes/post_process_skeleton_data/gap_fill_filter_and_origin_align_skeleton_data.py
+++ b/freemocap/core_processes/post_process_skeleton_data/gap_fill_filter_and_origin_align_skeleton_data.py
@@ -11,7 +11,7 @@ from scipy import signal
from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_names_and_connections import \
NUMBER_OF_MEDIAPIPE_BODY_MARKERS
-from freemocap.system.paths_and_files_names import (
+from freemocap.system.paths_and_filenames.file_and_folder_names import (
CENTER_OF_MASS_FOLDER_NAME,
SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME,
TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME,
@@ -811,7 +811,7 @@ def build_mediapipe_skeleton(mediapipe_pose_data, segment_dataframe, mediapipe_i
# Winter, D.A. (2005) Biomechanics and Motor Control of Human Movement. 3rd Edition, John Wiley & Sons, Inc., Hoboken.
-segments = [
+BODY_SEGMENT_NAMES = [
"head",
"trunk",
"right_upper_arm",
@@ -1063,7 +1063,7 @@ def gap_fill_filter_origin_align_3d_data_and_then_calculate_center_of_mass(
# Calculate segment and total body COM
anthropometric_info_dataframe = build_anthropometric_dataframe(
- segments, joint_connections, segment_COM_lengths, segment_COM_percentages
+ BODY_SEGMENT_NAMES, joint_connections, segment_COM_lengths, segment_COM_percentages
)
skelcoordinates_frame_segment_joint_XYZ = build_mediapipe_skeleton(
processed_skel3d_frame_marker_xyz,
diff --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.py
index 265ce2fa..8b57952e 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
@@ -1,11 +1,11 @@
-from pathlib import Path
import logging
+from pathlib import Path
from typing import Union
import numpy as np
from freemocap.core_processes.capture_volume_calibration.triangulate_3d_data import save_mediapipe_3d_data_to_npy
-from freemocap.utilities.project_3d_data_to_z_plane import project_3d_data_to_z_plane
+from freemocap.utilities.geometry.project_3d_data_to_z_plane import project_3d_data_to_z_plane
logger = logging.getLogger(__name__)
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.py
index 2fa561db..98664080 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
@@ -1,20 +1,10 @@
import logging
-import numpy as np
import multiprocessing
from pathlib import Path
+import numpy as np
import pandas as pd
-from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_names_and_connections import (
- mediapipe_names_and_connections_dict,
-)
-from freemocap.core_processes.post_process_skeleton_data.process_single_camera_skeleton_data import \
- process_single_camera_skeleton_data
-from freemocap.system.paths_and_files_names import (
- MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME,
- RAW_DATA_FOLDER_NAME,
- RECORDING_PARAMETER_DICT_JSON_FILE_NAME,
-)
from freemocap.core_processes.capture_volume_calibration.anipose_camera_calibration.get_anipose_calibration_object import (
load_anipose_calibration_toml_from_path,
)
@@ -27,6 +17,9 @@ from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.conv
from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_detector import (
MediaPipeSkeletonDetector,
)
+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_names_and_connections import (
+ mediapipe_names_and_connections_dict,
+)
from freemocap.core_processes.post_process_skeleton_data.estimate_skeleton_segment_lengths import (
estimate_skeleton_segment_lengths,
mediapipe_skeleton_segment_definitions,
@@ -34,27 +27,36 @@ from freemocap.core_processes.post_process_skeleton_data.estimate_skeleton_segme
from freemocap.core_processes.post_process_skeleton_data.gap_fill_filter_and_origin_align_skeleton_data import (
gap_fill_filter_origin_align_3d_data_and_then_calculate_center_of_mass,
)
-from freemocap.parameter_info_models.recording_processing_parameter_models import RecordingProcessingParameterModel
+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 DataSaver
+
+from freemocap.data_layer.recording_models.post_processing_parameter_models import PostProcessingParameterModel
+from freemocap.system.paths_and_filenames.file_and_folder_names import (
+ MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME,
+ RAW_DATA_FOLDER_NAME,
+)
from freemocap.tests.test_image_tracking_data_shape import (
test_image_tracking_data_shape,
)
from freemocap.tests.test_mediapipe_skeleton_data_shape import test_mediapipe_skeleton_data_shape
-from freemocap.utilities.rotate_by_90_degrees_around_x_axis import rotate_by_90_degrees_around_x_axis
+from freemocap.utilities.geometry.rotate_by_90_degrees_around_x_axis import rotate_by_90_degrees_around_x_axis
from freemocap.utilities.save_dictionary_to_json import save_dictionary_to_json
logger = logging.getLogger(__name__)
def process_recording_folder(
- recording_processing_parameter_model: RecordingProcessingParameterModel,
+ recording_processing_parameter_model: PostProcessingParameterModel,
kill_event: multiprocessing.Event = None,
+ use_tqdm: bool = True,
):
"""
Parameters
----------
- recording_processing_parameter_model : RecordingProcessingParameterModel
+ recording_processing_parameter_model : PostProcessingParameterModel
RecordingProcessingParameterModel object (contains all the paths and parameters necessary to process a session folder
"""
@@ -66,18 +68,20 @@ def process_recording_folder(
f"Could not find synchronized_videos folder at {rec.recording_info_model.synchronized_videos_folder_path}"
)
-
- logger.info("Detecting 2d skeletons...")
+
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}")
try:
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")
return
else:
+ logger.info("Detecting 2d skeletons...")
# 2d skeleton detection
mediapipe_skeleton_detector = MediaPipeSkeletonDetector(
parameter_model=rec.mediapipe_parameters_model,
+ use_tqdm=use_tqdm,
)
mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ = mediapipe_skeleton_detector.process_folder_full_of_videos(
@@ -92,20 +96,20 @@ def process_recording_folder(
try:
assert test_image_tracking_data_shape(
synchronized_video_folder_path=rec.recording_info_model.synchronized_videos_folder_path,
- image_tracking_data_file_name=rec.recording_info_model.mediapipe_2d_data_npy_file_path,
+ image_tracking_data_file_path=rec.recording_info_model.mediapipe_2d_data_npy_file_path,
)
except AssertionError as error_message:
logger.error(error_message)
- # spoof 3D data if single camera
- if mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ.shape[0] == 1:
+ if mediapipe_image_data_numCams_numFrames_numTrackedPts_XYZ.shape[0] == 1:
+ # 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))
-
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}")
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)
else:
@@ -134,7 +138,7 @@ def process_recording_folder(
assert test_mediapipe_skeleton_data_shape(
synchronized_video_folder_path=rec.recording_info_model.synchronized_videos_folder_path,
raw_skeleton_npy_file_path=rec.recording_info_model.raw_mediapipe_3d_data_npy_file_path,
- reprojection_error_file_name=rec.recording_info_model.mediapipe_reprojection_error_data_npy_file_path,
+ reprojection_error_file_path=rec.recording_info_model.mediapipe_reprojection_error_data_npy_file_path,
)
except AssertionError as error_message:
logger.error(error_message)
@@ -161,7 +165,7 @@ def process_recording_folder(
test_mediapipe_skeleton_data_shape(
synchronized_video_folder_path=rec.recording_info_model.synchronized_videos_folder_path,
raw_skeleton_npy_file_path=rec.recording_info_model.mediapipe_3d_data_npy_file_path,
- reprojection_error_file_name=rec.recording_info_model.mediapipe_reprojection_error_data_npy_file_path,
+ reprojection_error_file_path=rec.recording_info_model.mediapipe_reprojection_error_data_npy_file_path,
)
except AssertionError as error_message:
logger.error(error_message)
@@ -196,3 +200,8 @@ def process_recording_folder(
file_name="mediapipe_names_and_connections_dict.json",
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)
+ 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
diff --git a/freemocap/tests/utilities/process_recording_headless.py b/freemocap/core_processes/process_motion_capture_videos/process_recording_headless.py
similarity index 67%
rename from freemocap/tests/utilities/process_recording_headless.py
rename to freemocap/core_processes/process_motion_capture_videos/process_recording_headless.py
index 7ab97f05..00b3a68e 100644
--- a/freemocap/tests/utilities/process_recording_headless.py
+++ b/freemocap/core_processes/process_motion_capture_videos/process_recording_headless.py
@@ -3,14 +3,16 @@ from pathlib import Path
from typing import Optional, Union
from freemocap.core_processes.process_motion_capture_videos.process_recording_folder import process_recording_folder
-from freemocap.export_data.blender_stuff.export_to_blender import export_to_blender
-from freemocap.export_data.generate_jupyter_notebook.generate_jupyter_notebook import generate_jupyter_notebook
-from freemocap.parameter_info_models.recording_info_model import RecordingInfoModel
-from freemocap.parameter_info_models.recording_processing_parameter_models import RecordingProcessingParameterModel
-from freemocap.system.paths_and_files_names import RECORDING_PARAMETER_DICT_JSON_FILE_NAME, get_blender_file_path
-from freemocap.utilities.save_dictionary_to_json import save_dictionary_to_json
+from freemocap.data_layer.export_data.blender_stuff.export_to_blender import export_to_blender
+from 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.recording_models.post_processing_parameter_models import PostProcessingParameterModel
+from freemocap.data_layer.recording_models.recording_info_model import RecordingInfoModel
+from freemocap.system.paths_and_filenames.file_and_folder_names import RECORDING_PARAMETERS_JSON_FILE_NAME
+from freemocap.system.paths_and_filenames.path_getters import get_blender_file_path
+from freemocap.utilities.download_sample_data import get_sample_data_path
from freemocap.utilities.get_video_paths import get_video_paths
-
+from freemocap.utilities.save_dictionary_to_json import save_dictionary_to_json
logger = logging.getLogger(__name__)
@@ -18,9 +20,10 @@ 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]] = None,
+ path_to_blender_executable: Optional[Union[str, Path]] = get_best_guess_of_blender_path(),
recording_processing_parameter_model: Optional[
- RecordingProcessingParameterModel] = RecordingProcessingParameterModel(),
+ PostProcessingParameterModel] = PostProcessingParameterModel(),
+ use_tqdm: bool = True,
):
rec = recording_processing_parameter_model
@@ -34,11 +37,12 @@ def process_recording_headless(
if path_to_camera_calibration_toml:
rec.recording_info_model.calibration_toml_path = Path(path_to_camera_calibration_toml)
- else:
+
+ if rec.recording_info_model.calibration_toml_path is None:
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.")
-
+ raise ValueError(
+ 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'})
@@ -47,13 +51,13 @@ def process_recording_headless(
save_dictionary_to_json(
save_path=rec.recording_info_model.output_data_folder_path,
- file_name=RECORDING_PARAMETER_DICT_JSON_FILE_NAME,
+ file_name=RECORDING_PARAMETERS_JSON_FILE_NAME,
dictionary=recording_info_dict,
)
logger.info("Starting core processing pipeline...")
-
- process_recording_folder(recording_processing_parameter_model=rec)
+ 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)
@@ -79,4 +83,4 @@ if __name__ == "__main__":
recording_path = Path("PATH/TO/RECORDING/FOLDER")
blender_path = Path("PATH/TO/BLENDER/EXECUTABLE")
- process_recording_headless(recording_path=recording_path, path_to_blender_executable=blender_path)
+ process_recording_headless(recording_path=get_sample_data_path())
diff --git a/freemocap/export_data/__init__.py b/freemocap/data_layer/__init__.py
similarity index 100%
rename from freemocap/export_data/__init__.py
rename to freemocap/data_layer/__init__.py
diff --git a/freemocap/export_data/blender_stuff/__init__.py b/freemocap/data_layer/data_saver/__init__.py
similarity index 100%
rename from freemocap/export_data/blender_stuff/__init__.py
rename to freemocap/data_layer/data_saver/__init__.py
diff --git a/freemocap/data_layer/data_saver/data_models.py b/freemocap/data_layer/data_saver/data_models.py
new file mode 100644
index 00000000..08a79d45
--- /dev/null
+++ b/freemocap/data_layer/data_saver/data_models.py
@@ -0,0 +1,90 @@
+import json
+import pprint
+from typing import List, Dict, Tuple
+from typing import Optional, Any
+
+from pydantic import BaseModel, Field, root_validator
+
+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_names_and_connections import \
+ mediapipe_skeleton_schema
+from freemocap.utilities.create_nested_dict_from_pydantic import create_nested_dict
+
+
+class Point(BaseModel):
+ 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):
+ 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_validator
+ def check_weights(cls, values):
+ marker_weights = values.get("marker_weights")
+ if sum(marker_weights) != 1:
+ raise ValueError(f"Marker weights must sum to 1, got {marker_weights}")
+ return values
+
+class Schema(BaseModel):
+ 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: Schema = Field(default_factory=Schema, description="The tracked points that define the body")
+ hands: Dict[str, Schema] = Field(default_factory=dict, description="The tracked points that define the hands: keys - (left, right)")
+ face: Schema = Field(default_factory=Schema, description="The tracked points that define the face")
+
+ def __init__(self, schema_dict: Dict[str, Dict[str, Any]]):
+ super().__init__()
+ self.body = Schema(**schema_dict["body"])
+ self.hands = {hand: Schema(**hand_schema) for hand, hand_schema in schema_dict["hands"].items()}
+ self.face = Schema(**schema_dict["face"])
+
+ def to_dict(self):
+ d = {}
+ d["body"] = self.body.dict()
+ d["hands"] = {hand: hand_schema.dict() for hand, hand_schema in self.hands.items()}
+ d["face"] = self.face.dict()
+ return d
+
+
+class Timestamps(BaseModel):
+ # TODO - Add Unix time and ISO format stuff and whatnot
+ mean: 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)")
+
+class FrameData(BaseModel):
+ timestamps: Timestamps = Field(default_factory=Timestamps, description="Timestamp data")
+ tracked_points: Dict[str, Point] = Field(default_factory=dict, description="The points being tracked")
+ @property
+ def tracked_point_names(self):
+ return list(self.tracked_points.keys())
+
+ @property
+ def timestamp(self):
+ return self.timestamps.mean
+
+ def to_dict(self):
+ d = {}
+ d["timestamps"] = self.timestamps.dict()
+ d["tracked_points"] = {name: point.dict() for name, point in self.tracked_points.items()}
+ return d
+
+class InfoDict(BaseModel):
+ 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")
+
+
+if __name__ == "__main__":
+ # nested_dict = create_nested_dict(FramePacket)
+ # print(json.dumps(nested_dict, indent=4))
+
+ print("=====================================\n\n===============================")
+
+ skeleton_schema = SkeletonSchema(schema_dict=mediapipe_skeleton_schema)
+
+ pprint.pp(skeleton_schema.to_dict())
+
diff --git a/freemocap/data_layer/data_saver/data_saver.py b/freemocap/data_layer/data_saver/data_saver.py
new file mode 100644
index 00000000..f758294a
--- /dev/null
+++ b/freemocap/data_layer/data_saver/data_saver.py
@@ -0,0 +1,301 @@
+import json
+import logging
+from pathlib import Path
+from typing import Union
+
+import numpy as np
+import pandas as pd
+
+from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_names_and_connections import \
+ mediapipe_skeleton_schema
+from freemocap.core_processes.post_process_skeleton_data.gap_fill_filter_and_origin_align_skeleton_data import \
+ BODY_SEGMENT_NAMES
+from freemocap.data_layer.data_saver.data_models import FrameData, Timestamps, Point, InfoDict, 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_total_body_center_of_mass_file_path, get_segment_center_of_mass_file_path, get_full_npy_file_path, \
+ get_timestamps_directory
+
+logger = logging.getLogger(__name__)
+
+from typing import Any, Dict
+
+
+class DataSaver:
+
+ 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.
+
+ Args:
+ recording_folder_path (Union[Path, str]): path to the folder containing the recording data.
+ include_hands (bool): flag to include hands data in the processing.
+ include_face (bool): flag to include face data in the processing.
+ """
+ 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.recording_data_by_frame = None
+ self.number_of_frames = None
+
+ def save_all(self):
+ """
+ Load all data, validate it, and create the recording_data_by_frame_number dictionary.
+
+ Returns:
+ Dict[int, Dict]: a dictionary containing the processed data, indexed by frame number.
+ """
+
+ self.recording_data_by_frame = self._data_loader.get_data_by_frame()
+
+ self.save_to_json()
+ self.save_to_csv()
+ self.save_to_npy()
+
+ 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
+
+ if save_path is None:
+ save_path = self.recording_folder_path / f"{self._recording_name}_by_frame.json"
+
+ logger.info(f"Saving recording data to {save_path}")
+ with open(save_path, 'w') as file:
+ json.dump(dict_to_save, file, indent=4)
+
+ def save_to_csv(self, save_path: Union[str, Path] = None):
+ data_for_dataframe = []
+
+ for frame_data in self.recording_data_by_frame.values():
+ data_for_dataframe.append(self._generate_frame_data_row(frame_data))
+
+ # Create DataFrame and save to csv
+ df = pd.DataFrame(data_for_dataframe)
+
+ if save_path is None:
+ save_path = self.recording_folder_path / f"{self._recording_name}_by_trajectory.csv"
+
+ df.to_csv(save_path, index=False)
+ logger.info(f"Saved recording data to {save_path}")
+
+ def save_to_npy(self, save_path: Union[str, Path] = None):
+ if save_path is None:
+ save_path = self.recording_folder_path / f"{self._recording_name}_frame_name_xyz.npy"
+ np.save(save_path, self._data_loader.data_frame_name_xyz)
+ logger.info(f"Saved recording data to {save_path}")
+
+ def _generate_frame_data_row(self, frame_data: Dict[str, Any]) -> Dict:
+ """
+ Generate a data row for a given frame number.
+ """
+ frame_data_row = {}
+
+ 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():
+ 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"]
+
+ return frame_data_row
+
+ def _get_info_dict(self):
+ return InfoDict(
+ segment_lengths=self._data_loader.segment_lengths,
+ schemas=[self._data_loader.skeleton_schema.dict()],
+ )
+
+
+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_hands
+ self.include_face = include_face
+
+ self._recording_name = self._recording_folder_path.name
+ self._output_folder_path = Path(get_output_data_folder_path(self._recording_folder_path))
+
+ self._load_data()
+
+ def _load_data(self):
+ self._load_timestamps()
+ self._load_data_frames()
+ self._load_full_npy_data()
+ self._load_center_of_mass_data()
+ self._load_segment_lengths()
+ self._load_names_and_connections()
+ self._load_skeleton_schema()
+ self._validate_data()
+
+ def _load_data_frames(self):
+ self.body_dataframe = self._load_dataframe(MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME)
+ self.number_of_frames = len(self.body_dataframe)
+ if self.include_hands:
+ self.right_hand_dataframe = self._load_dataframe(MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME)
+ self.left_hand_dataframe = self._load_dataframe(MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME)
+ if self.include_face:
+ self.face_dataframe = self._load_dataframe(MEDIAPIPE_FACE_3D_DATAFRAME_CSV_FILE_NAME)
+
+ def _load_dataframe(self, filename):
+ 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')
+
+ 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.")
+
+ 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.")
+
+ def _load_timestamps(self):
+ timestamps_directory = get_timestamps_directory(recording_directory=self._recording_folder_path)
+ if timestamps_directory is None:
+ logger.warning("No timestamps directory found. Skipping timestamps loading.")
+ return
+
+ timestamps_by_camera = {}
+ for timestamps_npy in Path(timestamps_directory).glob("*.npy"):
+ camera_name = timestamps_npy.stem
+ timestamps_by_camera[camera_name] = np.load(str(timestamps_npy))
+
+ self._timestamps_by_camera = timestamps_by_camera
+ timestamps = [timestamps for timestamps in timestamps_by_camera.values()]
+ self._timestamps_mean_per_frame = np.nanmean(np.asarray(timestamps), axis=0)
+
+ def _load_center_of_mass_data(self):
+ """
+ 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))
+ self.segment_center_of_mass_segment_xyz = np.load(
+ 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:
+ 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:
+ 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))
+
+ 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()})
+ except AttributeError:
+ return Timestamps()
+
+ def get_tracked_points(self, frame_number) -> Dict[str, Point]:
+
+ right_hand_points = {}
+ left_hand_points = {}
+ face_points = {}
+
+ body_points = self._process_dataframe(self.body_dataframe.iloc[frame_number, :])
+ center_of_mass_points = self._get_center_of_mass_data(frame_number)
+
+ if self.include_hands:
+ left_hand_points, right_hand_points = self._load_hand_data(frame_number)
+
+ if self.include_face:
+ face_points = self._process_dataframe(self.face_dataframe.iloc[frame_number, :])
+
+ all_points = {}
+ all_points.update(body_points)
+ all_points.update(center_of_mass_points)
+ all_points.update(right_hand_points)
+ all_points.update(left_hand_points)
+ all_points.update(face_points)
+
+ return all_points
+
+ def _load_hand_data(self, frame_number: int):
+ right_hand_points = self._process_dataframe(self.right_hand_dataframe.iloc[frame_number, :])
+ left_hand_points = self._process_dataframe(self.left_hand_dataframe.iloc[frame_number, :])
+ return left_hand_points, right_hand_points
+
+ def _get_center_of_mass_data(self, frame_number: int):
+ """
+ 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])
+
+ 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])
+
+ return com_data
+
+ def _process_dataframe(self, data_frame) -> Dict[str, Any]:
+ """
+ Process a single row from a dataframe and add it to the recording_data_by_frame_number dictionary.
+
+ Args:
+ data_frame (DataFrame): the dataframe to process.
+ """
+ tracked_points = {}
+ column_names = list(data_frame.index)
+ for column_name in column_names:
+ point_name = column_name[:-2] # e.g. "nose" or "left_knee" or whatever
+ dimension = column_name[-1] # e.g. "x" or "y" or "z"
+
+ value = data_frame[column_name]
+ if pd.isna(value): # Check if value is NaN
+ value = None # Replace NaN with None which is valid in JSON
+
+ tracked_points.setdefault(point_name, {})[dimension] = value
+
+ return tracked_points
+
+ def get_data_by_frame(self):
+ recording_data_by_frame_number = {}
+ for frame_number in range(self.number_of_frames):
+ recording_data_by_frame_number[frame_number] = self.load_frame_data(frame_number).to_dict()
+ return recording_data_by_frame_number
+
+ def _load_skeleton_schema(self):
+ self.skeleton_schema = SkeletonSchema(schema_dict=mediapipe_skeleton_schema)
+
+
+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_data_by_frame_number = recording_data_saver.save_all()
diff --git a/freemocap/export_data/blender_stuff/blender_bpy_export_scripts/__init__.py b/freemocap/data_layer/export_data/__init__.py
similarity index 100%
rename from freemocap/export_data/blender_stuff/blender_bpy_export_scripts/__init__.py
rename to freemocap/data_layer/export_data/__init__.py
diff --git a/freemocap/export_data/generate_jupyter_notebook/__init__.py b/freemocap/data_layer/export_data/blender_stuff/__init__.py
similarity index 100%
rename from freemocap/export_data/generate_jupyter_notebook/__init__.py
rename to freemocap/data_layer/export_data/blender_stuff/__init__.py
diff --git a/freemocap/parameter_info_models/__init__.py b/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/__init__.py
similarity index 100%
rename from freemocap/parameter_info_models/__init__.py
rename to freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/__init__.py
diff --git a/freemocap/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
similarity index 99%
rename from freemocap/export_data/blender_stuff/blender_bpy_export_scripts/alpha_freemocap_blender_megascript.py
rename to freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/alpha_freemocap_blender_megascript.py
index 3608e0c7..553f3972 100644
--- a/freemocap/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
@@ -4,7 +4,6 @@ from pathlib import Path
import bpy
import numpy as np
-
print(" - Starting (alpha) blender megascript - ")
#######################################################################
diff --git a/freemocap/export_data/blender_stuff/blender_bpy_export_scripts/cgtinker_blendarmocap_load.py b/freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/cgtinker_blendarmocap_load.py
similarity index 100%
rename from freemocap/export_data/blender_stuff/blender_bpy_export_scripts/cgtinker_blendarmocap_load.py
rename to freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/cgtinker_blendarmocap_load.py
diff --git a/freemocap/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
similarity index 99%
rename from freemocap/export_data/blender_stuff/blender_bpy_export_scripts/freemocap_blender_megascript_take2.py
rename to freemocap/data_layer/export_data/blender_stuff/blender_bpy_export_scripts/freemocap_blender_megascript_take2.py
index 9c8870d7..7619bd21 100644
--- a/freemocap/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
@@ -9,7 +9,6 @@ import addon_utils
import bpy
import numpy as np
-
print("Running script to create Blender file from freemocap session data: " + __file__)
logger = logging.getLogger(__name__)
diff --git a/freemocap/export_data/blender_stuff/call_blender_subprocess_methods.py b/freemocap/data_layer/export_data/blender_stuff/call_blender_subprocess_methods.py
similarity index 98%
rename from freemocap/export_data/blender_stuff/call_blender_subprocess_methods.py
rename to freemocap/data_layer/export_data/blender_stuff/call_blender_subprocess_methods.py
index c2d6f2e8..8409ccbb 100644
--- a/freemocap/export_data/blender_stuff/call_blender_subprocess_methods.py
+++ b/freemocap/data_layer/export_data/blender_stuff/call_blender_subprocess_methods.py
@@ -10,7 +10,7 @@ from typing import Union
from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.mediapipe_skeleton_names_and_connections import (
mediapipe_names_and_connections_dict,
)
-from freemocap.system.paths_and_files_names import OUTPUT_DATA_FOLDER_NAME
+from freemocap.system.paths_and_filenames.file_and_folder_names import OUTPUT_DATA_FOLDER_NAME
from freemocap.utilities.save_dictionary_to_json import save_dictionary_to_json
logger = logging.getLogger(__name__)
diff --git a/freemocap/export_data/blender_stuff/export_to_blender.py b/freemocap/data_layer/export_data/blender_stuff/export_to_blender.py
similarity index 90%
rename from freemocap/export_data/blender_stuff/export_to_blender.py
rename to freemocap/data_layer/export_data/blender_stuff/export_to_blender.py
index 67206bd2..d4994f66 100644
--- a/freemocap/export_data/blender_stuff/export_to_blender.py
+++ b/freemocap/data_layer/export_data/blender_stuff/export_to_blender.py
@@ -2,12 +2,12 @@ import logging
from pathlib import Path
from typing import Union
-from freemocap.export_data.blender_stuff.call_blender_subprocess_methods import (
+from freemocap.data_layer.export_data.blender_stuff.call_blender_subprocess_methods import (
call_blender_subprocess_megascript_take2,
call_blender_subprocess_cgtinker,
call_blender_subprocess_alpha_megascript,
)
-from freemocap.export_data.blender_stuff.get_best_guess_of_blender_path import (
+from freemocap.data_layer.export_data.blender_stuff.get_best_guess_of_blender_path import (
get_best_guess_of_blender_path,
)
diff --git a/freemocap/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
similarity index 100%
rename from freemocap/export_data/blender_stuff/get_best_guess_of_blender_path.py
rename to freemocap/data_layer/export_data/blender_stuff/get_best_guess_of_blender_path.py
diff --git a/freemocap/data_layer/export_data/generate_jupyter_notebook/__init__.py b/freemocap/data_layer/export_data/generate_jupyter_notebook/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/freemocap/export_data/generate_jupyter_notebook/freemocap_template.ipynb b/freemocap/data_layer/export_data/generate_jupyter_notebook/freemocap_template.ipynb
similarity index 100%
rename from freemocap/export_data/generate_jupyter_notebook/freemocap_template.ipynb
rename to freemocap/data_layer/export_data/generate_jupyter_notebook/freemocap_template.ipynb
diff --git a/freemocap/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py b/freemocap/data_layer/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py
similarity index 99%
rename from freemocap/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py
rename to freemocap/data_layer/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py
index 19a58b9b..847e34b5 100644
--- a/freemocap/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py
+++ b/freemocap/data_layer/export_data/generate_jupyter_notebook/generate_jupyter_notebook.py
@@ -3,6 +3,7 @@ from pathlib import Path
from typing import Union
import papermill as pm
+
logging.getLogger('papermill').setLevel(logging.WARNING)
logger = logging.getLogger(__name__)
diff --git a/freemocap/data_layer/recording_models/__init__.py b/freemocap/data_layer/recording_models/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/freemocap/parameter_info_models/recording_processing_parameter_models.py b/freemocap/data_layer/recording_models/post_processing_parameter_models.py
similarity index 91%
rename from freemocap/parameter_info_models/recording_processing_parameter_models.py
rename to freemocap/data_layer/recording_models/post_processing_parameter_models.py
index b98a1790..1c3acbe5 100644
--- a/freemocap/parameter_info_models/recording_processing_parameter_models.py
+++ b/freemocap/data_layer/recording_models/post_processing_parameter_models.py
@@ -2,7 +2,7 @@ import logging
from pydantic import BaseModel
-from freemocap.parameter_info_models.recording_info_model import (
+from freemocap.data_layer.recording_models.recording_info_model import (
RecordingInfoModel,
)
@@ -28,7 +28,6 @@ class ButterworthFilterParametersModel(BaseModel):
cutoff_frequency: float = 7
order: int = 4
-
class PostProcessingParametersModel(BaseModel):
framerate: float = 30.0
butterworth_filter_parameters = ButterworthFilterParametersModel()
@@ -36,7 +35,7 @@ class PostProcessingParametersModel(BaseModel):
skip_butterworth_filter: bool = False
-class RecordingProcessingParameterModel(BaseModel):
+class PostProcessingParameterModel(BaseModel):
recording_info_model: RecordingInfoModel = None
mediapipe_parameters_model: MediapipeParametersModel = MediapipeParametersModel()
anipose_triangulate_3d_parameters_model: AniposeTriangulate3DParametersModel = AniposeTriangulate3DParametersModel()
diff --git a/freemocap/parameter_info_models/recording_info_model.py b/freemocap/data_layer/recording_models/recording_info_model.py
similarity index 94%
rename from freemocap/parameter_info_models/recording_info_model.py
rename to freemocap/data_layer/recording_models/recording_info_model.py
index b2d063e3..2a09d231 100644
--- a/freemocap/parameter_info_models/recording_info_model.py
+++ b/freemocap/data_layer/recording_models/recording_info_model.py
@@ -1,11 +1,10 @@
import logging
from pathlib import Path
-from typing import Union, Dict, Any
+from typing import Union, Dict
import numpy as np
-import toml
-from freemocap.system.paths_and_files_names import (
+from freemocap.system.paths_and_filenames.file_and_folder_names import (
CENTER_OF_MASS_FOLDER_NAME,
MEDIAPIPE_2D_NPY_FILE_NAME,
RAW_MEDIAPIPE_3D_NPY_FILE_NAME,
@@ -14,18 +13,13 @@ from freemocap.system.paths_and_files_names import (
TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME,
MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME,
SYNCHRONIZED_VIDEOS_FOLDER_NAME,
- get_blender_file_path,
ANNOTATED_VIDEOS_FOLDER_NAME,
- MEDIAPIPE_3D_NPY_FILE_NAME, create_camera_calibration_file_name,
-)
+ MEDIAPIPE_3D_NPY_FILE_NAME, )
+from freemocap.system.paths_and_filenames.path_getters import create_camera_calibration_file_name, get_blender_file_path
from freemocap.tests.test_image_tracking_data_shape import test_image_tracking_data_shape
from freemocap.tests.test_mediapipe_skeleton_data_shape import test_mediapipe_skeleton_data_shape
-from freemocap.tests.test_synchronized_video_frame_counts import (
- test_synchronized_video_frame_counts,
-)
-from freemocap.tests.test_total_body_center_of_mass_data_shape import (
- test_total_body_center_of_mass_data_shape,
-)
+from freemocap.tests.test_synchronized_video_frame_counts import test_synchronized_video_frame_counts
+from freemocap.tests.test_total_body_center_of_mass_data_shape import test_total_body_center_of_mass_data_shape
logger = logging.getLogger(__name__)
@@ -143,6 +137,9 @@ class RecordingInfoModel:
return self._recording_folder_status_checker.check_center_of_mass_data_status()
+
+
+
class RecordingFolderStatusChecker:
def __init__(self, recording_info_model: RecordingInfoModel):
@@ -175,7 +172,7 @@ class RecordingFolderStatusChecker:
try:
test_image_tracking_data_shape(
synchronized_video_folder_path=self.recording_info_model.synchronized_videos_folder_path,
- image_tracking_data_file_name=self.recording_info_model.mediapipe_2d_data_npy_file_path,
+ image_tracking_data_file_path=self.recording_info_model.mediapipe_2d_data_npy_file_path,
)
return True
@@ -187,7 +184,7 @@ class RecordingFolderStatusChecker:
test_mediapipe_skeleton_data_shape(
synchronized_video_folder_path=self.recording_info_model.synchronized_videos_folder_path,
raw_skeleton_npy_file_path=self.recording_info_model.mediapipe_3d_data_npy_file_path,
- reprojection_error_file_name=self.recording_info_model.mediapipe_reprojection_error_data_npy_file_path,
+ reprojection_error_file_path=self.recording_info_model.mediapipe_reprojection_error_data_npy_file_path,
)
return True
except AssertionError as e:
diff --git a/freemocap/gui/qt/actions_and_menus/actions.py b/freemocap/gui/qt/actions_and_menus/actions.py
index f4b62f38..755d5ea4 100644
--- a/freemocap/gui/qt/actions_and_menus/actions.py
+++ b/freemocap/gui/qt/actions_and_menus/actions.py
@@ -1,6 +1,5 @@
-from PyQt6.QtGui import QAction, QDesktopServices
from PyQt6.QtCore import QUrl
-
+from PyQt6.QtGui import QAction, QDesktopServices
CREATE_NEW_RECORDING_ACTION_NAME = "New Recording"
LOAD_MOST_RECENT_RECORDING_ACTION_NAME = "Load Most Recent Recording"
diff --git a/freemocap/gui/qt/actions_and_menus/menu_bar.py b/freemocap/gui/qt/actions_and_menus/menu_bar.py
index 03427d2f..864e68c6 100644
--- a/freemocap/gui/qt/actions_and_menus/menu_bar.py
+++ b/freemocap/gui/qt/actions_and_menus/menu_bar.py
@@ -1,4 +1,5 @@
from PyQt6.QtWidgets import QMainWindow, QMenuBar
+
from freemocap.gui.qt.actions_and_menus.actions import Actions
diff --git a/freemocap/gui/qt/freemocap_main.py b/freemocap/gui/qt/freemocap_main.py
index 6cdd45fc..77b44b20 100644
--- a/freemocap/gui/qt/freemocap_main.py
+++ b/freemocap/gui/qt/freemocap_main.py
@@ -6,11 +6,9 @@ from pathlib import Path
from PyQt6.QtCore import QTimer
from PyQt6.QtWidgets import QApplication
-from freemocap.gui.qt.main_window.freemocap_main_window import FreemocapMainWindow, EXIT_CODE_REBOOT
+from freemocap.gui.qt.main_window.freemocap_main_window import MainWindow, EXIT_CODE_REBOOT
from freemocap.gui.qt.utilities.get_qt_app import get_qt_app
-from freemocap.system.paths_and_files_names import (
- get_freemocap_data_folder_path,
-)
+from freemocap.system.paths_and_filenames.path_getters import get_freemocap_data_folder_path
from freemocap.system.user_data.pipedream_pings import PipedreamPings
repo = Path(__file__).parent.parent.parent.parent
@@ -34,8 +32,8 @@ def qt_gui_main():
pipedream_pings = PipedreamPings()
while True:
- freemocap_main_window = FreemocapMainWindow(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)
freemocap_main_window.show()
timer.timeout.connect(freemocap_main_window.update)
error_code = app.exec()
diff --git a/freemocap/gui/qt/main_window/freemocap_main_window.py b/freemocap/gui/qt/main_window/freemocap_main_window.py
index 68b29033..24dad478 100644
--- a/freemocap/gui/qt/main_window/freemocap_main_window.py
+++ b/freemocap/gui/qt/main_window/freemocap_main_window.py
@@ -7,6 +7,7 @@ from typing import Union, List
from PyQt6.QtCore import Qt, pyqtSlot
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import (
+ QApplication,
QDockWidget,
QMainWindow,
QFileDialog,
@@ -15,21 +16,21 @@ from skelly_viewer import SkellyViewer
from skellycam import (
SkellyCamParameterTreeWidget,
SkellyCamWidget,
- SkellyCamControllerWidget,
)
from tqdm import tqdm
-from freemocap.export_data.blender_stuff.export_to_blender import (
+from freemocap.data_layer.export_data.blender_stuff.export_to_blender import (
export_to_blender,
)
-from freemocap.export_data.blender_stuff.get_best_guess_of_blender_path import \
- get_best_guess_of_blender_path
-from freemocap.export_data.generate_jupyter_notebook.generate_jupyter_notebook import generate_jupyter_notebook
+from 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.gui.qt.actions_and_menus.actions import Actions
from freemocap.gui.qt.actions_and_menus.menu_bar import MenuBar
from freemocap.gui.qt.style_sheet.css_file_watcher import CSSFileWatcher
from freemocap.gui.qt.style_sheet.scss_file_watcher import SCSSFileWatcher
from freemocap.gui.qt.style_sheet.set_css_style_sheet import apply_css_style_sheet
+from freemocap.gui.qt.utilities.copy_timestamps_folder import copy_directory_if_contains_timestamps
from freemocap.gui.qt.utilities.get_qt_app import get_qt_app
from freemocap.gui.qt.utilities.update_most_recent_recording_toml import (
update_most_recent_recording_toml,
@@ -50,30 +51,29 @@ from freemocap.gui.qt.widgets.home_widget import (
)
from freemocap.gui.qt.widgets.import_videos_window import ImportVideosWizard
from freemocap.gui.qt.widgets.log_view_widget import LogViewWidget
-from freemocap.parameter_info_models.recording_info_model import (
- RecordingInfoModel,
+from freemocap.data_layer.recording_models.post_processing_parameter_models import (
+ PostProcessingParameterModel,
)
-from freemocap.parameter_info_models.recording_processing_parameter_models import (
- RecordingProcessingParameterModel,
+from freemocap.data_layer.recording_models.recording_info_model import (
+ RecordingInfoModel,
)
# reboot GUI method based on this - https://stackoverflow.com/a/56563926/14662833
from freemocap.system.open_file import open_file
-from freemocap.system.paths_and_files_names import (
- get_scss_stylesheet_path,
- get_css_stylesheet_path,
- get_most_recent_recording_path,
+from freemocap.system.paths_and_filenames.file_and_folder_names import (
PATH_TO_FREEMOCAP_LOGO_SVG,
- get_blender_file_path,
- get_recording_session_folder_path,
)
+from freemocap.system.paths_and_filenames.path_getters import get_recording_session_folder_path, \
+ get_css_stylesheet_path, get_scss_stylesheet_path, get_most_recent_recording_path, get_blender_file_path, \
+ get_freemocap_data_folder_path
from freemocap.system.user_data.pipedream_pings import PipedreamPings
+from freemocap.utilities.remove_empty_directories import remove_empty_directories
EXIT_CODE_REBOOT = -123456789
logger = logging.getLogger(__name__)
-class FreemocapMainWindow(QMainWindow):
+class MainWindow(QMainWindow):
def __init__(
self,
freemocap_data_folder_path: Union[str, Path],
@@ -81,10 +81,11 @@ class FreemocapMainWindow(QMainWindow):
parent=None,
):
- logger.info("Initializing QtGUIMainWindow")
+ logger.info("Initializing FreeMoCap MainWindow")
super().__init__(parent=parent)
- self.setGeometry(100, 100, 1280, 720)
+ self._size_main_window()
+
self.setWindowIcon(QIcon(PATH_TO_FREEMOCAP_LOGO_SVG))
self.setWindowTitle(f"freemocap \U0001F480 \U00002728")
@@ -151,6 +152,18 @@ class FreemocapMainWindow(QMainWindow):
QDockWidget.DockWidgetFeature.DockWidgetMovable | QDockWidget.DockWidgetFeature.DockWidgetFloatable
)
+ def _size_main_window(self, width_fraction:float=0.8, height_fraction:float=0.8):
+ # Get screen size
+ screen = QApplication.primaryScreen().availableGeometry()
+ # Calculate width and height as a fraction of the screen size
+
+ width = screen.width() * width_fraction
+ height = screen.height() * height_fraction
+ # Position the window in the center of the screen
+ left = (screen.width() - width) / 2
+ top = (screen.height() - height) / 2
+ self.setGeometry(int(left), int(top), int(width), int(height))
+
def _create_tools_dock_widget(self):
tools_dock_widget = QDockWidget("Control Panel", self)
tools_dock_widget.setAllowedAreas(Qt.DockWidgetArea.LeftDockWidgetArea | Qt.DockWidgetArea.RightDockWidgetArea)
@@ -226,13 +239,8 @@ class FreemocapMainWindow(QMainWindow):
self._handle_videos_saved_to_this_folder_signal
)
- self._skellycam_controller_widget = SkellyCamControllerWidget(
- self._skellycam_widget,
- parent=self,
- )
-
self._controller_group_box = CameraControllerGroupBox(
- skellycam_controller=self._skellycam_controller_widget, parent=self
+ skellycam_widget=self._skellycam_widget,
)
self._skelly_viewer_widget = SkellyViewer()
@@ -285,7 +293,7 @@ class FreemocapMainWindow(QMainWindow):
# )
self._process_motion_capture_data_panel = ProcessMotionCaptureDataPanel(
- recording_processing_parameters=RecordingProcessingParameterModel(),
+ recording_processing_parameters=PostProcessingParameterModel(),
get_active_recording_info=self._active_recording_info_widget.get_active_recording_info,
kill_thread_event=self._kill_thread_event,
)
@@ -340,7 +348,6 @@ class FreemocapMainWindow(QMainWindow):
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
)
@@ -401,9 +408,7 @@ class FreemocapMainWindow(QMainWindow):
)
- def reboot_gui(self):
- logger.info("Rebooting GUI... ")
- get_qt_app().exit(EXIT_CODE_REBOOT)
+
def kill_running_threads_and_processes(self):
logger.info("Killing running threads and processes... ")
@@ -491,8 +496,20 @@ class FreemocapMainWindow(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)
+
+ if timestamps_copied:
+ logger.info(f"Copied timestamps from {Path(video_paths[0]).parent} to {folder_to_save_videos}")
+ else:
+ 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)
+ def reboot_gui(self):
+ logger.info("Rebooting GUI... ")
+ get_qt_app().exit(EXIT_CODE_REBOOT)
def closeEvent(self, a0) -> None:
logger.info("Main window `closeEvent` detected")
@@ -514,33 +531,20 @@ class FreemocapMainWindow(QMainWindow):
logger.error(f"Error while closing the viewer widget: {e}")
super().closeEvent(a0)
-
-def remove_empty_directories(root_dir: Union[str, Path]):
- """
- Recursively remove empty directories from the root directory
- :param root_dir: The root directory to start removing empty directories from
- """
- # logger.debug(f"Searching for empty directories in: {root_dir}")
- for path in Path(root_dir).rglob("*"):
- if path.is_dir() and not any(path.iterdir()):
- logger.info(f"Removing empty directory: {path}")
- path.rmdir()
- elif path.is_dir() and any(path.iterdir()):
- remove_empty_directories(path)
- else:
- continue
+ for process in multiprocessing.active_children():
+ logger.info(f"Terminating process: {process}")
+ process.terminate()
if __name__ == "__main__":
import sys
- from PyQt6.QtWidgets import QApplication
app = QApplication(sys.argv)
- main_window = FreemocapMainWindow(pipedream_pings=PipedreamPings())
+ main_window = MainWindow(pipedream_pings=PipedreamPings(),
+ freemocap_data_folder_path=get_freemocap_data_folder_path(),
+ )
main_window.show()
app.exec()
- for process in multiprocessing.active_children():
- logger.info(f"Terminating process: {process}")
- process.terminate()
+
sys.exit()
diff --git a/freemocap/gui/qt/style_sheet/AMOLED.qss b/freemocap/gui/qt/style_sheet/AMOLED.qss
deleted file mode 100644
index 12737962..00000000
--- a/freemocap/gui/qt/style_sheet/AMOLED.qss
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
-AMOLED Style Sheet for QT Applications
-Author: Jaime A. Quiroga P.
-Company: GTRONICK
-Last updated: 01/10/2021, 15:49.
-Available at: https://github.com/GTRONICK/QSS/blob/master/AMOLED.qss
-*/
-QMainWindow {
- background-color: #d00e0e;
-}
-QDialog {
- background-color: #b00505;
-}
-QColorDialog {
- background-color:#000000;
-}
-QTextEdit {
- background-color:#000000;
- color: #a9b7c6;
-}
-QPlainTextEdit {
- selection-background-color:#f39c12;
- background-color:#000000;
- border: 1px solid #FF00FF;
- color: #a9b7c6;
-}
-QPushButton{
- border: 1px transparent;
- color: #a9b7c6;
- padding: 2px;
- background-color: #670b8c;
- border-radius: 20px;
-}
-QPushButton::default{
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: #e06b04;
- border-width: 1px;
- color: #a9b7c6;
- padding: 2px;
- background-color: #000000;
-}
-QPushButton:hover{
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: #FF00FF;
- border-bottom-width: 1px;
- border-bottom-radius: 6px;
- border-style: solid;
- color: #FFFFFF;
- padding-bottom: 2px;
- background-color: #000000;
-}
-QPushButton:pressed{
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: #FF00FF;
- border-bottom-width: 2px;
- border-bottom-radius: 6px;
- border-style: solid;
- color: #e67e22;
- padding-bottom: 1px;
- background-color: #000000;
-}
-QPushButton:disabled{
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: transparent;
- border-bottom-width: 2px;
- border-bottom-radius: 6px;
- border-style: solid;
- color: #808086;
- padding-bottom: 1px;
- background-color: #000000;
-}
-QToolButton {
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: #e67e22;
- border-bottom-width: 1px;
- border-style: solid;
- color: #a9b7c6;
- padding: 2px;
- background-color: #000000;
-}
-QToolButton:hover{
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: #e67e22;
- border-bottom-width: 2px;
- border-bottom-radius: 6px;
- border-style: solid;
- color: #FFFFFF;
- padding-bottom: 1px;
- background-color: #000000;
-}
-QLineEdit {
- border-width: 1px; border-radius: 4px;
- border-color: rgb(58, 58, 58);
- border-style: inset;
- padding: 0 8px;
- color: #a9b7c6;
- background:#000000;
- selection-background-color:#007b50;
- selection-color: #FFFFFF;
-}
-QLabel {
- color: #a9b7c6;
-}
-QLCDNumber {
- color: #e67e22;
-}
-QProgressBar {
- text-align: center;
- color: rgb(240, 240, 240);
- border-width: 1px;
- border-radius: 10px;
- border-color: rgb(58, 58, 58);
- border-style: inset;
- background-color:#000000;
-}
-QProgressBar::chunk {
- background-color: #e67e22;
- border-radius: 5px;
-}
-QMenu{
- background-color:#000000;
-}
-QMenuBar {
- background:rgb(0, 0, 0);
- color: #a9b7c6;
-}
-QMenuBar::item {
- spacing: 3px;
- padding: 1px 4px;
- background: transparent;
-}
-QMenuBar::item:selected {
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: #e67e22;
- border-bottom-width: 1px;
- border-bottom-radius: 6px;
- border-style: solid;
- color: #FFFFFF;
- padding-bottom: 0px;
- background-color: #000000;
-}
-QMenu::item:selected {
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: #e67e22;
- border-bottom-color: transparent;
- border-left-width: 2px;
- color: #FFFFFF;
- padding-left:15px;
- padding-top:4px;
- padding-bottom:4px;
- padding-right:7px;
- background-color:#000000;
-}
-QMenu::item {
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: transparent;
- border-bottom-width: 1px;
- border-style: solid;
- color: #a9b7c6;
- padding-left:17px;
- padding-top:4px;
- padding-bottom:4px;
- padding-right:7px;
- background-color:#000000;
-}
-QTabWidget {
- color:rgb(0,0,0);
- background-color:#000000;
-}
-QTabWidget::pane {
- border-color: rgb(77,77,77);
- background-color:#000000;
- border-style: solid;
- border-width: 1px;
- border-radius: 6px;
-}
-QTabBar::tab {
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: transparent;
- border-bottom-width: 1px;
- border-style: solid;
- color: #808086;
- padding: 3px;
- margin-left:3px;
- background-color:#000000;
-}
-QTabBar::tab:selected, QTabBar::tab:last:selected, QTabBar::tab:hover {
- border-style: solid;
- border-top-color: transparent;
- border-right-color: transparent;
- border-left-color: transparent;
- border-bottom-color: #e67e22;
- border-bottom-width: 2px;
- border-style: solid;
- color: #FFFFFF;
- padding-left: 3px;
- padding-bottom: 2px;
- margin-left:3px;
- background-color:#000000;
-}
-
-QCheckBox {
- color: #a9b7c6;
- padding: 2px;
-}
-QCheckBox:disabled {
- color: #808086;
- padding: 2px;
-}
-
-QCheckBox:hover {
- border-radius:4px;
- border-style:solid;
- padding-left: 1px;
- padding-right: 1px;
- padding-bottom: 1px;
- padding-top: 1px;
- border-width:1px;
- border-color: rgb(87, 97, 106);
- background-color:#000000;
-}
-QCheckBox::indicator:checked {
-
- height: 10px;
- width: 10px;
- border-style:solid;
- border-width: 1px;
- border-color: #e67e22;
- color: #a9b7c6;
- background-color: #e67e22;
-}
-QCheckBox::indicator:unchecked {
-
- height: 10px;
- width: 10px;
- border-style:solid;
- border-width: 1px;
- border-color: #e67e22;
- color: #a9b7c6;
- background-color: transparent;
-}
-QRadioButton {
- color: #a9b7c6;
- background-color:#000000;
- padding: 1px;
-}
-QRadioButton::indicator:checked {
- height: 10px;
- width: 10px;
- border-style:solid;
- border-radius:5px;
- border-width: 1px;
- border-color: #e67e22;
- color: #a9b7c6;
- background-color: #e67e22;
-}
-QRadioButton::indicator:!checked {
- height: 10px;
- width: 10px;
- border-style:solid;
- border-radius:5px;
- border-width: 1px;
- border-color: #e67e22;
- color: #a9b7c6;
- background-color: transparent;
-}
-QStatusBar {
- color:#34e8eb;
-}
-QSpinBox {
- color: #a9b7c6;
- background-color:#000000;
-}
-QDoubleSpinBox {
- color: #a9b7c6;
- background-color:#000000;
-}
-QTimeEdit {
- color: #a9b7c6;
- background-color:#000000;
-}
-QDateTimeEdit {
- color: #a9b7c6;
- background-color:#000000;
-}
-QDateEdit {
- color: #a9b7c6;
- background-color:#000000;
-}
-QComboBox {
- color: #a9b7c6;
- background: #1e1d23;
-}
-QComboBox:editable {
- background: #1e1d23;
- color: #a9b7c6;
- selection-background-color:#000000;
-}
-QComboBox QAbstractItemView {
- color: #a9b7c6;
- background: #1e1d23;
- selection-color: #FFFFFF;
- selection-background-color:#000000;
-}
-QComboBox:!editable:on, QComboBox::drop-down:editable:on {
- color: #a9b7c6;
- background: #1e1d23;
-}
-QFontComboBox {
- color: #a9b7c6;
- background-color:#000000;
-}
-QToolBox {
- color: #a9b7c6;
- background-color:#000000;
-}
-QToolBox::tab {
- color: #a9b7c6;
- background-color:#000000;
-}
-QToolBox::tab:selected {
- color: #FFFFFF;
- background-color:#000000;
-}
-QScrollArea {
- color: #FFFFFF;
- background-color:#000000;
-}
-QSlider::groove:horizontal {
- height: 5px;
- background: #e67e22;
-}
-QSlider::groove:vertical {
- width: 5px;
- background: #e67e22;
-}
-QSlider::handle:horizontal {
- background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
- border: 1px solid #5c5c5c;
- width: 14px;
- margin: -5px 0;
- border-radius: 7px;
-}
-QSlider::handle:vertical {
- background: qlineargradient(x1:1, y1:1, x2:0, y2:0, stop:0 #b4b4b4, stop:1 #8f8f8f);
- border: 1px solid #5c5c5c;
- height: 14px;
- margin: 0 -5px;
- border-radius: 7px;
-}
-QSlider::add-page:horizontal {
- background: white;
-}
-QSlider::add-page:vertical {
- background: white;
-}
-QSlider::sub-page:horizontal {
- background: #e67e22;
-}
-QSlider::sub-page:vertical {
- background: #e67e22;
-}
-QScrollBar:horizontal {
- max-height: 20px;
- background: rgb(0,0,0);
- border: 1px transparent grey;
- margin: 0px 20px 0px 20px;
-}
-QScrollBar::handle:horizontal {
- background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 0, 0, 0), stop:0.7 rgba(255, 0, 0, 0), stop:0.71 rgb(230, 126, 34), stop:1 rgb(230, 126, 34));
- border-style: solid;
- border-width: 1px;
- border-color: rgb(0,0,0);
- min-width: 25px;
-}
-QScrollBar::handle:horizontal:hover {
- background: rgb(230, 126, 34);
- border-style: solid;
- border-width: 1px;
- border-color: rgb(0,0,0);
- min-width: 25px;
-}
-QScrollBar::add-line:horizontal {
- border: 1px solid;
- border-color: rgb(0,0,0);
- background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 0, 0, 0), stop:0.7 rgba(255, 0, 0, 0), stop:0.71 rgb(230, 126, 34), stop:1 rgb(230, 126, 34));
- width: 20px;
- subcontrol-position: right;
- subcontrol-origin: margin;
-}
-QScrollBar::add-line:horizontal:hover {
- border: 1px solid;
- border-color: rgb(0,0,0);
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: right;
- subcontrol-origin: margin;
-}
-QScrollBar::add-line:horizontal:pressed {
- border: 1px solid;
- border-color: grey;
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: right;
- subcontrol-origin: margin;
-}
-QScrollBar::sub-line:horizontal {
- border: 1px solid;
- border-color: rgb(0,0,0);
- background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 0, 0, 0), stop:0.7 rgba(255, 0, 0, 0), stop:0.71 rgb(230, 126, 34), stop:1 rgb(230, 126, 34));
- width: 20px;
- subcontrol-position: left;
- subcontrol-origin: margin;
-}
-QScrollBar::sub-line:horizontal:hover {
- border: 1px solid;
- border-color: rgb(0,0,0);
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: left;
- subcontrol-origin: margin;
-}
-QScrollBar::sub-line:horizontal:pressed {
- border: 1px solid;
- border-color: grey;
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: left;
- subcontrol-origin: margin;
-}
-QScrollBar::left-arrow:horizontal {
- border: 1px transparent grey;
- border-radius: 3px;
- width: 6px;
- height: 6px;
- background: rgb(0,0,0);
-}
-QScrollBar::right-arrow:horizontal {
- border: 1px transparent grey;
- border-radius: 3px;
- width: 6px;
- height: 6px;
- background: rgb(0,0,0);
-}
-QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
- background: none;
-}
-QScrollBar:vertical {
- max-width: 20px;
- background: rgb(0,0,0);
- border: 1px transparent grey;
- margin: 20px 0px 20px 0px;
-}
-QScrollBar::add-line:vertical {
- border: 1px solid;
- border-color: rgb(0,0,0);
- background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 0, 0, 0), stop:0.7 rgba(255, 0, 0, 0), stop:0.71 rgb(230, 126, 34), stop:1 rgb(230, 126, 34));
- height: 20px;
- subcontrol-position: bottom;
- subcontrol-origin: margin;
-}
-QScrollBar::add-line:vertical:hover {
- border: 1px solid;
- border-color: rgb(0,0,0);
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: bottom;
- subcontrol-origin: margin;
-}
-QScrollBar::add-line:vertical:pressed {
- border: 1px solid;
- border-color: grey;
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: bottom;
- subcontrol-origin: margin;
-}
-QScrollBar::sub-line:vertical {
- border: 1px solid;
- border-color: rgb(0,0,0);
- background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 0, 0, 0), stop:0.7 rgba(255, 0, 0, 0), stop:0.71 rgb(230, 126, 34), stop:1 rgb(230, 126, 34));
- height: 20px;
- subcontrol-position: top;
- subcontrol-origin: margin;
-}
-QScrollBar::sub-line:vertical:hover {
- border: 1px solid;
- border-color: rgb(0,0,0);
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: top;
- subcontrol-origin: margin;
-}
-QScrollBar::sub-line:vertical:pressed {
- border: 1px solid;
- border-color: grey;
- border-radius: 8px;
- background: rgb(230, 126, 34);
- height: 16px;
- width: 16px;
- subcontrol-position: top;
- subcontrol-origin: margin;
-}
- QScrollBar::handle:vertical {
- background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 0, 0, 0), stop:0.7 rgba(255, 0, 0, 0), stop:0.71 rgb(230, 126, 34), stop:1 rgb(230, 126, 34));
- border-style: solid;
- border-width: 1px;
- border-color: rgb(0,0,0);
- min-height: 25px;
-}
-QScrollBar::handle:vertical:hover {
- background: rgb(230, 126, 34);
- border-style: solid;
- border-width: 1px;
- border-color: rgb(0,0,0);
- min-heigth: 25px;
-}
-QScrollBar::up-arrow:vertical {
- border: 1px transparent grey;
- border-radius: 3px;
- width: 6px;
- height: 6px;
- background: rgb(0,0,0);
-}
-QScrollBar::down-arrow:vertical {
- border: 1px transparent grey;
- border-radius: 3px;
- width: 6px;
- height: 6px;
- background: rgb(0,0,0);
-}
-QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
- background: none;
-}
diff --git a/freemocap/gui/qt/style_sheet/ElegantDark.qss b/freemocap/gui/qt/style_sheet/ElegantDark.qss
deleted file mode 100644
index 0b0012b2..00000000
--- a/freemocap/gui/qt/style_sheet/ElegantDark.qss
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-ElegantDark Style Sheet for QT Applications
-Author: Jaime A. Quiroga P.
-Company: GTRONICK
-Last updated: 17/04/2018
-Available at: https://github.com/GTRONICK/QSS/blob/master/ElegantDark.qss
-*/
-QMainWindow {
- background-color:rgb(82, 82, 82);
-}
-QTextEdit {
- background-color:rgb(42, 42, 42);
- color: rgb(0, 255, 0);
-}
-QPushButton{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(255, 255, 255);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(77, 77, 77, 255), stop:1 rgba(97, 97, 97, 255));
-}
-QPushButton:hover{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(180, 180, 180, 255), stop:1 rgba(110, 110, 110, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(180, 180, 180, 255), stop:1 rgba(110, 110, 110, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(180, 180, 180, 255), stop:1 rgba(110, 110, 110, 255));
- border-bottom-color: rgb(115, 115, 115);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(255, 255, 255);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(107, 107, 107, 255), stop:1 rgba(157, 157, 157, 255));
-}
-QPushButton:pressed{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(62, 62, 62, 255), stop:1 rgba(22, 22, 22, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(255, 255, 255);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(77, 77, 77, 255), stop:1 rgba(97, 97, 97, 255));
-}
-QPushButton:disabled{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(0, 0, 0);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(57, 57, 57, 255), stop:1 rgba(77, 77, 77, 255));
-}
-QLineEdit {
- border-width: 1px; border-radius: 4px;
- border-color: rgb(58, 58, 58);
- border-style: inset;
- padding: 0 8px;
- color: rgb(255, 255, 255);
- background:rgb(100, 100, 100);
- selection-background-color: rgb(187, 187, 187);
- selection-color: rgb(60, 63, 65);
-}
-QLabel {
- color:rgb(255,255,255);
-}
-QProgressBar {
- text-align: center;
- color: rgb(240, 240, 240);
- border-width: 1px;
- border-radius: 10px;
- border-color: rgb(58, 58, 58);
- border-style: inset;
- background-color:rgb(77,77,77);
-}
-QProgressBar::chunk {
- background-color: qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 rgba(87, 97, 106, 255), stop:1 rgba(93, 103, 113, 255));
- border-radius: 5px;
-}
-QMenuBar {
- background:rgb(82, 82, 82);
-}
-QMenuBar::item {
- color:rgb(223,219,210);
- spacing: 3px;
- padding: 1px 4px;
- background: transparent;
-}
-
-QMenuBar::item:selected {
- background:rgb(115, 115, 115);
-}
-QMenu::item:selected {
- color:rgb(255,255,255);
- border-width:2px;
- border-style:solid;
- padding-left:18px;
- padding-right:8px;
- padding-top:2px;
- padding-bottom:3px;
- background:qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 rgba(87, 97, 106, 255), stop:1 rgba(93, 103, 113, 255));
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
-}
-QMenu::item {
- color:rgb(223,219,210);
- background-color:rgb(78,78,78);
- padding-left:20px;
- padding-top:4px;
- padding-bottom:4px;
- padding-right:10px;
-}
-QMenu{
- background-color:rgb(78,78,78);
-}
-QTabWidget {
- color:rgb(0,0,0);
- background-color:rgb(247,246,246);
-}
-QTabWidget::pane {
- border-color: rgb(77,77,77);
- background-color:rgb(101,101,101);
- border-style: solid;
- border-width: 1px;
- border-radius: 6px;
-}
-QTabBar::tab {
- padding:2px;
- color:rgb(250,250,250);
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(77, 77, 77, 255), stop:1 rgba(97, 97, 97, 255));
- border-style: solid;
- border-width: 2px;
- border-top-right-radius:4px;
- border-top-left-radius:4px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(95, 92, 93, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(95, 92, 93, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(95, 92, 93, 255));
- border-bottom-color: rgb(101,101,101);
-}
-QTabBar::tab:selected, QTabBar::tab:last:selected, QTabBar::tab:hover {
- background-color:rgb(101,101,101);
- margin-left: 0px;
- margin-right: 1px;
-}
-QTabBar::tab:!selected {
- margin-top: 1px;
- margin-right: 1px;
-}
-QCheckBox {
- color:rgb(223,219,210);
- padding: 2px;
-}
-QCheckBox:hover {
- border-radius:4px;
- border-style:solid;
- padding-left: 1px;
- padding-right: 1px;
- padding-bottom: 1px;
- padding-top: 1px;
- border-width:1px;
- border-color: rgb(87, 97, 106);
- background-color:qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 rgba(87, 97, 106, 150), stop:1 rgba(93, 103, 113, 150));
-}
-QCheckBox::indicator:checked {
- border-radius:4px;
- border-style:solid;
- border-width:1px;
- border-color: rgb(180,180,180);
- background-color:qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 rgba(87, 97, 106, 255), stop:1 rgba(93, 103, 113, 255));
-}
-QCheckBox::indicator:unchecked {
- border-radius:4px;
- border-style:solid;
- border-width:1px;
- border-color: rgb(87, 97, 106);
- background-color:rgb(255,255,255);
-}
-QStatusBar {
- color:rgb(240,240,240);
-}
diff --git a/freemocap/gui/qt/style_sheet/FunkyTown.qss b/freemocap/gui/qt/style_sheet/FunkyTown.qss
deleted file mode 100644
index 1f62052a..00000000
--- a/freemocap/gui/qt/style_sheet/FunkyTown.qss
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-ElegantDark Style Sheet for QT Applications
-Author: Jaime A. Quiroga P.
-Company: GTRONICK
-Last updated: 17/04/2018
-Available at: https://github.com/GTRONICK/QSS/blob/master/ElegantDark.qss
-*/
-QMainWindow {
- background-color:rgb(182, 82, 82);
-}
-QTextEdit {
- background-color:rgb(42, 42, 42);
- color: rgb(0, 255, 0);
-}
-QPushButton{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(255, 255, 255);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:.5, y2:0, stop:0 rgba(1, 247, 77, 255), stop:1 rgba(232, 7, 247, 255));
-}
-QPushButton:hover{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(180, 10, 180, 255), stop:1 rgba(110, 110, 110, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(180, 10, 180, 255), stop:1 rgba(110, 110, 110, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(180, 10, 180, 255), stop:1 rgba(110, 110, 110, 255));
- border-bottom-color: rgb(115, 115, 115);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(255, 255, 255);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(107, 107, 107, 255), stop:1 rgba(157, 157, 157, 255));
-}
-QPushButton:pressed{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(162, 62, 212, 255), stop:1 rgba(22, 22, 22, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(255, 255, 255);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(77, 77, 77, 255), stop:1 rgba(97, 97, 97, 255));
-}
-QPushButton:disabled{
- border-style: outset;
- border-width: 2px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
- border-style: solid;
- color: rgb(0, 0, 0);
- padding: 2px;
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(57, 57, 57, 255), stop:1 rgba(77, 77, 77, 255));
-}
-QLineEdit {
- border-width: 1px; border-radius: 4px;
- border-color: rgb(58, 58, 58);
- border-style: inset;
- padding: 0 8px;
- color: rgb(255, 255, 255);
- background:rgb(100, 100, 100);
- selection-background-color: rgb(187, 187, 187);
- selection-color: rgb(60, 63, 65);
-}
-QLabel {
- color:rgb(255,255,255);
-}
-QProgressBar {
- text-align: center;
- color: rgb(240, 240, 240);
- border-width: 1px;
- border-radius: 10px;
- border-color: rgb(58, 58, 58);
- border-style: inset;
- background-color:rgb(77,77,77);
-}
-QProgressBar::chunk {
- background-color: qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 #ffff00, stop:1 rgba(93, 103, 113, 255));
- border-radius: 5px;
-}
-QMenuBar {
- background:rgb(82, 82, 82);
-}
-QMenuBar::item {
- color:rgb(223,219,210);
- spacing: 3px;
- padding: 1px 4px;
- background: transparent;
-}
-
-QMenuBar::item:selected {
- background:rgb(115, 115, 115);
-}
-QMenu::item:selected {
- color:rgb(255,255,255);
- border-width:2px;
- border-style:solid;
- padding-left:18px;
- padding-right:8px;
- padding-top:2px;
- padding-bottom:3px;
- background:qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 #ffff00, stop:1 rgba(255, 03, 213, 255));
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(162, 62, 212, 255));
- border-bottom-color: rgb(58, 58, 58);
- border-bottom-width: 1px;
-}
-QMenu::item {
- color:rgb(223,219,210);
- background-color:rgb(78,78,78);
- padding-left:20px;
- padding-top:4px;
- padding-bottom:4px;
- padding-right:10px;
-}
-QMenu{
- background-color:rgb(78,78,78);
-}
-QTabWidget {
- color:rgb(0,0,0);
- background-color:rgb(247,246,246);
-}
-QTabWidget::pane {
- border-color: rgb(77,177,77);
- background-color:qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 rgba(237, 7, 06, 150), stop:1 rgba(3, 03, 213, 150));
- border-style: solid;
- border-width: 1px;
- border-radius: 6px;
-}
-QTabBar::tab {
- padding:2px;
- color:rgb(250,250,250);
- background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(77, 77, 77, 255), stop:1 rgba(97, 97, 97, 255));
- border-style: solid;
- border-width: 2px;
- border-top-right-radius:4px;
- border-top-left-radius:4px;
- border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(95, 92, 93, 255));
- border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(95, 92, 93, 255));
- border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(15, 215, 115, 255), stop:1 rgba(95, 92, 93, 255));
- border-bottom-color: rgb(101,101,101);
-}
-QTabBar::tab:selected, QTabBar::tab:last:selected, QTabBar::tab:hover {
- background-color:rgb(101,101,101);
- margin-left: 0px;
- margin-right: 1px;
-}
-QTabBar::tab:!selected {
- margin-top: 1px;
- margin-right: 1px;
-}
-QCheckBox {
- color:rgb(223,219,210);
- padding: 2px;
-}
-QCheckBox:hover {
- border-radius:4px;
- border-style:solid;
- padding-left: 1px;
- padding-right: 1px;
- padding-bottom: 1px;
- padding-top: 1px;
- border-width:1px;
- border-color: rgb(87, 97, 106);
- background-color:qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 rgba(87, 97, 106, 150), stop:1 rgba(93, 103, 113, 150));
-}
-QCheckBox::indicator:checked {
- border-radius:4px;
- border-style:solid;
- border-width:1px;
- border-color: rgb(180,180,180);
- background-color:qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 #bf07ea, stop:1 rgba(93, 103, 113, 255));
-}
-QCheckBox::indicator:unchecked {
- border-radius:4px;
- border-style:solid;
- border-width:1px;
- border-color: rgb(87, 97, 106);
- background-color:rgb(255,255,255);
-}
-QStatusBar {
- color:rgb(240,240,240);
-}
diff --git a/freemocap/gui/qt/style_sheet/compile_scss_to_css.py b/freemocap/gui/qt/style_sheet/compile_scss_to_css.py
index 6043f106..9ea9cdc1 100644
--- a/freemocap/gui/qt/style_sheet/compile_scss_to_css.py
+++ b/freemocap/gui/qt/style_sheet/compile_scss_to_css.py
@@ -1,7 +1,9 @@
-import sass
from pathlib import Path
from typing import Union
+import sass
+
+
def compile_scss_to_css(scss_path: Union[str, Path], css_path: Union[str, Path]):
with open(scss_path) as scss_file:
scss_contents = scss_file.read()
diff --git a/freemocap/gui/qt/style_sheet/qt_style_sheet.css b/freemocap/gui/qt/style_sheet/qt_style_sheet.css
index 101c79b5..d6a17c70 100644
--- a/freemocap/gui/qt/style_sheet/qt_style_sheet.css
+++ b/freemocap/gui/qt/style_sheet/qt_style_sheet.css
@@ -18,10 +18,12 @@ QMainWindow {
QTabWidget::pane {
border: 1px solid #f5f5f7;
- top: 1px;
background: #eeeeee;
padding: 5px; }
+QTabWidget::pane::selection {
+ border-top: 1px solid #333333; }
+
QTabBar::tab {
border: 1px solid #1d1d1f;
padding: 5px;
@@ -65,20 +67,22 @@ QPushButton:pressed {
background-color: #53d4dc; }
QPushButton#start_recording_button {
- font-size: 20px;
- background-color: #d95158;
- border: 2px solid #1d1d1f;
- padding: 6px;
- border-radius: 10px; }
+ font-size: 16px;
+ background-color: #ce7076;
+ border: 2px solid #333333;
+ padding: 10px;
+ border-radius: 10px;
+ width: 250px; }
QPushButton#start_recording_button:hover {
border: 2px solid #cb2c34; }
QPushButton#start_recording_button:disabled {
- background-color: #8c5454; }
+ background-color: #8c7474;
+ color: #555555; }
QPushButton#stop_recording_button {
- font-size: 18px;
+ font-size: 14px;
background-color: #eeeeee; }
QPushButton#stop_recording_button:enabled {
@@ -89,6 +93,9 @@ QPushButton#stop_recording_button:hover {
border: 3px solid #1d1d1f;
background-color: #eeeeee; }
+QPushButton#stop_recording_button:disabled {
+ color: #555555; }
+
QPushButton#process_motion_capture_button,
QPushButton#export_to_blender_button {
font-size: 18px;
diff --git a/freemocap/gui/qt/style_sheet/qt_style_sheet.scss b/freemocap/gui/qt/style_sheet/qt_style_sheet.scss
index b1fbaf3d..1bb78120 100644
--- a/freemocap/gui/qt/style_sheet/qt_style_sheet.scss
+++ b/freemocap/gui/qt/style_sheet/qt_style_sheet.scss
@@ -4,7 +4,8 @@ $cadet-skelly: cadetblue;
$freemocap-green: #365d5f;
$freemocap-dark-green: #254342;
$laser-red: #d95158;
-$disabled-laser-red: #8c5454;
+$recording-button-red: #ce7076;
+$disabled-laser-red: #8c7474;
$background: #eeeeee;
$dark-background: #e0e0e0;
$accent-background: #f5f5f5;
@@ -13,6 +14,7 @@ $active-element: #424242;
$primary-button: #67bcc0;
$secondary-button: #a8e9ed;
$disabled-button: #9e9e9e;
+$disabled-text: #555555;
$tree-primary: #eeeeee;
$tree-secondary: #e0e0e0;
$tree-selected: #f6e0f5;
@@ -33,8 +35,10 @@ QGroupBox {
margin-top: 10px;
font-weight: bold;
background-color: $accent-background;
+
}
+
QStatusBar {
color: $plain-black;
}
@@ -45,11 +49,12 @@ QMainWindow {
QTabWidget::pane {
border: 1px solid $plain-white;
- top: 1px;
background: $background;
padding: 5px;
}
-
+QTabWidget::pane::selection {
+ border-top: 1px solid $dark-charcoal;
+}
QTabBar::tab {
border: 1px solid $plain-black;
padding: 5px;
@@ -101,21 +106,23 @@ QPushButton:pressed {
}
QPushButton#start_recording_button {
- font-size: 20px;
- background-color: $laser-red;
- border: 2px solid $plain-black;
- padding: 6px;
+ font-size: 16px;
+ background-color: $recording-button-red;
+ border: 2px solid $dark-charcoal;
+ padding: 10px;
border-radius: 10px;
+ width:250px;
}
QPushButton#start_recording_button:hover {
border: 2px solid darken($laser-red, 10%);
}
QPushButton#start_recording_button:disabled {
background-color: $disabled-laser-red;
+ color: $disabled-text;
}
QPushButton#stop_recording_button {
- font-size: 18px;
+ font-size: 14px;
background-color: $background;
}
QPushButton#stop_recording_button:enabled {
@@ -126,7 +133,9 @@ QPushButton#stop_recording_button:hover {
border: 3px solid $plain-black;
background-color: $background;
}
-
+QPushButton#stop_recording_button:disabled {
+ color: $disabled-text;
+}
QPushButton#process_motion_capture_button,
QPushButton#export_to_blender_button {
font-size: 18px;
diff --git a/freemocap/gui/qt/style_sheet/scss_file_watcher.py b/freemocap/gui/qt/style_sheet/scss_file_watcher.py
index ea459777..dcaa84b7 100644
--- a/freemocap/gui/qt/style_sheet/scss_file_watcher.py
+++ b/freemocap/gui/qt/style_sheet/scss_file_watcher.py
@@ -4,6 +4,7 @@ from typing import Union
from PyQt6 import QtCore
from PyQt6.QtCore import pyqtSlot, QFileSystemWatcher
+
from freemocap.gui.qt.style_sheet.compile_scss_to_css import compile_scss_to_css
logger = logging.getLogger(__name__)
diff --git a/freemocap/gui/qt/style_sheet/stylesheet-branch-more.png b/freemocap/gui/qt/style_sheet/stylesheet-branch-more.png
deleted file mode 100644
index 664ad447..00000000
Binary files a/freemocap/gui/qt/style_sheet/stylesheet-branch-more.png and /dev/null differ
diff --git a/freemocap/gui/qt/utilities/copy_timestamps_folder.py b/freemocap/gui/qt/utilities/copy_timestamps_folder.py
new file mode 100644
index 00000000..fd36f6e7
--- /dev/null
+++ b/freemocap/gui/qt/utilities/copy_timestamps_folder.py
@@ -0,0 +1,30 @@
+import logging
+import shutil
+from pathlib import Path
+from typing import Union
+
+logger = 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)
+
+ # Check if the source directory exists
+ if not source_path.is_dir():
+ raise ValueError(f"{source_dir} is not a valid directory.")
+
+ # Check if the directory contains a directory or file called 'timestamps'
+ timestamps_path = source_path / "timestamps"
+ if not timestamps_path.exists():
+ logger.info(f"{source_dir} does not contain a 'timestamps' directory or file.")
+ return False
+
+
+ # Create the destination directory if it doesn't exist
+ destination_path.mkdir(parents=True, exist_ok=True)
+
+ if destination_path.stem == "timestamps":
+ destination_path = destination_path.parent
+
+ # Copy the 'timestamps' directory/file to the destination directory
+ shutil.copytree(timestamps_path, destination_path / "timestamps", dirs_exist_ok=True)
+ return True
\ No newline at end of file
diff --git a/freemocap/gui/qt/utilities/update_most_recent_recording_toml.py b/freemocap/gui/qt/utilities/update_most_recent_recording_toml.py
index 69c473e8..4eadde8a 100644
--- a/freemocap/gui/qt/utilities/update_most_recent_recording_toml.py
+++ b/freemocap/gui/qt/utilities/update_most_recent_recording_toml.py
@@ -2,10 +2,8 @@ import logging
import toml
-from freemocap.parameter_info_models.recording_info_model import RecordingInfoModel
-from freemocap.system.paths_and_files_names import (
- get_most_recent_recording_toml_path,
-)
+from freemocap.data_layer.recording_models.recording_info_model import RecordingInfoModel
+from freemocap.system.paths_and_filenames.path_getters import get_most_recent_recording_toml_path
logger = logging.getLogger(__name__)
diff --git a/freemocap/gui/qt/widgets/active_recording_widget.py b/freemocap/gui/qt/widgets/active_recording_widget.py
index acf16f62..c1749efa 100644
--- a/freemocap/gui/qt/widgets/active_recording_widget.py
+++ b/freemocap/gui/qt/widgets/active_recording_widget.py
@@ -6,10 +6,10 @@ from PyQt6.QtCore import pyqtSignal, QFileSystemWatcher
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QWidget
from pyqtgraph.parametertree import Parameter, ParameterTree
-from freemocap.parameter_info_models.recording_info_model import (
+from freemocap.data_layer.recording_models.recording_info_model import (
RecordingInfoModel,
)
-from freemocap.system.paths_and_files_names import get_most_recent_recording_path
+from freemocap.system.paths_and_filenames.path_getters import get_most_recent_recording_path
logger = logging.getLogger(__name__)
diff --git a/freemocap/gui/qt/widgets/camera_controller_group_box.py b/freemocap/gui/qt/widgets/camera_controller_group_box.py
index 87e30f3f..97800c26 100644
--- a/freemocap/gui/qt/widgets/camera_controller_group_box.py
+++ b/freemocap/gui/qt/widgets/camera_controller_group_box.py
@@ -1,3 +1,7 @@
+import logging
+from pathlib import Path
+
+from PyQt6 import QtWidgets, QtGui
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import (
QGroupBox,
@@ -7,77 +11,88 @@ from PyQt6.QtWidgets import (
QFormLayout,
QLabel,
QRadioButton,
- QCheckBox,
+ QCheckBox, QFrame,
)
-from skellycam import SkellyCamControllerWidget
+from skellycam import SkellyCamControllerWidget, SkellyCamWidget
from freemocap.core_processes.capture_volume_calibration.charuco_stuff.default_charuco_square_size import (
default_charuco_square_size_mm,
)
-from freemocap.system.paths_and_files_names import create_new_default_recording_name, create_new_recording_folder_path
+from 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
+
+CALIBRATION_RECORDING_BUTTON_TEXT = "\U0001F534 \U0001F4D0 Start Calibration Recording"
+MOCAP_RECORDING_BUTTON_TEXT = f"{SKULL_EMOJI_STRING} {SPARKLES_EMOJI_STRING} Start Motion Capture Recording"
+
+logger = logging.getLogger(__name__)
+
-class RecordingNameGenerator:
- pass
class CameraControllerGroupBox(QGroupBox):
- def __init__(self, skellycam_controller: SkellyCamControllerWidget, parent=None):
+ def __init__(self, skellycam_widget: SkellyCamWidget, parent=None):
super().__init__(parent=parent)
- self._skellycam_controller = skellycam_controller
- skellycam_controller.start_recording_button.setObjectName("start_recording_button")
- skellycam_controller.stop_recording_button.setObjectName("stop_recording_button")
+ self.setStyleSheet("font-size: 12px;")
+ self._skellycam_widget = skellycam_widget
+ self._skellycam_controller = SkellyCamControllerWidget(
+ camera_viewer_widget=skellycam_widget,
+ parent=self,
+ )
+ self._skellycam_controller.check_recording_type = self.check_recording_type,
- # self.setFlat(True)
- self._layout = QVBoxLayout()
- self._layout.setAlignment(Qt.AlignmentFlag.AlignTop)
+ self._layout = QHBoxLayout()
+ self._layout.setAlignment(Qt.AlignmentFlag.AlignLeft)
self.setLayout(self._layout)
- # self._layout.setContentsMargins(0, 0, 0, 0)
- # self._layout.setSpacing(0)
- self._layout.setAlignment(Qt.AlignmentFlag.AlignTop)
-
- motion_capture_recording_options_layout = self._create_mocap_recording_option_layout()
- self._layout.addLayout(motion_capture_recording_options_layout)
+ self._layout.addLayout(self._make_record_button_layout())
- calibration_recording_option_layout = self._create_calibration_recording_option_layout()
- self._layout.addLayout(calibration_recording_option_layout)
+ self._layout.addLayout(self._make_options_layout())
- self._layout.addLayout(self._create_videos_will_save_to_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))
+ self._stop_recording_button.clicked.connect(self._set_record_button_text)
- self._layout.addWidget(self._skellycam_controller)
-
- def _create_videos_will_save_to_layout(self):
- vbox = QVBoxLayout()
+ @property
+ def mocap_videos_radio_button_checked(self) -> bool:
+ return self._mocap_videos_radio_button.isChecked()
- hbox = QHBoxLayout()
- self._recording_string_tag_line_edit = QLineEdit(parent=self)
- self._recording_string_tag_line_edit.setPlaceholderText("(Optional)")
+ @property
+ def calibration_videos_radio_button_checked(self) -> bool:
+ return self._calibration_videos_radio_button.isChecked()
- recording_string_tag_form_layout = QFormLayout(parent=self)
- recording_string_tag_form_layout.addRow("Tag:", self._recording_string_tag_line_edit)
- hbox.addLayout(recording_string_tag_form_layout)
+ @property
+ def auto_process_videos_checked(self) -> bool:
+ return self._auto_process_videos_checkbox.isChecked()
- hbox.setAlignment(Qt.AlignmentFlag.AlignLeft)
- videos_will_save_to_label = QLabel("Videos will save to folder: ")
- videos_will_save_to_label.setStyleSheet("font-size: 10px;")
- hbox.addWidget(videos_will_save_to_label)
- self._recording_path_label = QLabel(f"{self.get_new_recording_path()}")
- self._recording_path_label.setStyleSheet("font-family: monospace; font-size: 10px;")
- hbox.addWidget(self._recording_path_label)
+ @property
+ def auto_open_in_blender_checked(self) -> bool:
+ return self._auto_open_in_blender_checkbox.isChecked()
- vbox.addLayout(hbox)
+ @property
+ def generate_jupyter_notebook_checked(self) -> bool:
+ return self._generate_jupyter_notebook_checkbox.isChecked()
- lag_note_label = QLabel("NOTE: If you experience lag in your camera views, decrease the resolution and/or use fewer cameras.\nWe are working on a fix which should be done 'soon' (written: 2023-04-05)")
- vbox.addWidget(lag_note_label)
+ @property
+ def charuco_square_size(self) -> float:
+ return float(self._charuco_square_size_line_edit.text())
- return vbox
+ def check_recording_type(self):
+ if self._mocap_videos_radio_button.isChecked():
+ return "mocap"
+ elif self._calibration_videos_radio_button.isChecked():
+ return "calibration"
+ else:
+ raise ValueError("No recording type selected")
def _create_mocap_recording_option_layout(self):
hbox = QHBoxLayout()
hbox.setAlignment(Qt.AlignmentFlag.AlignLeft)
self._mocap_videos_radio_button = QRadioButton("Record Motion Capture Videos")
+
hbox.addWidget(self._mocap_videos_radio_button)
self._mocap_videos_radio_button.setChecked(True)
@@ -102,7 +117,6 @@ class CameraControllerGroupBox(QGroupBox):
self._calibration_videos_radio_button = QRadioButton("Record Calibration Videos")
hbox.addWidget(self._calibration_videos_radio_button)
hbox.addWidget(QLabel(" - "))
- self._calibration_videos_radio_button.toggled.connect(self._handle_calibration_videos_radio_button_changed)
hbox.addWidget(QLabel("Charuco square size (mm)", parent=self))
self._charuco_square_size_line_edit = QLineEdit(parent=self)
@@ -115,35 +129,72 @@ class CameraControllerGroupBox(QGroupBox):
hbox.addStretch()
return hbox
- @property
- def mocap_videos_radio_button_checked(self) -> bool:
- return self._mocap_videos_radio_button.isChecked()
+ def _make_options_layout(self):
+ options_vbox = QVBoxLayout()
+ options_vbox.addLayout(self._create_mocap_recording_option_layout())
+ options_vbox.addLayout(self._create_calibration_recording_option_layout())
+ options_vbox.addLayout(self._create_videos_will_save_to_layout())
+ return options_vbox
+
+ def _make_record_button_layout(self):
+ button_vbox = QVBoxLayout()
+ self._start_recording_button = self._skellycam_controller.start_recording_button
+ self._stop_recording_button = self._skellycam_controller.stop_recording_button
+ self._start_recording_button.setStyleSheet("font-size: 14px;")
+ self._stop_recording_button.setStyleSheet("font-size: 14px;")
+ self._start_recording_button.setText(MOCAP_RECORDING_BUTTON_TEXT)
+ self._start_recording_button.setObjectName("start_recording_button")
+ self._stop_recording_button.setObjectName("stop_recording_button")
+ self._start_recording_button.show()
+ self._start_recording_button.setEnabled(False)
+ self._stop_recording_button.show()
+ button_vbox.addWidget(self._start_recording_button)
+ button_vbox.addWidget(self._stop_recording_button)
+ return button_vbox
- @property
- def calibration_videos_radio_button_checked(self) -> bool:
- return self._calibration_videos_radio_button.isChecked()
+ def _create_videos_will_save_to_layout(self):
+ vbox = QVBoxLayout()
- @property
- def auto_process_videos_checked(self) -> bool:
- return self._auto_process_videos_checkbox.isChecked()
+ session_path_hbox = QHBoxLayout()
+ session_path_hbox.setAlignment(Qt.AlignmentFlag.AlignLeft)
+ vbox.addLayout(session_path_hbox)
+ recording_path_full = self.get_new_recording_path()
+ recording_name = Path(recording_path_full).stem
- @property
- def auto_open_in_blender_checked(self) -> bool:
- return self._auto_open_in_blender_checkbox.isChecked()
+ recording_name_hbox = QHBoxLayout()
+ vbox.addLayout(recording_name_hbox)
+ recording_name_key_label = QLabel("Recording Name: ")
+ recording_name_hbox.addWidget(recording_name_key_label)
+ self._recording_name_label = QLabel(f"{recording_name}")
+ self._recording_name_label.setStyleSheet("font-family: monospace;")
+ recording_name_hbox.addWidget(self._recording_name_label)
- @property
- def generate_jupyter_notebook_checked(self) -> bool:
- return self._generate_jupyter_notebook_checkbox.isChecked()
+ recording_string_tag_form_layout = QFormLayout(parent=self)
+ self._recording_string_tag_line_edit = QLineEdit(parent=self)
+ self._recording_string_tag_line_edit.setPlaceholderText("(Optional)")
+ self._recording_string_tag_line_edit.setMaxLength(200)
- @property
- def charuco_square_size(self) -> float:
- return float(self._charuco_square_size_line_edit.text())
+ recording_string_tag_form_layout.addRow("Tag:", self._recording_string_tag_line_edit)
+ recording_name_hbox.addWidget(QLabel(" - "))
+ recording_name_hbox.addLayout(recording_string_tag_form_layout)
+
+ full_path_hbox = QHBoxLayout()
+ full_path_hbox.setAlignment(Qt.AlignmentFlag.AlignLeft)
+ vbox.addLayout(full_path_hbox)
+ full_path_key_label = QLabel("Full Path: ")
+ full_path_hbox.addWidget(full_path_key_label)
+ self._full_path_label = QLabel(recording_path_full)
+ self._full_path_label.setStyleSheet("font-family: monospace;")
+ full_path_hbox.addWidget(self._full_path_label)
+
+ return vbox
def get_new_recording_path(self):
return create_new_recording_folder_path(recording_name=self._get_recording_name())
def update_recording_name_string(self):
- self._recording_path_label.setText(self.get_new_recording_path())
+ self._recording_name_label.setText(Path(self.get_new_recording_path()).stem)
+ self._full_path_label.setText(f"{self.get_new_recording_path()}")
def _get_recording_name_string_tag(self):
try:
@@ -166,11 +217,11 @@ class CameraControllerGroupBox(QGroupBox):
else:
return f"{name}__{self._get_recording_name_string_tag()}"
- def _handle_calibration_videos_radio_button_changed(self, state):
+ def _set_record_button_text(self):
if self._calibration_videos_radio_button.isChecked():
self.setProperty("calibration_videos_radio_button_checked", True)
- self._skellycam_controller.set_calibration_recordings_button_label(True)
+ self._start_recording_button.setText(CALIBRATION_RECORDING_BUTTON_TEXT)
else:
self.setProperty("calibration_videos_radio_button_checked", False)
- self._skellycam_controller.set_calibration_recordings_button_label(False)
+ self._start_recording_button.setText(MOCAP_RECORDING_BUTTON_TEXT)
self.style().polish(self)
diff --git a/freemocap/gui/qt/widgets/central_tab_widget.py b/freemocap/gui/qt/widgets/central_tab_widget.py
index 85ef68b4..fad20eb5 100644
--- a/freemocap/gui/qt/widgets/central_tab_widget.py
+++ b/freemocap/gui/qt/widgets/central_tab_widget.py
@@ -1,14 +1,13 @@
import logging
from PyQt6.QtCore import Qt
-from PyQt6.QtWidgets import QTabWidget, QVBoxLayout, QWidget
+from PyQt6.QtWidgets import QTabWidget, QVBoxLayout, QWidget, QLabel
# from skelly_viewer import SkellyViewer
from skellycam import SkellyCamWidget
from freemocap.gui.qt.widgets.home_widget import (
HomeWidget,
)
-from freemocap.system.paths_and_files_names import CAMERA_WITH_FLASH_EMOJI_STRING, EYES_EMOJI_STRING
logger = logging.getLogger(__name__)
@@ -69,6 +68,14 @@ 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.setStyleSheet("font-size: 10px;")
+ lag_note_label.setWordWrap(True)
+ layout = QVBoxLayout()
+ layout.addWidget(lag_note_label)
+ layout.setAlignment(Qt.AlignmentFlag.AlignBottom)
+ self._camera_view_layout.addLayout(layout)
+
def _create_skelly_viewer_tab(self, tab_widget: QTabWidget):
logger.info("Creating export_data tab")
tab_widget.addTab(self._skelly_viewer_widget, f"Data Viewer")
diff --git a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py
index 56951f29..40c06b33 100644
--- a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py
+++ b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py
@@ -23,30 +23,26 @@ from freemocap.core_processes.capture_volume_calibration.charuco_stuff.default_c
from freemocap.gui.qt.workers.anipose_calibration_thread_worker import (
AniposeCalibrationThreadWorker,
)
-from freemocap.system.paths_and_files_names import (
- get_last_successful_calibration_toml_path,
-)
+from freemocap.system.paths_and_filenames.path_getters import get_last_successful_calibration_toml_path
logger = logging.getLogger(__name__)
class CalibrationControlPanel(QWidget):
- def __init__(self, get_active_recording_info_callable: Callable, kill_thread_event: threading.Event, parent=None):
-
+ def __init__(self, get_active_recording_info: Callable, kill_thread_event: threading.Event, parent=None):
super().__init__(parent=parent)
- self._has_a_toml_path = False
- self._calibration_toml_path = None
- self._kill_thread_event = kill_thread_event
-
- self._get_active_recording_info_callable = get_active_recording_info_callable
+ self._get_active_recording_info = get_active_recording_info
self.parent = parent
- self._anipose_calibration_frame_worker = None
- self._user_selected_calibration_toml_path_str = None
-
self._layout = QVBoxLayout()
self.setLayout(self._layout)
+ self._calibration_toml_path = None
+ self._kill_thread_event = kill_thread_event
+
+ self._anipose_calibration_frame_worker = None
+ self._user_selected_toml_path = None
+
self._selected_calibration_toml_label = QLabel("")
self._selected_calibration_toml_label.setWordWrap(True)
@@ -86,7 +82,7 @@ class CalibrationControlPanel(QWidget):
radio_button_push_button_layout.addWidget(self._load_calibration_from_file_radio_button)
self._load_calibration_from_file_radio_button.toggled.connect(self._handle_load_calibration_from_file_toggled)
- self._load_calibration_toml_dialog_button = QPushButton("Load Camera Calibration TOML...")
+ self._load_calibration_toml_dialog_button = QPushButton("Load TOML...")
radio_button_push_button_layout.addWidget(self._load_calibration_toml_dialog_button)
# self._load_calibration_toml_dialog_button.setStyleSheet("font-size: 10pt;")
self._load_calibration_toml_dialog_button.clicked.connect(self.open_load_camera_calibration_toml_dialog)
@@ -95,27 +91,27 @@ class CalibrationControlPanel(QWidget):
return vbox_layout
def 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_calibration_toml_path_str is not None:
- toml_path = self._user_selected_calibration_toml_path_str
+ if self._user_selected_toml_path is not None:
+ toml_path = self._user_selected_toml_path
+ else:
+ toml_path = self._check_active_recording_for_calibration_toml()
+
elif self._use_most_recent_calibration_radio_button.isChecked():
toml_path = get_last_successful_calibration_toml_path()
- elif self._calibrate_from_active_recording_radio_button.isChecked():
- active_recording_info = self._get_active_recording_info_callable()
- if active_recording_info.calibration_toml_check:
- toml_path = active_recording_info.calibration_toml_path
- else:
- active_rec = self._get_active_recording_info_callable()
- if active_rec is not None:
- if active_rec.calibration_toml_check:
- toml_path = self._get_active_recording_info_callable().calibration_toml_path
- self._load_calibration_from_file_radio_button.setChecked(True)
- else:
- toml_path = get_last_successful_calibration_toml_path()
- self._use_most_recent_calibration_radio_button.setChecked(True)
+ elif self._calibrate_from_active_recording_radio_button.isChecked():
+ toml_path = self._check_active_recording_for_calibration_toml()
+ else: #no button checked -> initialize
+ toml_path = self._check_active_recording_for_calibration_toml()
+ if toml_path is not None:
+ self._load_calibration_from_file_radio_button.setChecked(True)
+ else:
+ toml_path = get_last_successful_calibration_toml_path()
+ self._use_most_recent_calibration_radio_button.setChecked(True)
self._calibration_toml_path = toml_path
@@ -137,7 +133,7 @@ class CalibrationControlPanel(QWidget):
self._handle_calibrate_from_active_recording_toggled
)
- self._calibrate_from_active_recording_button = QPushButton("Calibrate from Videos")
+ self._calibrate_from_active_recording_button = QPushButton("Run calibration...")
hbox.addWidget(self._calibrate_from_active_recording_button)
self._calibrate_from_active_recording_button.setEnabled(False)
@@ -163,14 +159,14 @@ class CalibrationControlPanel(QWidget):
return self._use_most_recent_calibration_radio_button
def update_calibrate_from_active_recording_button_text(self):
- active_recording_info = self._get_active_recording_info_callable()
+ active_recording_info = self._get_active_recording_info()
if active_recording_info is None:
active_path_str = f"- No active recording selected -"
else:
if not active_recording_info.synchronized_videos_status_check:
active_path_str = f"Recording: {active_recording_info.name} has no synchronized videos!"
else:
- active_path_str = f"Calibrate from Recording: {self._get_active_recording_info_callable().name}"
+ active_path_str = f"Calibrate from Recording: {self._get_active_recording_info().name}"
self._calibrate_from_active_recording_button.setToolTip(active_path_str)
self.update_calibration_toml_path()
@@ -192,7 +188,7 @@ class CalibrationControlPanel(QWidget):
self.update_calibration_toml_path()
def _handle_calibrate_from_active_recording_toggled(self, checked):
- active_recording_info = self._get_active_recording_info_callable()
+ active_recording_info = self._get_active_recording_info()
self.update_calibrate_from_active_recording_button_text()
self.update_calibration_toml_path()
@@ -221,15 +217,15 @@ class CalibrationControlPanel(QWidget):
calibration_toml_path_selection = dialog.getOpenFileName(
self,
"Select 'toml' containing camera calibration info",
- str(self._get_active_recording_info_callable().path),
+ str(self._get_active_recording_info().path),
"Camera Calibration TOML (*.toml)",
)
if len(calibration_toml_path_selection) > 0:
- self._user_selected_calibration_toml_path_str = calibration_toml_path_selection[0]
- logger.info(f"User selected camera calibration toml path:{self._user_selected_calibration_toml_path_str}")
- self._show_selected_calibration_toml_path(self._user_selected_calibration_toml_path_str)
- self.update_calibration_toml_path(toml_path=self._user_selected_calibration_toml_path_str)
- return self.calibration_toml_path
+ self._user_selected_toml_path = calibration_toml_path_selection[0]
+ logger.info(f"User selected camera calibration toml path:{self._user_selected_toml_path}")
+ self._show_selected_calibration_toml_path(self._user_selected_toml_path)
+ 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):
@@ -261,7 +257,7 @@ class CalibrationControlPanel(QWidget):
if not charuco_square_size_mm:
charuco_square_size_mm = float(self._charuco_square_size_line_edit.text())
- active_recording_info = self._get_active_recording_info_callable()
+ active_recording_info = self._get_active_recording_info()
if active_recording_info is None:
logger.error("Cannot calibrate from active recording - no active recording selected")
return
@@ -287,6 +283,12 @@ class CalibrationControlPanel(QWidget):
self._anipose_calibration_frame_worker.finished.connect(self.update_calibration_toml_path)
+ def _check_active_recording_for_calibration_toml(self):
+ active_rec = self._get_active_recording_info()
+ if active_rec is not None:
+ if active_rec.calibration_toml_check:
+ return self._get_active_recording_info().calibration_toml_path
+
if __name__ == "__main__":
from PyQt6.QtWidgets import QApplication
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.py
index bfa43d85..17ebc78c 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
@@ -10,14 +10,6 @@ from skellycam import SkellyCamParameterTreeWidget
from freemocap.gui.qt.widgets.control_panel.process_mocap_data_panel.process_motion_capture_data_panel import (
ProcessMotionCaptureDataPanel,
)
-from freemocap.system.paths_and_files_names import (
- HAMMER_AND_WRENCH_EMOJI_STRING,
- CAMERA_WITH_FLASH_EMOJI_STRING,
- THREE_HEARTS_EMOJI_STRING,
- ROBOT_EMOJI_STRING,
- WIND_EMOJI_STRING,
- SPARKLES_EMOJI_STRING,
-)
class ControlPanelDockWidget(QDockWidget):
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.py
index 340d5095..e1709b5e 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,7 +1,7 @@
-from pyqtgraph.parametertree import Parameter, ParameterTree
+from pyqtgraph.parametertree import Parameter
-from freemocap.parameter_info_models.recording_processing_parameter_models import MediapipeParametersModel, \
- RecordingProcessingParameterModel, AniposeTriangulate3DParametersModel, PostProcessingParametersModel, \
+from freemocap.data_layer.recording_models.post_processing_parameter_models import MediapipeParametersModel, \
+ PostProcessingParameterModel, AniposeTriangulate3DParametersModel, PostProcessingParametersModel, \
ButterworthFilterParametersModel
BUTTERWORTH_ORDER = "Order"
@@ -145,12 +145,12 @@ def create_post_processing_parameter_group(
def extract_parameter_model_from_parameter_tree(
parameter_object: Parameter,
-) -> RecordingProcessingParameterModel:
+) -> PostProcessingParameterModel:
parameter_values_dictionary = extract_processing_parameter_model_from_tree(parameter_object=parameter_object)
model_complexity_integer = get_integer_from_model_complexity(parameter_values_dictionary[MODEL_COMPLEXITY])
- return RecordingProcessingParameterModel(
+ return PostProcessingParameterModel(
mediapipe_parameters_model=MediapipeParametersModel(
model_complexity=model_complexity_integer,
min_detection_confidence=parameter_values_dictionary[MINIMUM_DETECTION_CONFIDENCE],
diff --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.py
index 4c4c40c3..a73be881 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
@@ -10,9 +10,9 @@ from pyqtgraph.parametertree import Parameter, ParameterTree
from freemocap.gui.qt.widgets.control_panel.calibration_control_panel import CalibrationControlPanel
from freemocap.gui.qt.widgets.control_panel.process_mocap_data_panel.parameter_groups.create_parameter_groups import (
- create_mediapipe_parameter_group,
- create_3d_triangulation_prarameter_group,
- create_post_processing_parameter_group,
+ create_mediapipe_parameter_group,
+ create_3d_triangulation_prarameter_group,
+ create_post_processing_parameter_group,
extract_parameter_model_from_parameter_tree,
SKIP_2D_IMAGE_TRACKING_NAME,
SKIP_3D_TRIANGULATION_NAME,
@@ -21,8 +21,8 @@ from freemocap.gui.qt.widgets.control_panel.process_mocap_data_panel.parameter_g
from freemocap.gui.qt.workers.process_motion_capture_data_thread_worker import (
ProcessMotionCaptureDataThreadWorker,
)
-from freemocap.parameter_info_models.recording_processing_parameter_models import (
- RecordingProcessingParameterModel,
+from freemocap.data_layer.recording_models.post_processing_parameter_models import (
+ PostProcessingParameterModel,
)
logger = logging.getLogger(__name__)
@@ -33,7 +33,7 @@ class ProcessMotionCaptureDataPanel(QWidget):
def __init__(
self,
- recording_processing_parameters: RecordingProcessingParameterModel,
+ recording_processing_parameters: PostProcessingParameterModel,
get_active_recording_info: Callable,
kill_thread_event: threading.Event,
parent=None,
@@ -55,7 +55,7 @@ class ProcessMotionCaptureDataPanel(QWidget):
self._layout.addWidget(calibration_group_box)
self._calibration_control_panel = CalibrationControlPanel(
- get_active_recording_info_callable=self._get_active_recording_info,
+ get_active_recording_info=self._get_active_recording_info,
kill_thread_event=self._kill_thread_event,
parent=self,
)
@@ -94,7 +94,7 @@ class ProcessMotionCaptureDataPanel(QWidget):
def _add_parameters_to_parameter_tree_widget(
self,
parameter_tree_widget: ParameterTree,
- session_processing_parameter_model: RecordingProcessingParameterModel,
+ session_processing_parameter_model: PostProcessingParameterModel,
):
parameter_group = self._convert_session_processing_parameter_model_to_parameter_group(
session_processing_parameter_model
@@ -105,7 +105,7 @@ class ProcessMotionCaptureDataPanel(QWidget):
def _convert_session_processing_parameter_model_to_parameter_group(
self,
- session_processing_parameter_model: RecordingProcessingParameterModel,
+ session_processing_parameter_model: PostProcessingParameterModel,
):
return Parameter.create(
@@ -149,7 +149,7 @@ class ProcessMotionCaptureDataPanel(QWidget):
def _create_session_parameter_model(
self,
- ) -> RecordingProcessingParameterModel:
+ ) -> PostProcessingParameterModel:
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()
diff --git a/freemocap/gui/qt/widgets/directory_view_widget.py b/freemocap/gui/qt/widgets/directory_view_widget.py
index af7e8398..a3b5f96c 100644
--- a/freemocap/gui/qt/widgets/directory_view_widget.py
+++ b/freemocap/gui/qt/widgets/directory_view_widget.py
@@ -8,8 +8,8 @@ from PyQt6.QtGui import QFileSystemModel
from PyQt6.QtWidgets import QLabel, QMenu, QTreeView, QVBoxLayout, QWidget, QPushButton
from qtpy import QtGui
-from freemocap.system.paths_and_files_names import get_recording_session_folder_path
from freemocap.system.open_file import open_file
+from freemocap.system.paths_and_filenames.path_getters import get_recording_session_folder_path
logger = logging.getLogger(__name__)
diff --git a/freemocap/gui/qt/widgets/home_widget.py b/freemocap/gui/qt/widgets/home_widget.py
index ffdec296..c95a033b 100644
--- a/freemocap/gui/qt/widgets/home_widget.py
+++ b/freemocap/gui/qt/widgets/home_widget.py
@@ -18,7 +18,7 @@ from freemocap.gui.qt.actions_and_menus.actions import (
IMPORT_VIDEOS_ACTION_NAME,
Actions,
)
-from freemocap.system.paths_and_files_names import PATH_TO_FREEMOCAP_LOGO_SVG, SPARKLES_EMOJI_STRING
+from freemocap.system.paths_and_filenames.file_and_folder_names import PATH_TO_FREEMOCAP_LOGO_SVG
logger = logging.getLogger(__name__)
@@ -80,9 +80,13 @@ class HomeWidget(QWidget):
def _make_version_label(self):
hbox = QHBoxLayout()
self._layout.addLayout(hbox)
- version_label = QLabel(f"{freemocap.__version__}")
+ version_label_string = f'source:<a href="https://github.com/freemocap/freemocap" style="color: #777777;"> {freemocap.__version__}</a>'
+
+ version_label = QLabel(version_label_string)
version_label.setAlignment(Qt.AlignmentFlag.AlignRight)
- version_label.setStyleSheet("font-size: 14px;color: #777777")
+ version_label.setStyleSheet("font-size: 12px;color: #777777")
+ version_label.setOpenExternalLinks(True)
+
hbox.addWidget(version_label)
def _add_code_and_docs_links(self):
@@ -93,42 +97,26 @@ class HomeWidget(QWidget):
privacy_policy_link_label = QLabel(privacy_policy_link_string)
privacy_policy_link_label.setOpenExternalLinks(True)
hbox.addWidget(privacy_policy_link_label)
- source_code_label = f'<a href="https://github.com/freemocap/freemocap" style="color: #333333;">code</a>'
- source_code_label = QLabel(source_code_label)
- source_code_label.setOpenExternalLinks(True)
- hbox.addWidget(source_code_label, alignment=Qt.AlignmentFlag.AlignCenter)
- # vbox.addWidget(QLabel("|"))
docs_string = '<a href="https://freemocap.readthedocs.io/en/latest/" style="color: #333333;">docs</a>'
docs_string = QLabel(docs_string)
docs_string.setOpenExternalLinks(True)
hbox.addWidget(docs_string, alignment=Qt.AlignmentFlag.AlignCenter)
hbox.addStretch(1)
-
-
-
def _create_user_info_consent_checkbox(self):
-
hbox = QHBoxLayout()
self._layout.addLayout(hbox)
hbox.addStretch(1)
self._send_pings_checkbox = QCheckBox("Send anonymous usage information")
self._send_pings_checkbox.setChecked(True)
hbox.addWidget(self._send_pings_checkbox)
-
-
-
-
-
hbox.addStretch(1)
@property
def consent_to_send_usage_information(self):
return self._send_pings_checkbox.isChecked()
-
def _welcome_to_freemocap_title(self):
- # TO DO - this shouldn't be part of the `camera_view_panel` - it should be its own thing that gets swapped out on session start
logger.info("Creating `welcome to freemocap` layout")
session_title_label = QLabel("Welcome to FreeMoCap!")
@@ -142,6 +130,7 @@ class HomeWidget(QWidget):
freemocap_logo_label.sizePolicy().setHorizontalStretch(1)
freemocap_logo_label.sizePolicy().setVerticalStretch(1)
self._layout.addWidget(freemocap_logo_label)
+
freemocap_logo_pixmap = QPixmap(PATH_TO_FREEMOCAP_LOGO_SVG)
freemocap_logo_pixmap = freemocap_logo_pixmap.scaledToWidth(200)
freemocap_logo_label.setPixmap(freemocap_logo_pixmap)
diff --git a/freemocap/gui/qt/widgets/import_videos_window.py b/freemocap/gui/qt/widgets/import_videos_window.py
index 3da69617..bee784b3 100644
--- a/freemocap/gui/qt/widgets/import_videos_window.py
+++ b/freemocap/gui/qt/widgets/import_videos_window.py
@@ -7,8 +7,9 @@ from PyQt6.QtGui import QFileSystemModel
from PyQt6.QtWidgets import QVBoxLayout, QListWidget, QLabel, QFormLayout, QLineEdit, \
QTreeView, QPushButton, QDialog
-from freemocap.system.paths_and_files_names import get_recording_session_folder_path, SYNCHRONIZED_VIDEOS_FOLDER_NAME
from freemocap.system.open_file import open_file
+from freemocap.system.paths_and_filenames.file_and_folder_names import SYNCHRONIZED_VIDEOS_FOLDER_NAME
+from freemocap.system.paths_and_filenames.path_getters import get_recording_session_folder_path
no_files_found_string = "No '.mp4' video files found! \n \n Note - We only look for `.mp4` files (for now). If your videos are a different format, convert them to `mp4` via online tools like `www.cloudconvert.com`, or softwares like `HandBrake`, `ffmpeg` or any video editing software"
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.py
index 15c27b2f..62171c5c 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
@@ -7,8 +7,8 @@ from PyQt6.QtCore import pyqtSignal, QThread
from freemocap.core_processes.process_motion_capture_videos.process_recording_folder import (
process_recording_folder,
)
-from freemocap.parameter_info_models.recording_processing_parameter_models import RecordingProcessingParameterModel
-from freemocap.system.paths_and_files_names import RECORDING_PARAMETER_DICT_JSON_FILE_NAME
+from freemocap.data_layer.recording_models.post_processing_parameter_models import PostProcessingParameterModel
+from freemocap.system.paths_and_filenames.file_and_folder_names import RECORDING_PARAMETERS_JSON_FILE_NAME
from freemocap.utilities.save_dictionary_to_json import save_dictionary_to_json
logger = logging.getLogger(__name__)
@@ -18,27 +18,26 @@ class ProcessMotionCaptureDataThreadWorker(QThread):
finished = pyqtSignal()
in_progress = pyqtSignal(str)
- def __init__(self, session_processing_parameters: RecordingProcessingParameterModel,
+ def __init__(self, post_processing_parameters: PostProcessingParameterModel,
kill_event: multiprocessing.Event, parent=None):
super().__init__()
- self._session_processing_parameters = session_processing_parameters
+ self._post_processing_parameters = post_processing_parameters
self._kill_event = kill_event
-
- self._process = multiprocessing.Process(target=process_recording_folder, args=(self._session_processing_parameters, self._kill_event))
-
+ self._process = multiprocessing.Process(target=process_recording_folder, args=(self._post_processing_parameters,
+ self._kill_event))
def run(self):
logger.info(
- f"Beginning processing of motion capture data with parameters: {self._session_processing_parameters.__dict__}"
+ f"Beginning processing of motion capture data with parameters: {self._post_processing_parameters.__dict__}"
)
self._kill_event.clear()
- recording_info_dict = self._session_processing_parameters.dict(exclude={'recording_info_model'})
- Path(self._session_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._session_processing_parameters.recording_info_model.output_data_folder_path,
- file_name=RECORDING_PARAMETER_DICT_JSON_FILE_NAME,
+ save_path=self._post_processing_parameters.recording_info_model.output_data_folder_path,
+ file_name=RECORDING_PARAMETERS_JSON_FILE_NAME,
dictionary=recording_info_dict,
)
@@ -48,6 +47,7 @@ class ProcessMotionCaptureDataThreadWorker(QThread):
except Exception as e:
logger.error(f"Error processing motion capture data: {e}")
+
logger.info("Finished processing session folder!")
self.finished.emit()
diff --git a/freemocap/system/logging/configure_logging.py b/freemocap/system/logging/configure_logging.py
index 6e390975..b8e8f1ce 100644
--- a/freemocap/system/logging/configure_logging.py
+++ b/freemocap/system/logging/configure_logging.py
@@ -3,7 +3,7 @@ import logging.handlers
import sys
from logging.config import dictConfig
-from freemocap.system.paths_and_files_names import get_log_file_path
+from freemocap.system.paths_and_filenames.path_getters import get_log_file_path
DEFAULT_LOGGING = {"version": 1, "disable_existing_loggers": False}
@@ -13,6 +13,7 @@ format_string = "[%(asctime)s.%(msecs)04d] [%(levelname)8s] [%(name)s] [%(funcNa
default_logging_formatter = logging.Formatter(fmt=format_string, datefmt="%Y-%m-%d %H:%M:%S")
+# logging.basicConfig(level=logging.WARNING)
def get_logging_handlers():
dictConfig(DEFAULT_LOGGING)
diff --git a/freemocap/system/paths_and_filenames/__init__.py b/freemocap/system/paths_and_filenames/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/freemocap/system/paths_and_filenames/file_and_folder_names.py b/freemocap/system/paths_and_filenames/file_and_folder_names.py
new file mode 100644
index 00000000..c6fa6dbb
--- /dev/null
+++ b/freemocap/system/paths_and_filenames/file_and_folder_names.py
@@ -0,0 +1,61 @@
+import logging
+from pathlib import Path
+
+import freemocap
+
+logger = logging.getLogger(__name__)
+
+# directory names
+BASE_FREEMOCAP_DATA_FOLDER_NAME = "freemocap_data"
+RECORDING_SESSIONS_FOLDER_NAME = "recording_sessions"
+CALIBRATIONS_FOLDER_NAME = "calibrations"
+LOGS_INFO_AND_SETTINGS_FOLDER_NAME = "logs_info_and_settings"
+LOG_FILE_FOLDER_NAME = "logs"
+OUTPUT_DATA_FOLDER_NAME = "output_data"
+SYNCHRONIZED_VIDEOS_FOLDER_NAME = "synchronized_videos"
+ANNOTATED_VIDEOS_FOLDER_NAME = "annotated_videos"
+RAW_DATA_FOLDER_NAME = "raw_data"
+CENTER_OF_MASS_FOLDER_NAME = "center_of_mass"
+
+# file names
+MOST_RECENT_RECORDING_TOML_FILENAME = "most_recent_recording.toml"
+LAST_SUCCESSFUL_CALIBRATION_TOML_FILENAME = "last_successful_calibration.toml"
+MEDIAPIPE_2D_NPY_FILE_NAME = "mediapipe2dData_numCams_numFrames_numTrackedPoints_pixelXY.npy"
+MEDIAPIPE_BODY_WORLD_FILE_NAME = "mediapipeBodyWorld_numCams_numFrames_numTrackedPoints_XYZ.npy"
+
+RAW_MEDIAPIPE_3D_NPY_FILE_NAME = "mediapipe3dData_numFrames_numTrackedPoints_spatialXYZ.npy"
+MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME = "mediapipe3dData_numFrames_numTrackedPoints_reprojectionError.npy"
+
+MEDIAPIPE_3D_NPY_FILE_NAME = "mediaPipeSkel_3d_body_hands_face.npy"
+MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME = "mediapipe_body_3d_xyz.csv"
+MEDIAPIPE_RIGHT_HAND_3D_DATAFRAME_CSV_FILE_NAME = "mediapipe_right_hand_3d_xyz.csv"
+MEDIAPIPE_LEFT_HAND_3D_DATAFRAME_CSV_FILE_NAME = "mediapipe_left_hand_3d_xyz.csv"
+MEDIAPIPE_FACE_3D_DATAFRAME_CSV_FILE_NAME = "mediapipe_face_3d_xyz.csv"
+
+TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME = "total_body_center_of_mass_xyz.npy"
+SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME = "segmentCOM_frame_joint_xyz.npy"
+
+RECORDING_PARAMETERS_JSON_FILE_NAME = "recording_parameters.json"
+# Figshare info
+FIGSHARE_ZIP_FILE_URL = "https://figshare.com/ndownloader/files/40293973"
+FREEMOCAP_SAMPLE_DATA_RECORDING_NAME = "freemocap_sample_data"
+
+# logo
+PATH_TO_FREEMOCAP_LOGO_SVG = str(Path(freemocap.__file__).parent / "assets/logo/freemocap-logo-black-border.svg")
+
+# emoji strings
+SPARKLES_EMOJI_STRING = "\U00002728"
+SKULL_EMOJI_STRING = "\U0001F480"
+DIZZY_EMOJI_STRING = "\U0001F4AB"
+EYES_EMOJI_STRING = "\U0001F440"
+CAMERA_WITH_FLASH_EMOJI_STRING = "\U0001F4F8"
+HAMMER_AND_WRENCH_EMOJI_STRING = "\U0001F6E0"
+ROBOT_EMOJI_STRING = "\U0001F916"
+THREE_HEARTS_EMOJI_STRING = "\U0001F495"
+WIND_EMOJI_STRING = "\U0001F32C"
+GEAR_EMOJI_STRING = "\U00002699"
+FOLDER_EMOJI_STRING = "\U0001F4C1"
+DIRECTORY_EMOJI_STRING = "\U0001F4C1"
+COOL_EMOJI_STRING = "\U0001F60E"
+
+
diff --git a/freemocap/system/paths_and_files_names.py b/freemocap/system/paths_and_filenames/path_getters.py
similarity index 54%
rename from freemocap/system/paths_and_files_names.py
rename to freemocap/system/paths_and_filenames/path_getters.py
index 3ed11b29..0288965e 100644
--- a/freemocap/system/paths_and_files_names.py
+++ b/freemocap/system/paths_and_filenames/path_getters.py
@@ -6,58 +6,12 @@ from typing import Union
import toml
-import freemocap
-
-logger = logging.getLogger(__name__)
-
-# directory names
-BASE_FREEMOCAP_DATA_FOLDER_NAME = "freemocap_data"
-RECORDING_SESSIONS_FOLDER_NAME = "recording_sessions"
-CALIBRATIONS_FOLDER_NAME = "calibrations"
-LOGS_INFO_AND_SETTINGS_FOLDER_NAME = "logs_info_and_settings"
-LOG_FILE_FOLDER_NAME = "logs"
-OUTPUT_DATA_FOLDER_NAME = "output_data"
-SYNCHRONIZED_VIDEOS_FOLDER_NAME = "synchronized_videos"
-ANNOTATED_VIDEOS_FOLDER_NAME = "annotated_videos"
-RAW_DATA_FOLDER_NAME = "raw_data"
-CENTER_OF_MASS_FOLDER_NAME = "center_of_mass"
-
-# file names
-MOST_RECENT_RECORDING_TOML_FILENAME = "most_recent_recording.toml"
-LAST_SUCCESSFUL_CALIBRATION_TOML_FILENAME = "last_successful_calibration.toml"
-MEDIAPIPE_2D_NPY_FILE_NAME = "mediapipe2dData_numCams_numFrames_numTrackedPoints_pixelXY.npy"
-MEDIAPIPE_BODY_WORLD_FILE_NAME = "mediapipeBodyWorld_numCams_numFrames_numTrackedPoints_XYZ.npy"
-MEDIAPIPE_3D_NPY_FILE_NAME = "mediaPipeSkel_3d_body_hands_face.npy"
-RAW_MEDIAPIPE_3D_NPY_FILE_NAME = "mediapipe3dData_numFrames_numTrackedPoints_spatialXYZ.npy"
-MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME = "mediapipe3dData_numFrames_numTrackedPoints_reprojectionError.npy"
-MEDIAPIPE_BODY_3D_DATAFRAME_CSV_FILE_NAME = "mediapipe_body_3d_xyz.csv"
-RECORDING_PARAMETER_DICT_JSON_FILE_NAME = "recording_parameter_dict.json"
-
-SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME = "segmentCOM_frame_joint_xyz.npy"
-
-TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME = "total_body_center_of_mass_xyz.npy"
-
-# Figshare info
-FIGSHARE_ZIP_FILE_URL = "https://figshare.com/ndownloader/files/40293973"
-FIGSHARE_SAMPLE_DATA_FILE_NAME = "freemocap_sample_data"
-
-# logo
-PATH_TO_FREEMOCAP_LOGO_SVG = str(Path(freemocap.__file__).parent.parent / "assets/logo/freemocap-logo-black-border.svg")
-
-# emoji strings
-SPARKLES_EMOJI_STRING = "\U00002728"
-DIZZY_EMOJI_STRING = "\U0001F4AB"
-EYES_EMOJI_STRING = "\U0001F440"
-SKULL_EMOJI_STRING = "\U0001F480"
-CAMERA_WITH_FLASH_EMOJI_STRING = "\U0001F4F8"
-HAMMER_AND_WRENCH_EMOJI_STRING = "\U0001F6E0"
-ROBOT_EMOJI_STRING = "\U0001F916"
-THREE_HEARTS_EMOJI_STRING = "\U0001F495"
-WIND_EMOJI_STRING = "\U0001F32C"
-GEAR_EMOJI_STRING = "\U00002699"
-FOLDER_EMOJI_STRING = "\U0001F4C1"
-DIRECTORY_EMOJI_STRING = "\U0001F4C1"
-COOL_EMOJI_STRING = "\U0001F60E"
+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
def os_independent_home_dir():
@@ -133,6 +87,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}"
@@ -175,11 +130,12 @@ def get_logs_info_and_settings_folder_path(create_folder: bool = True):
def get_css_stylesheet_path():
# return str(Path(__file__).parent.parent / "gui" / "qt" / "style_sheet" / "ElegantDark.qss")
# return str(Path(__file__).parent.parent / "gui" / "qt" / "style_sheet" / "FunkyTown.qss")
- return str(Path(__file__).parent.parent / "gui" / "qt" / "style_sheet" / "qt_style_sheet.css")
+ return str(Path(__file__).parent.parent.parent / "gui" / "qt" / "style_sheet" / "qt_style_sheet.css")
def get_scss_stylesheet_path():
- return str(Path(__file__).parent.parent / "gui" / "qt" / "style_sheet" / "qt_style_sheet.scss")
+ return str(Path(__file__).parent.parent.parent / "gui" / "qt" / "style_sheet" / "qt_style_sheet.scss")
+
def get_most_recent_recording_toml_path():
return str(Path(get_logs_info_and_settings_folder_path()) / MOST_RECENT_RECORDING_TOML_FILENAME)
@@ -228,3 +184,81 @@ def get_blender_file_name(recording_name: 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:
+ for subfolder_path in Path(recording_folder_path).iterdir():
+ if subfolder_path.name == OUTPUT_DATA_FOLDER_NAME:
+ return str(subfolder_path)
+
+ raise Exception(f"Could not find a data folder in path {str(recording_folder_path)}")
+
+
+def get_synchronized_videos_folder_path(recording_folder_path: Union[str, Path]) -> str:
+ for subfolder_path in Path(recording_folder_path).iterdir():
+ if subfolder_path.name == SYNCHRONIZED_VIDEOS_FOLDER_NAME:
+ return str(subfolder_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:
+ 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:
+ raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAME
+ if raw_data_subfolder_path.exists:
+ raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]
+ if RAW_MEDIAPIPE_3D_NPY_FILE_NAME in raw_data_npy_path_list:
+ return str(raw_data_subfolder_path / RAW_MEDIAPIPE_3D_NPY_FILE_NAME)
+
+ 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:
+ path = Path(output_data_folder) / MEDIAPIPE_3D_NPY_FILE_NAME
+ return str(path)
+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_NAME
+ if center_of_mass_subfolder_path.exists:
+ center_of_mass_npy_path_list = [path.name for path in center_of_mass_subfolder_path.glob("*.npy")]
+
+ if TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME in center_of_mass_npy_path_list:
+ return str(center_of_mass_subfolder_path / TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME)
+
+ 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:
+ center_of_mass_subfolder_path = Path(output_data_folder) / CENTER_OF_MASS_FOLDER_NAME
+ if center_of_mass_subfolder_path.exists:
+ center_of_mass_npy_path_list = [path.name for path in center_of_mass_subfolder_path.glob("*.npy")]
+
+ if SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME in center_of_mass_npy_path_list:
+ return str(center_of_mass_subfolder_path / SEGMENT_CENTER_OF_MASS_NPY_FILE_NAME)
+
+ raise 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:
+ raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAME
+ if raw_data_subfolder_path.exists:
+ raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]
+
+ if MEDIAPIPE_2D_NPY_FILE_NAME in raw_data_npy_path_list:
+ return str(raw_data_subfolder_path / MEDIAPIPE_2D_NPY_FILE_NAME)
+
+ 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:
+ raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAME
+ if raw_data_subfolder_path.exists:
+ raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]
+
+ if MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME in raw_data_npy_path_list:
+ 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/tests/conftest.py b/freemocap/tests/conftest.py
index 5c27f980..10d1dcb5 100644
--- a/freemocap/tests/conftest.py
+++ b/freemocap/tests/conftest.py
@@ -1,22 +1,22 @@
import pytest
-from freemocap.tests.utilities.load_sample_data import (
- load_sample_data,
- find_output_data_folder_path,
- find_raw_skeleton_npy_file_name,
- find_synchronized_videos_folder_path,
- find_image_tracking_data_file_name,
- find_reprojection_error_file_name,
- find_total_body_center_of_mass_file_name,
+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,
)
-from freemocap.tests.utilities.process_recording_headless import process_recording_headless, find_calibration_toml_path
def pytest_sessionstart():
- pytest.sample_session_folder_path = load_sample_data()
+ pytest.sample_session_folder_path = download_sample_data()
calibration_toml_path = find_calibration_toml_path(pytest.sample_session_folder_path)
process_recording_headless(
- recording_path=pytest.sample_session_folder_path, path_to_camera_calibration_toml=calibration_toml_path
+ recording_path=pytest.sample_session_folder_path,
+ path_to_camera_calibration_toml=calibration_toml_path,
+ use_tqdm=False,
)
@@ -27,32 +27,32 @@ def sample_session_path():
@pytest.fixture
def synchronized_video_folder_path():
- return find_synchronized_videos_folder_path(pytest.sample_session_folder_path)
+ return get_synchronized_videos_folder_path(pytest.sample_session_folder_path)
@pytest.fixture
def data_folder_path():
- return find_output_data_folder_path(pytest.sample_session_folder_path)
+ return get_output_data_folder_path(pytest.sample_session_folder_path)
@pytest.fixture
def raw_skeleton_npy_file_path():
- return find_raw_skeleton_npy_file_name(find_output_data_folder_path(pytest.sample_session_folder_path))
+ return get_raw_skeleton_npy_file_name(get_output_data_folder_path(pytest.sample_session_folder_path))
@pytest.fixture
def total_body_center_of_mass_file_path():
- return find_total_body_center_of_mass_file_name(find_output_data_folder_path(pytest.sample_session_folder_path))
+ return get_total_body_center_of_mass_file_path(get_output_data_folder_path(pytest.sample_session_folder_path))
@pytest.fixture
-def image_tracking_data_file_name():
- return find_image_tracking_data_file_name(find_output_data_folder_path(pytest.sample_session_folder_path))
+def image_tracking_data_file_path():
+ return get_image_tracking_data_file_name(get_output_data_folder_path(pytest.sample_session_folder_path))
@pytest.fixture
-def reprojection_error_file_name():
- return find_reprojection_error_file_name(find_output_data_folder_path(pytest.sample_session_folder_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
diff --git a/freemocap/tests/test_image_tracking_data_shape.py b/freemocap/tests/test_image_tracking_data_shape.py
index 1205f69f..5c34e5f1 100644
--- a/freemocap/tests/test_image_tracking_data_shape.py
+++ b/freemocap/tests/test_image_tracking_data_shape.py
@@ -1,18 +1,19 @@
-import pytest
-import numpy as np
from pathlib import Path
from typing import Union
-from freemocap.tests.utilities.get_number_of_frames_of_videos_in_a_folder import (
+import numpy as np
+import pytest
+
+from freemocap.utilities.get_number_of_frames_of_videos_in_a_folder import (
get_number_of_frames_of_videos_in_a_folder,
)
from freemocap.utilities.get_video_paths import get_video_paths
[email protected]("synchronized_video_folder_path", "image_tracking_data_file_name")
[email protected]("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_name: Union[str, Path],
+ image_tracking_data_file_path,
):
"""
test that the `mediapipe 2d detection` process worked correctly by checking:
@@ -23,15 +24,15 @@ def test_image_tracking_data_shape(
TODO - check number of tracked points vs 'expected' number of tracked points
"""
- assert Path(image_tracking_data_file_name).is_file(), f"{image_tracking_data_file_name} is not a file"
+ assert Path(image_tracking_data_file_path).is_file(), f"{image_tracking_data_file_path} is not a file"
- image_tracking_data = np.load(image_tracking_data_file_name)
+ image_tracking_data = np.load(image_tracking_data_file_path)
list_of_video_paths = get_video_paths(Path(synchronized_video_folder_path))
number_of_videos = len(list_of_video_paths)
assert (
image_tracking_data.shape[0] == number_of_videos
- ), f"Number of videos in {image_tracking_data_file_name} does not match number of videos in synchronized videos folder"
+ ), f"Number of videos in {image_tracking_data_file_path} does not match number of videos in synchronized videos folder"
frame_count = get_number_of_frames_of_videos_in_a_folder(synchronized_video_folder_path)
@@ -40,7 +41,7 @@ def test_image_tracking_data_shape(
), f"Videos in {synchronized_video_folder_path} have different frame counts: {frame_count}"
assert (
image_tracking_data.shape[1] == frame_count[0]
- ), f"Number of frames in {image_tracking_data_file_name} does not match number of frames of videos in {synchronized_video_folder_path}"
+ ), f"Number of frames in {image_tracking_data_file_path} does not match number of frames of videos in {synchronized_video_folder_path}"
# TODO - check number of tracked points vs 'expected' number of tracked points
diff --git a/freemocap/tests/test_mediapipe_skeleton_data_shape.py b/freemocap/tests/test_mediapipe_skeleton_data_shape.py
index 65b0b2e0..26620b86 100644
--- a/freemocap/tests/test_mediapipe_skeleton_data_shape.py
+++ b/freemocap/tests/test_mediapipe_skeleton_data_shape.py
@@ -1,17 +1,19 @@
-import pytest
-import numpy as np
from pathlib import Path
from typing import Union
-from freemocap.tests.utilities.get_number_of_frames_of_videos_in_a_folder import (
+import numpy as np
+import pytest
+
+from freemocap.utilities.get_number_of_frames_of_videos_in_a_folder import (
get_number_of_frames_of_videos_in_a_folder,
)
[email protected]("synchronized_video_folder_path", "raw_skeleton_npy_file_path", "reprojection_error_file_name")
+
[email protected]("synchronized_video_folder_path", "raw_skeleton_npy_file_path", "reprojection_error_file_path")
def test_mediapipe_skeleton_data_shape(
synchronized_video_folder_path: Union[str, Path],
raw_skeleton_npy_file_path: Union[str, Path],
- reprojection_error_file_name: Union[str, Path],
+ reprojection_error_file_path,
):
"""
test that the `mediapipe 3d detection` process worked correctly by checking:
@@ -33,16 +35,16 @@ def test_mediapipe_skeleton_data_shape(
), f"3d skeleton data file should have 3 dimensions - {raw_skeleton_npy_file_path}"
assert Path(
- reprojection_error_file_name
- ).is_file(), f"3d skeleton reprojection error data file does not exist at {reprojection_error_file_name}"
+ 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_name
+ reprojection_error_file_path
)
assert (
len(skeleton_reprojection_error_fr_mar.shape) == 2
- ), f"3d skeleton reprojection error data file should have 2 dimensions {reprojection_error_file_name}"
+ ), f"3d skeleton reprojection error data file should have 2 dimensions {reprojection_error_file_path}"
frame_count = get_number_of_frames_of_videos_in_a_folder(synchronized_video_folder_path)
assert (
diff --git a/freemocap/tests/test_synchronized_video_frame_counts.py b/freemocap/tests/test_synchronized_video_frame_counts.py
index aa9f9a44..dda23745 100644
--- a/freemocap/tests/test_synchronized_video_frame_counts.py
+++ b/freemocap/tests/test_synchronized_video_frame_counts.py
@@ -1,12 +1,14 @@
-import pytest
from pathlib import Path
from typing import Union
-from freemocap.tests.utilities.get_number_of_frames_of_videos_in_a_folder import (
+import pytest
+
+from freemocap.utilities.get_number_of_frames_of_videos_in_a_folder import (
get_number_of_frames_of_videos_in_a_folder,
)
from freemocap.utilities.get_video_paths import get_video_paths
+
@pytest.mark.usefixtures("synchronized_video_folder_path")
def test_synchronized_video_frame_counts(synchronized_video_folder_path: Union[Path, str]):
"""
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.py
index 22a96825..515d83f9 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
@@ -1,12 +1,14 @@
-import pytest
-import numpy as np
from pathlib import Path
from typing import Union
-from freemocap.tests.utilities.get_number_of_frames_of_videos_in_a_folder import (
+import numpy as np
+import pytest
+
+from freemocap.utilities.get_number_of_frames_of_videos_in_a_folder import (
get_number_of_frames_of_videos_in_a_folder,
)
+
@pytest.mark.usefixtures("synchronized_video_folder_path", "total_body_center_of_mass_file_path")
def test_total_body_center_of_mass_data_shape(
synchronized_video_folder_path: Union[str, Path],
diff --git a/freemocap/tests/utilities/load_sample_data.py b/freemocap/tests/utilities/load_sample_data.py
deleted file mode 100644
index 049b8b78..00000000
--- a/freemocap/tests/utilities/load_sample_data.py
+++ /dev/null
@@ -1,111 +0,0 @@
-import io
-import logging
-from typing import Union
-
-import requests
-import zipfile
-from pathlib import Path
-
-from freemocap.system.paths_and_files_names import (
- CENTER_OF_MASS_FOLDER_NAME,
- FIGSHARE_SAMPLE_DATA_FILE_NAME,
- FIGSHARE_ZIP_FILE_URL,
- MEDIAPIPE_2D_NPY_FILE_NAME,
- RAW_MEDIAPIPE_3D_NPY_FILE_NAME,
- MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME,
- OUTPUT_DATA_FOLDER_NAME,
- RAW_DATA_FOLDER_NAME,
- SYNCHRONIZED_VIDEOS_FOLDER_NAME,
- TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME, get_recording_session_folder_path,
-)
-
-logger = logging.getLogger(__name__)
-
-# TODO - some of the naming in this file is inconsistent with the rest of the codebase. Needs fixed at some point. Also I think a lot of the `find_..` functions should be in a different file?
-
-
-def load_sample_data(sample_data_zip_file_url: str = FIGSHARE_ZIP_FILE_URL) -> str:
- try:
- logger.info(f"Downloading sample data from {sample_data_zip_file_url}...")
-
- recording_session_folder_path = Path(get_recording_session_folder_path())
- recording_session_folder_path.mkdir(parents=True, exist_ok=True)
-
- r = requests.get(FIGSHARE_ZIP_FILE_URL, stream=True)
- r.raise_for_status() # Check if request was successful
-
- z = zipfile.ZipFile(io.BytesIO(r.content))
- z.extractall(recording_session_folder_path)
-
- figshare_sample_data_path = recording_session_folder_path / FIGSHARE_SAMPLE_DATA_FILE_NAME
- logger.info(f"Sample data extracted to {str(figshare_sample_data_path)}")
- return str(figshare_sample_data_path)
-
- except requests.exceptions.RequestException as e:
- logger.error(f"Request failed: {e}")
- except zipfile.BadZipFile as e:
- logger.error(f"Failed to unzip the file: {e}")
-
-
-def find_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)
-
- raise Exception(f"Could not find a data folder in path {str(recording_folder_path)}")
-
-
-def find_synchronized_videos_folder_path(recording_folder_path: Union[str, Path]) -> str:
- for subfolder_path in Path(recording_folder_path).iterdir():
- if subfolder_path.name == SYNCHRONIZED_VIDEOS_FOLDER_NAME:
- return str(subfolder_path)
-
- raise Exception(f"Could not find a videos folder in path {str(recording_folder_path)}")
-
-
-def find_raw_skeleton_npy_file_name(data_folder_name: Union[str,Path])->str:
- raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAME
- if raw_data_subfolder_path.exists:
- raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]
- if RAW_MEDIAPIPE_3D_NPY_FILE_NAME in raw_data_npy_path_list:
- return str(raw_data_subfolder_path / RAW_MEDIAPIPE_3D_NPY_FILE_NAME)
-
- raise Exception(f"Could not find a skeleton NPY file in path {str(data_folder_name)}")
-
-
-def find_total_body_center_of_mass_file_name(data_folder_name: Union[str,Path])->str:
- center_of_mass_subfolder_path = Path(data_folder_name) / CENTER_OF_MASS_FOLDER_NAME
- if center_of_mass_subfolder_path.exists:
- center_of_mass_npy_path_list = [path.name for path in center_of_mass_subfolder_path.glob("*.npy")]
-
- if TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME in center_of_mass_npy_path_list:
- return str(center_of_mass_subfolder_path / TOTAL_BODY_CENTER_OF_MASS_NPY_FILE_NAME)
-
- raise Exception(f"Could not find a total body center of mass npy file in path {str(data_folder_name)}")
-
-
-def find_image_tracking_data_file_name(data_folder_name: Union[str,Path])->str:
- raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAME
- if raw_data_subfolder_path.exists:
- raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]
-
- if MEDIAPIPE_2D_NPY_FILE_NAME in raw_data_npy_path_list:
- return str(raw_data_subfolder_path / MEDIAPIPE_2D_NPY_FILE_NAME)
-
- raise Exception(f"Could not find a 2d data file in path {str(data_folder_name)}")
-
-
-def find_reprojection_error_file_name(data_folder_name: Union[str,Path])->str:
- raw_data_subfolder_path = Path(data_folder_name) / RAW_DATA_FOLDER_NAME
- if raw_data_subfolder_path.exists:
- raw_data_npy_path_list = [path.name for path in raw_data_subfolder_path.glob("*.npy")]
-
- if MEDIAPIPE_REPROJECTION_ERROR_NPY_FILE_NAME in raw_data_npy_path_list:
- 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)}")
-
-
-if __name__ == "__main__":
- sample_data_path = load_sample_data()
- print(f"Sample data downloaded successfully to path: {str(sample_data_path)}")
diff --git a/freemocap/utilities/__init__.py b/freemocap/utilities/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/freemocap/utilities/create_nested_dict_from_pydantic.py b/freemocap/utilities/create_nested_dict_from_pydantic.py
new file mode 100644
index 00000000..b1f62ba5
--- /dev/null
+++ b/freemocap/utilities/create_nested_dict_from_pydantic.py
@@ -0,0 +1,34 @@
+from ctypes import Union
+from typing import get_origin, get_args
+
+from pydantic import BaseModel
+
+
+
+def create_nested_dict(pydantic_model):
+ if not issubclass(pydantic_model, BaseModel):
+ return str(pydantic_model)
+
+ model_dict = {}
+ for name, field in pydantic_model.__annotations__.items():
+ origin = get_origin(field)
+ if origin is Union:
+ args = get_args(field)
+ if type(None) in args:
+ # Remove 'None' type from Union type
+ args = tuple(arg for arg in args if arg is not type(None))
+ if len(args) == 1:
+ field = args[0]
+ origin = get_origin(field)
+ if origin is dict or origin is list:
+ model_dict[name] = str(field)
+ else:
+ model_dict[name] = create_nested_dict(field)
+ return model_dict
+
+if __name__ == "__main__":
+ from freemocap.core_processes.detecting_things_in_2d_images.mediapipe_stuff.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
diff --git a/freemocap/utilities/download_sample_data.py b/freemocap/utilities/download_sample_data.py
new file mode 100644
index 00000000..214aa395
--- /dev/null
+++ b/freemocap/utilities/download_sample_data.py
@@ -0,0 +1,53 @@
+import io
+import logging
+import zipfile
+from pathlib import Path
+
+import requests
+
+from freemocap.system.paths_and_filenames.file_and_folder_names import (
+ FREEMOCAP_SAMPLE_DATA_RECORDING_NAME,
+ FIGSHARE_ZIP_FILE_URL,
+)
+from freemocap.system.paths_and_filenames.path_getters import get_recording_session_folder_path
+
+logger = 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_SAMPLE_DATA_RECORDING_NAME)
+ if not Path(sample_data_path).exists():
+ if download_if_needed:
+ download_sample_data()
+ else:
+ raise Exception(f"Could not find sample data at {sample_data_path} (and `download_if_needed` is False)")
+
+ return sample_data_path
+
+
+def download_sample_data(sample_data_zip_file_url: str = FIGSHARE_ZIP_FILE_URL) -> str:
+ try:
+ logger.info(f"Downloading sample data from {sample_data_zip_file_url}...")
+
+ recording_session_folder_path = Path(get_recording_session_folder_path())
+ recording_session_folder_path.mkdir(parents=True, exist_ok=True)
+
+ r = requests.get(FIGSHARE_ZIP_FILE_URL, stream=True)
+ r.raise_for_status() # Check if request was successful
+
+ z = zipfile.ZipFile(io.BytesIO(r.content))
+ z.extractall(recording_session_folder_path)
+
+ figshare_sample_data_path = recording_session_folder_path / FREEMOCAP_SAMPLE_DATA_RECORDING_NAME
+ logger.info(f"Sample data extracted to {str(figshare_sample_data_path)}")
+ return str(figshare_sample_data_path)
+
+ except requests.exceptions.RequestException as e:
+ logger.error(f"Request failed: {e}")
+ except zipfile.BadZipFile as e:
+ logger.error(f"Failed to unzip the file: {e}")
+
+
+if __name__ == "__main__":
+ sample_data_path = download_sample_data()
+ print(f"Sample data downloaded successfully to path: {str(sample_data_path)}")
diff --git a/freemocap/utilities/geometry/__init__.py b/freemocap/utilities/geometry/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/freemocap/utilities/project_3d_data_to_z_plane.py b/freemocap/utilities/geometry/project_3d_data_to_z_plane.py
similarity index 100%
rename from freemocap/utilities/project_3d_data_to_z_plane.py
rename to freemocap/utilities/geometry/project_3d_data_to_z_plane.py
diff --git a/freemocap/utilities/rotate_by_90_degrees_around_x_axis.py b/freemocap/utilities/geometry/rotate_by_90_degrees_around_x_axis.py
similarity index 100%
rename from freemocap/utilities/rotate_by_90_degrees_around_x_axis.py
rename to freemocap/utilities/geometry/rotate_by_90_degrees_around_x_axis.py
diff --git a/freemocap/tests/utilities/get_number_of_frames_of_videos_in_a_folder.py b/freemocap/utilities/get_number_of_frames_of_videos_in_a_folder.py
similarity index 100%
rename from freemocap/tests/utilities/get_number_of_frames_of_videos_in_a_folder.py
rename to freemocap/utilities/get_number_of_frames_of_videos_in_a_folder.py
diff --git a/freemocap/utilities/get_video_paths.py b/freemocap/utilities/get_video_paths.py
index 63e390ea..85ac9eed 100644
--- a/freemocap/utilities/get_video_paths.py
+++ b/freemocap/utilities/get_video_paths.py
@@ -1,7 +1,8 @@
from pathlib import Path
+from typing import Union
-def get_video_paths(path_to_video_folder: 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(
diff --git a/freemocap/utilities/remove_empty_directories.py b/freemocap/utilities/remove_empty_directories.py
new file mode 100644
index 00000000..2d1980cf
--- /dev/null
+++ b/freemocap/utilities/remove_empty_directories.py
@@ -0,0 +1,21 @@
+import logging
+from pathlib import Path
+from typing import Union
+
+logger = logging.getLogger(__name__)
+
+
+def remove_empty_directories(root_dir: Union[str, Path]):
+ """
+ Recursively remove empty directories from the root directory
+ :param root_dir: The root directory to start removing empty directories from
+ """
+ # logger.debug(f"Searching for empty directories in: {root_dir}")
+ for path in Path(root_dir).rglob("*"):
+ if path.is_dir() and not any(path.iterdir()):
+ logger.info(f"Removing empty directory: {path}")
+ path.rmdir()
+ elif path.is_dir() and any(path.iterdir()):
+ remove_empty_directories(path)
+ else:
+ continue
diff --git a/pyproject.toml b/pyproject.toml
index b4ca4cf5..755b01c6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -87,6 +87,9 @@ dynamic = ["version", "description"]
[project.optional-dependencies]
dev = ["black", "bumpver", "isort", "pip-tools", "pytest", "pytest-cov", "flit"]
+[project.packages]
+freemocap = { include = ["assets"] }
+
[project.urls]
Homepage = "https://freemocap.org"
Documentation = "https://freemocap.readthedocs.io/en/latest/"
diff --git a/src/gui/main/main.py b/src/gui/main/main.py
index d428ccdb..60ec4400 100644
--- a/src/gui/main/main.py
+++ b/src/gui/main/main.py
@@ -18,6 +18,6 @@ if __name__ == "__main__":
"--------------------------------\n"
"--------------------------------\n")
- from freemocap.__main__ import main
+ from freemocap.__main__ import freemocap_main
- main()
+ freemocap_main()