Free Motion Capture for Everyone πβ¨
TypeScript
Jon/clean up some stuff (#275)
jonmatthisf6632d86809d
diff --git a/src/gui/main/main_window/left_panel_controls/control_panel.py b/src/gui/main/main_window/left_panel_controls/control_panel.pyindex e4fc9bf0..377914bd 100644--- a/src/gui/main/main_window/left_panel_controls/control_panel.py+++ b/src/gui/main/main_window/left_panel_controls/control_panel.py@@ -10,17 +10,21 @@ from src.gui.main.main_window.left_panel_controls.toolbox_widgets.calibrate_captfrom src.gui.main.main_window.left_panel_controls.toolbox_widgets.camera_setup_control_panel import (CameraSetupControlPanel,)-from src.gui.main.main_window.left_panel_controls.toolbox_widgets.record_motion_capture_videos_panel import (- RecordMotionCatpureVideosPanel,-)-from src.gui.main.main_window.left_panel_controls.toolbox_widgets.visualize_motion_capture_data import (- VisualizeMotionCaptureDataPanel,+from src.gui.main.main_window.left_panel_controls.toolbox_widgets.motion_capture_panel import (+ MotionCapturePanel,)+import logginglogger = logging.getLogger(__name__)+panel_title_strings = {+ "cameras": "1 - Camera Setup and Control",+ "calibration": "2 - Capture Volume Calibration",+ "mocap": "3 - Record/Process/Visualize Motion Capture Data",+}+class ControlPanel:def __init__(self):@@ -45,25 +49,23 @@ class ControlPanel:@propertydef camera_setup_control_panel(self):- return self._dictionary_of_toolbox_panels["1 - Camera Setup and Control"]+ return self._dictionary_of_toolbox_panels[panel_title_strings["cameras"]]@propertydef calibrate_capture_volume_panel(self):- return self._dictionary_of_toolbox_panels["2 - Calibrate Capture Volume"]+ return self._dictionary_of_toolbox_panels[panel_title_strings["calibration"]]@property- def record_motion_capture_videos_panel(self):- return self._dictionary_of_toolbox_panels[- "3 - Record and Process Motion Capture Videos"- ]+ def motion_capture_panel(self):+ return self._dictionary_of_toolbox_panels[panel_title_strings["mocap"]]@propertydef process_session_data_panel(self):- return self.record_motion_capture_videos_panel.process_session_data_panel+ return self.motion_capture_panel.process_session_data_panel@property- def visualize_motion_capture_data_panel(self):- return self._dictionary_of_toolbox_panels["4 - Visualize Motion Capture Data"]+ def visualize_session_data_panel(self):+ return self.motion_capture_panel.visualize_session_data_panel@propertydef toolbox_widget(self):@@ -85,17 +87,15 @@ class ControlPanel:dictionary_of_toolbox_panels = {}# self._create_or_load_new_session_panel = WelcomeCreateOrLoadNewSessionPanel()dictionary_of_toolbox_panels[- "1 - Camera Setup and Control"+ panel_title_strings["cameras"]] = CameraSetupControlPanel()dictionary_of_toolbox_panels[- "2 - Calibrate Capture Volume"+ panel_title_strings["calibration"]] = CalibrateCaptureVolumePanel()dictionary_of_toolbox_panels[- "3 - Record and Process Motion Capture Videos"- ] = RecordMotionCatpureVideosPanel()- dictionary_of_toolbox_panels[- "4 - Visualize Motion Capture Data"- ] = VisualizeMotionCaptureDataPanel()+ panel_title_strings["mocap"]+ ] = MotionCapturePanel()+# self._process_session_data_panel = ProcessSessionDataPanel()return dictionary_of_toolbox_panelsdiff --git a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/calibrate_capture_volume_panel.py b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/calibrate_capture_volume_panel.pyindex df07411c..381633c6 100644--- a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/calibrate_capture_volume_panel.py+++ b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/calibrate_capture_volume_panel.py@@ -1,6 +1,7 @@import loggingfrom pathlib import Path+from PyQt6.QtCore import Qtfrom PyQt6.QtWidgets import (QWidget,QVBoxLayout,@@ -13,7 +14,6 @@ from PyQt6.QtWidgets import (QFileDialog,QRadioButton,)-from pyqtgraph.parametertree import Parameter, ParameterTreefrom src.core_processes.capture_volume_calibration.charuco_board_detection.dataclasses.charuco_board_definition import (CharucoBoardDefinition,@@ -21,6 +21,9 @@ from src.core_processes.capture_volume_calibration.charuco_board_detection.datacfrom src.core_processes.capture_volume_calibration.charuco_board_detection.default_charuco_square_size import (default_charuco_square_size_mm,)+from src.gui.main.style_stuff.styled_widgets.panel_section_title import (+ PanelSectionTitle,+)logger = logging.getLogger(__name__)@@ -31,8 +34,10 @@ class CalibrateCaptureVolumePanel(QWidget):self._layout = QVBoxLayout()self.setLayout(self._layout)+self._layout.addStretch()+ self._layout.addWidget(PanelSectionTitle("Calibration Data Source"))self._use_most_recent_calibration_radio_button = QRadioButton("Use Most Recent Calibration")@@ -42,7 +47,7 @@ class CalibrateCaptureVolumePanel(QWidget):self._layout.addWidget(self._use_most_recent_calibration_radio_button)self._load_camera_calibration_radio_button = QRadioButton(- "Load Camera Calibration..."+ "Load Camera Calibration .toml file...")self._layout.addWidget(self._load_camera_calibration_radio_button)self._load_camera_calibration_radio_button.toggled.connect(@@ -61,24 +66,21 @@ class CalibrateCaptureVolumePanel(QWidget):)self._user_selected_camera_calibration_toml_path_label = QLabel(- "No Camera Calibration TOML Loaded"+ "- No Camera Calibration TOML Loaded -")self._user_selected_camera_calibration_toml_path_label.setWordWrap(True)self._layout.addWidget(self._user_selected_camera_calibration_toml_path_label)- self._load_calibration_toml_dialog_button.hide()- self._user_selected_camera_calibration_toml_path_label.hide()- #- # self._calibrate_from_synchronized_videos_radio_button = QRadioButton(- # "Calibrate from Synchronized Videos"- # )- # self._layout.addWidget(self._calibrate_from_synchronized_videos_radio_button)- # self._calibrate_from_synchronized_videos_radio_button.toggled.connect(- # self._handle_calibrate_from_synchronized_videos_radio_button_toggled- # )- # self._calibrate_from_videos_button = QPushButton("Calibrate from `synchronized_videos/`")- # self._layout.addWidget(self._calibrate_from_videos_button)- # self._calibrate_from_videos_button.hide()+ self._load_calibration_toml_dialog_button.setEnabled(False)+ self._user_selected_camera_calibration_toml_path_label.setEnabled(False)++ self._calibrate_from_synchronized_videos_radio_button = QRadioButton(+ "Calibrate from `synchronized_videos` folder"+ )+ self._layout.addWidget(self._calibrate_from_synchronized_videos_radio_button)+ self._calibrate_from_synchronized_videos_radio_button.toggled.connect(+ self._handle_calibrate_from_synchronized_videos_radio_button_toggled+ )self._record_calibration_videos_radio_button = QRadioButton("Record New Calibration Videos"@@ -107,16 +109,32 @@ class CalibrateCaptureVolumePanel(QWidget):)self._layout.addWidget(self._process_automatically_checkbox)+ self._layout.addWidget(QLabel("___"), alignment=Qt.AlignCenter)++ camera_warning_qlabel = QLabel(+ "NOTE - For faster processing, shut down your cameras when you're done recording (i.e. press `Stop Cameras` in the 'Cameras' tab)"+ )+ camera_warning_qlabel.setWordWrap(True)+ self._layout.addWidget(camera_warning_qlabel)++ self._layout.addWidget(+ QLabel("Calibrate Capture Volume"), alignment=Qt.AlignCenter+ )+self._calibrate_capture_volume_from_videos_button = QPushButton("Calibrate Capture Volume From Videos")self._calibrate_capture_volume_from_videos_button.setEnabled(True)+ self._calibrate_capture_volume_from_videos_button.setToolTip(+ "Looks for a `calibration_videos` folder first, reverting to `synchronized_videos` if not found"+ )self._layout.addWidget(self._calibrate_capture_volume_from_videos_button,)- self._layout.addWidget(QLabel("____________"))- self._layout.addWidget(QLabel("Calibration Parameters:"))+ self._layout.addWidget(+ QLabel("Calibration Parameters:"), alignment=Qt.AlignCenter+ )qlabel_link_to_charuco_board = QLabel()qlabel_link_to_charuco_board.setText(@@ -206,20 +224,26 @@ class CalibrateCaptureVolumePanel(QWidget):def _handle_use_previous_calibration_radio_button_toggled(self):- self._hide_load_camera_calibration_stuff()- self._hide_record_new_calibration_videos_stuff()- self._enable_disable_calibration_parameters_stuff(False)+ self._disable_load_camera_calibration_stuff()+ self._disable_record_new_calibration_videos_stuff()+ self._enable_calibration_parameters_stuff(False)def _handle_load_camera_calibration_radio_button_toggled(self):- self._load_calibration_toml_dialog_button.show()- self._user_selected_camera_calibration_toml_path_label.show()- self._hide_record_new_calibration_videos_stuff()- self._enable_disable_calibration_parameters_stuff(False)+ self._load_calibration_toml_dialog_button.setEnabled(True)+ self._user_selected_camera_calibration_toml_path_label.setEnabled(True)+ self._disable_record_new_calibration_videos_stuff()+ self._enable_calibration_parameters_stuff(False)++ def _handle_calibrate_from_synchronized_videos_radio_button_toggled(self):+ self._disable_record_new_calibration_videos_stuff()+ self._disable_load_camera_calibration_stuff()+ self._enable_calibration_parameters_stuff(True)+ self._calibrate_capture_volume_from_videos_button.setEnabled(True)def _handle_record_calibration_videos_radio_button_toggled(self):- self._show_record_new_calibration_videos_stuff()- self._hide_load_camera_calibration_stuff()- self._enable_disable_calibration_parameters_stuff(True)+ self._enable_record_new_calibration_videos_stuff()+ self._disable_load_camera_calibration_stuff()+ self._enable_calibration_parameters_stuff(True)def _open_load_camera_calibration_toml_dialog(self):# from this tutorial - https://www.youtube.com/watch?v=gg5TepTc2Jg&t=649s@@ -237,22 +261,22 @@ class CalibrateCaptureVolumePanel(QWidget):self.calibration_toml_path_str)- def _hide_record_new_calibration_videos_stuff(self):- self._start_recording_button.hide()- self._stop_recording_button.hide()- self._process_automatically_checkbox.hide()- self._calibrate_capture_volume_from_videos_button.hide()+ def _disable_record_new_calibration_videos_stuff(self):+ self._start_recording_button.setEnabled(False)+ self._stop_recording_button.setEnabled(False)+ self._process_automatically_checkbox.setEnabled(False)+ self._calibrate_capture_volume_from_videos_button.setEnabled(False)- def _show_record_new_calibration_videos_stuff(self):- self._start_recording_button.show()- self._stop_recording_button.show()- self._process_automatically_checkbox.show()- self._calibrate_capture_volume_from_videos_button.show()+ def _enable_record_new_calibration_videos_stuff(self):+ self._start_recording_button.setEnabled(True)+ self._stop_recording_button.setEnabled(True)+ self._process_automatically_checkbox.setEnabled(True)+ self._calibrate_capture_volume_from_videos_button.setEnabled(True)- def _hide_load_camera_calibration_stuff(self):- self._load_calibration_toml_dialog_button.hide()- self._user_selected_camera_calibration_toml_path_label.hide()+ def _disable_load_camera_calibration_stuff(self):+ self._load_calibration_toml_dialog_button.setEnabled(False)+ self._user_selected_camera_calibration_toml_path_label.setEnabled(False)- def _enable_disable_calibration_parameters_stuff(self, bool_in: bool):+ def _enable_calibration_parameters_stuff(self, bool_in: bool):self._charuco_combo_box.setEnabled(bool_in)self._charuco_square_size_line_edit_widget.setEnabled(bool_in)diff --git a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/camera_setup_control_panel.py b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/camera_setup_control_panel.pyindex 5d88ba04..7de0209a 100644--- a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/camera_setup_control_panel.py+++ b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/camera_setup_control_panel.py@@ -61,6 +61,15 @@ class CameraSetupControlPanel(QWidget):helper_qlabel_widget.setWordWrap(True)self._layout.addWidget(helper_qlabel_widget)+ camera_warning_label = QLabel(+ "NOTE -\nThe current version of the GUI is inefficient and will start dropping frames with ~3+ cameras. This will be fixed in a future version.\n\n"+ "In the meantime, to use more cameras, record them with the `pre-alpha` version of FreeMoCap and import the `[freemocap_data]/[session_id]/SyncedVideos` folder files into the GUI with the `Import Videos` functionality."+ )+ camera_warning_label.setWordWrap(True)+ camera_warning_label.setStyleSheet("color: #770000")+ self._layout.addWidget(camera_warning_label)+ self._layout.addWidget(QLabel())+self._redetect_cameras_button = QPushButton("Detect Cameras")self._redetect_cameras_button.setEnabled(True)self._layout.addWidget(self._redetect_cameras_button)diff --git a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/record_motion_capture_videos_panel.py b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/motion_capture_panel.pysimilarity index 59%rename from src/gui/main/main_window/left_panel_controls/toolbox_widgets/record_motion_capture_videos_panel.pyrename to src/gui/main/main_window/left_panel_controls/toolbox_widgets/motion_capture_panel.pyindex 606b8830..5e5bd970 100644--- a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/record_motion_capture_videos_panel.py+++ b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/motion_capture_panel.py@@ -4,17 +4,21 @@ from PyQt6.QtWidgets import (QVBoxLayout,QWidget,QCheckBox,- QFrame,- QSpacerItem,QLabel,)from src.gui.main.main_window.left_panel_controls.toolbox_widgets.process_session_data_panel import (ProcessSessionDataPanel,)+from src.gui.main.main_window.left_panel_controls.toolbox_widgets.visualize_motion_capture_data import (+ VisualizeMotionCaptureDataPanel,+)+from src.gui.main.style_stuff.styled_widgets.panel_section_title import (+ PanelSectionTitle,+)-class RecordMotionCatpureVideosPanel(QWidget):+class MotionCapturePanel(QWidget):def __init__(self):super().__init__()@@ -23,7 +27,7 @@ class RecordMotionCatpureVideosPanel(QWidget):self._layout.addStretch()self._layout.addWidget(- QLabel("Record Synchronized Videos"), alignment=Qt.AlignCenter+ PanelSectionTitle("Record Synchronized Videos"), alignment=Qt.AlignCenter)self._start_recording_button = QPushButton("Begin Recording")self._layout.addWidget(self._start_recording_button)@@ -38,18 +42,28 @@ class RecordMotionCatpureVideosPanel(QWidget):self._process_automatically_checkbox.setChecked(True)self._layout.addWidget(self._process_automatically_checkbox)- self._open_in_blender_automatically_checkbox = QCheckBox(- "Open in Blender automatically"+ self._layout.addWidget(QLabel("___"), alignment=Qt.AlignCenter)++ process_videos_section_title = PanelSectionTitle("Process Videos")+ self._layout.addWidget(process_videos_section_title, alignment=Qt.AlignCenter)+ process_videos_section_title.setToolTip(+ "TODO: \n"+ + "- Convert this mess of buttons into a 'Parameter Tree' like the one in the 'Camera Setup' panel (see `src/core_processes/batch_processes/process_session_folder.py`)\n\n"+ + "- Add method to check what's in the `session_folder` and only enable the appropriate buttons")- self._open_in_blender_automatically_checkbox.setChecked(True)- self._layout.addWidget(self._open_in_blender_automatically_checkbox)- self._layout.insertSpacing(-1, 10)- self._layout.addWidget(QLabel("______"), alignment=Qt.AlignCenter)- self._layout.addWidget(QLabel("Process Videos"), alignment=Qt.AlignCenter)self._process_session_data_panel = ProcessSessionDataPanel()self._layout.addWidget(self._process_session_data_panel)++ self._layout.addWidget(QLabel("___"), alignment=Qt.AlignCenter)++ self._layout.addWidget(+ PanelSectionTitle("Visualize Data"), alignment=Qt.AlignCenter+ )+ self._visualize_motion_capture_data_panel = VisualizeMotionCaptureDataPanel()++ self._layout.addWidget(self._visualize_motion_capture_data_panel)self._layout.addStretch()@property@@ -57,8 +71,8 @@ class RecordMotionCatpureVideosPanel(QWidget):return self._process_session_data_panel@property- def open_in_blender_automatically_checkbox(self):- return self._open_in_blender_automatically_checkbox+ def visualize_session_data_panel(self):+ return self._visualize_motion_capture_data_panel@propertydef process_recording_automatically_checkbox(self):diff --git a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/process_session_data_panel.py b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/process_session_data_panel.pyindex 06bb28e8..3ce735b2 100644--- a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/process_session_data_panel.py+++ b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/process_session_data_panel.py@@ -11,14 +11,12 @@ from PyQt6.QtWidgets import (QLabel,)-from src.blender_stuff.get_best_guess_of_blender_path import (- get_best_guess_of_blender_path,-)+from src.core_processes.mediapipe_stuff.mediapipe_default_settings import (default_mediapipe_confidence_threshold,)-from src.gui.main.tool_tips.tool_tips_strings import (+from src.gui.main.tool_tips_and_warning_labels.tool_tips_strings import (mediapipe_confidence_cutoff_tool_tip_str,)@@ -34,15 +32,29 @@ class ProcessSessionDataPanel(QWidget):self._layout.addStretch()- self._process_all_button = QPushButton("Process All")+ camera_warning_qlabel = QLabel(+ "NOTE - For faster processing, shut down your cameras when you're done recording (i.e. press `Stop Cameras` in the 'Cameras' tab)"+ )+ camera_warning_qlabel.setWordWrap(True)+ self._layout.addWidget(camera_warning_qlabel)++ self._process_all_button = QPushButton("Process All Steps Below")self._process_all_button.setEnabled(True)self._layout.addWidget(self._process_all_button)- self._detect_2d_skeletons_button = QPushButton("Detect 2d Skeletons in Videos")+ self._open_in_blender_automatically_checkbox = QCheckBox(+ "Open in Blender automatically"+ )+ self._open_in_blender_automatically_checkbox.setChecked(True)+ self._layout.addWidget(self._open_in_blender_automatically_checkbox)++ self._detect_2d_skeletons_button = QPushButton(+ "(a) - Detect 2d Skeletons in Videos"+ )self._detect_2d_skeletons_button.setEnabled(True)self._layout.addWidget(self._detect_2d_skeletons_button)- self._triangulate_3d_data_button = QPushButton("Triangulate 3d Data")+ self._triangulate_3d_data_button = QPushButton("(b) - Triangulate 3d Data")self._triangulate_3d_data_button.setEnabled(True)self._layout.addWidget(self._triangulate_3d_data_button)@@ -58,28 +70,17 @@ class ProcessSessionDataPanel(QWidget):self._layout.addLayout(self._mediapipe_confidence_cutoff_form_layout)self._gap_fill_filter_origin_align_button = QPushButton(- "Gap Fill, Butterworth Filter, and Origin Align Skeleton data (experimental)"+ "(c) - Post-process data")- self._layout.addWidget(self._gap_fill_filter_origin_align_button)-- self._visualize_freemocap_session_button = QPushButton(- "Visualize Freemocap Session"- )-- self._convert_npy_to_csv_checkbox = QCheckBox(- "Convert 3D npy data to csv (experimental)"+ self._gap_fill_filter_origin_align_button.setToolTip(+ "Gap Fill, Butterworth Filter, and Origin Align Skeletons")- self._convert_npy_to_csv_checkbox.setChecked(True)- self._layout.addWidget(self._convert_npy_to_csv_checkbox)-- self._blender_path_form_layout = self._make_blender_path_layout()- self._layout.addLayout(self._blender_path_form_layout)+ self._layout.addWidget(self._gap_fill_filter_origin_align_button)- self._open_in_blender_button = QPushButton(- "Export to Blender (Freezes GUI, sorry!)"+ self._convert_npy_to_csv_button = QPushButton(+ "(d) - Convert 3D npy data to csv")- self._open_in_blender_button.setEnabled(True)- self._layout.addWidget(self._open_in_blender_button)+ self._layout.addWidget(self._convert_npy_to_csv_button)self._layout.addStretch()@@ -87,6 +88,10 @@ class ProcessSessionDataPanel(QWidget):def process_all_button(self):return self._process_all_button+ @property+ def open_in_blender_automatically_checkbox(self):+ return self._open_in_blender_automatically_checkbox+@propertydef detect_2d_skeletons_button(self):return self._detect_2d_skeletons_button@@ -100,8 +105,8 @@ class ProcessSessionDataPanel(QWidget):return self._use_triangulate_ransac_checkbox@property- def convert_npy_to_csv_checkbox(self):- return self._convert_npy_to_csv_checkbox+ def convert_npy_to_csv_button(self):+ return self._convert_npy_to_csv_button@propertydef triangulate_3d_data_button(self):@@ -111,11 +116,6 @@ class ProcessSessionDataPanel(QWidget):def gap_fill_filter_origin_align_button(self):return self._gap_fill_filter_origin_align_button- @property- def open_in_blender_button(self):-- return self._open_in_blender_button-@propertydef blender_exe_path_str(self):return self._blender_exe_path_str@@ -139,33 +139,3 @@ class ProcessSessionDataPanel(QWidget):q_line_edit_widget.setToolTip(mediapipe_confidence_cutoff_tool_tip_str)return q_line_edit_widget-- def _make_blender_path_layout(self):-- blender_path_layout = QVBoxLayout()-- self._open_blender_path_file_dialog_button = QPushButton(- "Locate Blender Executable"- )- blender_path_layout.addWidget(self._open_blender_path_file_dialog_button)- self._open_blender_path_file_dialog_button.clicked.connect(- self._open_blender_path_file_dialog- )- self._open_blender_path_file_dialog_button.setToolTip(- "This is the path executable that we will send the `blender export` subprocess command"- )-- self._blender_exe_path_str = get_best_guess_of_blender_path()- self._current_blender_path_label = QLabel(self._blender_exe_path_str)- # if self._blender_exe_path is None:- # self._open_blender_path_file_dialog()- blender_path_layout.addWidget(self._current_blender_path_label)-- return blender_path_layout-- def _open_blender_path_file_dialog(self):- # from this tutorial - https://www.youtube.com/watch?v=gg5TepTc2Jg&t=649s- self._blender_exe_path_str = QFileDialog.getOpenFileName()- self._blender_exe_path_str = self._blender_exe_path_str[0]- logger.info(f"User selected Blender path:{self._blender_exe_path_str}")- self._current_blender_path_label.setText(self._blender_exe_path_str)diff --git a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/visualize_motion_capture_data.py b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/visualize_motion_capture_data.pyindex e100fa3b..7992494e 100644--- a/src/gui/main/main_window/left_panel_controls/toolbox_widgets/visualize_motion_capture_data.py+++ b/src/gui/main/main_window/left_panel_controls/toolbox_widgets/visualize_motion_capture_data.py@@ -1,18 +1,35 @@+import logging++from PyQt6.QtCore import Qtfrom PyQt6.QtWidgets import (QWidget,QVBoxLayout,QPushButton,+ QLabel,+ QFileDialog,+ QHBoxLayout,+)++from src.blender_stuff.get_best_guess_of_blender_path import (+ get_best_guess_of_blender_path,+)+from src.gui.main.style_stuff.styled_widgets.panel_section_title import (+ PanelSectionTitle,)+logger = logging.getLogger(__name__)++class VisualizeMotionCaptureDataPanel(QWidget):def __init__(self):super().__init__()self._layout = QVBoxLayout()+ self.setLayout(self._layout)self._load_session_data_button = QPushButton(- "Load Session Data",+ "Show Session Data Viewer",)self._load_session_data_button.setEnabled(True)self._layout.addWidget(self._load_session_data_button)@@ -20,21 +37,45 @@ class VisualizeMotionCaptureDataPanel(QWidget):self._handle_load_session_data_button_clicked,)- self._play_button = QPushButton("Play")+ self._play_pause_button_layout = QHBoxLayout()+ self._layout.addLayout(self._play_pause_button_layout)++ self._play_button = QPushButton("TODO - Play")self._play_button.setEnabled(False)- self._layout.addWidget(self._play_button)- self._play_button.hide()+ self._play_pause_button_layout.addWidget(self._play_button)self._play_button.clicked.connect(self._handle_play_button_clicked)- self._pause_button = QPushButton("Pause")+ self._pause_button = QPushButton("TODO - Pause")self._pause_button.setEnabled(False)- self._layout.addWidget(self._pause_button)- self._pause_button.hide()+ self._play_pause_button_layout.addWidget(self._pause_button)self._pause_button.clicked.connect(self._handle_pause_button_clicked)- self._layout.addStretch()+ self._layout.addWidget(QLabel("___"), alignment=Qt.AlignCenter)- self.setLayout(self._layout)+ self._layout.addWidget(+ PanelSectionTitle("Export to Blender"), alignment=Qt.AlignCenter+ )++ self._blender_path_form_layout = self._make_blender_path_layout()+ self._layout.addLayout(self._blender_path_form_layout)++ self._generate_blend_file_button = QPushButton(+ "Generate `.blend` file (Freezes GUI, sorry!)"+ )+ self._generate_blend_file_button.setEnabled(True)+ self._layout.addWidget(self._generate_blend_file_button)++ blender_output_warning_label = QLabel(+ "NOTE:\n "+ + "- In Blender, press `Z` and select `Material Preview` to see the videos in the 3D viewport.\n"+ + "- Due to some slop in the way we make the `.blend` file, it will be difficult to retarget a mesh to the resulting armature rig. We're working to improve this output!\n"+ + "- The skeleton will be oriented based on the orientation of `Camera0`, we're working on a method to auto-align with the groundplane."+ )+ blender_output_warning_label.setWordWrap(True)++ self._layout.addWidget(blender_output_warning_label)++ self._should_pause_playback_bool = Falseself._should_pause_playback_bool = False@@ -42,6 +83,10 @@ class VisualizeMotionCaptureDataPanel(QWidget):def load_session_data_button(self):return self._load_session_data_button+ @property+ def generate_blend_file_button(self):+ return self._generate_blend_file_button+@propertydef play_button(self):return self._play_button@@ -54,6 +99,10 @@ class VisualizeMotionCaptureDataPanel(QWidget):def should_pause_playback_bool(self):return self._should_pause_playback_bool+ @property+ def blender_exe_path_str(self):+ return self._blender_exe_path_str+def _handle_load_session_data_button_clicked(self):self._load_session_data_button.setEnabled(False)self._play_button.setEnabled(False)@@ -68,3 +117,34 @@ class VisualizeMotionCaptureDataPanel(QWidget):self._should_pause_playback_bool = Trueself._play_button.setEnabled(True)self._pause_button.setEnabled(False)++ def _make_blender_path_layout(self):+ blender_path_layout = QVBoxLayout()++ self._open_blender_path_file_dialog_button = QPushButton(+ "Locate Blender Executable"+ )+ blender_path_layout.addWidget(self._open_blender_path_file_dialog_button)+ self._open_blender_path_file_dialog_button.clicked.connect(+ self._open_blender_path_file_dialog+ )+ self._open_blender_path_file_dialog_button.setToolTip(+ "This is the path executable that we will send the `blender export` subprocess command"+ )++ self._blender_exe_path_str = get_best_guess_of_blender_path()+ if self._blender_exe_path_str is None:+ self._blender_exe_path_str = " - Blender executable not specified - "+ self._current_blender_path_label = QLabel(self._blender_exe_path_str)+ # if self._blender_exe_path is None:+ # self._open_blender_path_file_dialog()+ blender_path_layout.addWidget(self._current_blender_path_label)++ return blender_path_layout++ def _open_blender_path_file_dialog(self):+ # from this tutorial - https://www.youtube.com/watch?v=gg5TepTc2Jg&t=649s+ self._blender_exe_path_str = QFileDialog.getOpenFileName()+ self._blender_exe_path_str = self._blender_exe_path_str[0]+ logger.info(f"User selected Blender path:{self._blender_exe_path_str}")+ self._current_blender_path_label.setText(self._blender_exe_path_str)diff --git a/src/gui/main/main_window/main_window.py b/src/gui/main/main_window/main_window.pyindex 0a13804b..0062d493 100644--- a/src/gui/main/main_window/main_window.py+++ b/src/gui/main/main_window/main_window.py@@ -208,15 +208,10 @@ class MainWindow(QMainWindow):)self._show_calibrate_capture_volume_panel_action.setShortcut("Ctrl+2")- self._show_record_motion_capture_videos_panel_action = QAction(- "&3 - Show Record Motion Capture Videos Panel", parent=self+ self._show_motion_capture_videos_panel_action = QAction(+ "&3 - Show Motion Capture Videos Panel", parent=self)- self._show_record_motion_capture_videos_panel_action.setShortcut("Ctrl+3")-- self._show_visualize_session_panel_action = QAction(- "&4 - Show Visualize Session Panel", parent=self- )- self._show_visualize_session_panel_action.setShortcut("Ctrl+4")+ self._show_motion_capture_videos_panel_action.setShortcut("Ctrl+3")# Supportself._donate_action = QAction("&Donate", parent=self)@@ -248,8 +243,7 @@ class MainWindow(QMainWindow):menu_bar.addMenu(navigation_menu)navigation_menu.addAction(self._show_camera_control_panel_action)navigation_menu.addAction(self._show_calibrate_capture_volume_panel_action)- navigation_menu.addAction(self._show_record_motion_capture_videos_panel_action)- navigation_menu.addAction(self._show_visualize_session_panel_action)+ navigation_menu.addAction(self._show_motion_capture_videos_panel_action)# help menuhelp_menu = QMenu("&Help", parent=menu_bar)@@ -304,14 +298,9 @@ class MainWindow(QMainWindow):self._control_panel.calibrate_capture_volume_panel))- self._show_record_motion_capture_videos_panel_action.triggered.connect(- lambda: self._control_panel.toolbox_widget.setCurrentWidget(- self._control_panel.record_motion_capture_videos_panel- )- )- self._show_visualize_session_panel_action.triggered.connect(+ self._show_motion_capture_videos_panel_action.triggered.connect(lambda: self._control_panel.toolbox_widget.setCurrentWidget(- self._control_panel.visualize_motion_capture_data_panel+ self._control_panel.motion_capture_panel))@@ -380,19 +369,23 @@ class MainWindow(QMainWindow):)# RecordVideos panel- self._control_panel.record_motion_capture_videos_panel.start_recording_button.clicked.connect(+ self._control_panel.motion_capture_panel.start_recording_button.clicked.connect(lambda: self._start_recording_videos(- panel=self._control_panel.record_motion_capture_videos_panel,+ panel=self._control_panel.motion_capture_panel,))- self._control_panel.record_motion_capture_videos_panel.stop_recording_button.clicked.connect(+ self._control_panel.motion_capture_panel.stop_recording_button.clicked.connect(lambda: self._stop_recording_videos(- panel=self._control_panel.record_motion_capture_videos_panel+ panel=self._control_panel.motion_capture_panel))# (record videos) ProcessVideos panel+ self._control_panel.process_session_data_panel.process_all_button.clicked.connect(+ self._fully_process_mocap_videos+ )+self._control_panel.process_session_data_panel.detect_2d_skeletons_button.clicked.connect(self._setup_and_launch_mediapipe_2d_detection_thread_worker)@@ -405,15 +398,21 @@ class MainWindow(QMainWindow):self._setup_and_launch_gap_fill_filter_origin_align_thread_worker)- self._control_panel.process_session_data_panel.open_in_blender_button.clicked.connect(- self._export_to_blender+ self._control_panel.process_session_data_panel.convert_npy_to_csv_button.clicked.connect(+ self._setup_and_launch_convert_npy_to_csv_thread_worker)# Visualize Mocap Data panel- self._control_panel.visualize_motion_capture_data_panel.load_session_data_button.clicked.connect(+ self._control_panel.visualize_session_data_panel.load_session_data_button.clicked.connect(self._visualize_motion_capture_data)+ self._control_panel.visualize_session_data_panel.generate_blend_file_button.clicked.connect(+ self._generate_blend_file+ )+ self._control_panel.visualize_session_data_panel.generate_blend_file_button.clicked.connect(+ self._open_blender_file+ )# (right side) File viewer panelself._right_side_panel.file_system_view_widget.show_current_session_folder_button.clicked.connect(lambda: self._set_session_folder_as_root_for_file_viewer(self._session_id)@@ -442,10 +441,6 @@ class MainWindow(QMainWindow):self._handle_videos_saved_signal)- self._control_panel.process_session_data_panel.process_all_button.clicked.connect(- self._fully_process_mocap_videos- )-self._thread_worker_manager.start_3d_processing_signal.connect(lambda: self._setup_and_launch_triangulate_3d_thread_worker(auto_process_next_stage=True@@ -460,16 +455,16 @@ class MainWindow(QMainWindow):self._thread_worker_manager.start_convert_npy_to_to_csv_signal.connect(lambda: self._setup_and_launch_convert_npy_to_csv_thread_worker(- auto_process_next_stage=False+ auto_process_next_stage=True))self._thread_worker_manager.start_blender_processing_signal.connect(- self._export_to_blender+ self._generate_blend_file)- self._control_panel.process_session_data_panel.open_in_blender_button.clicked.connect(- self._open_blender_file+ self._thread_worker_manager.start_session_data_visualization_signal.connect(+ self._visualize_motion_capture_data)def _set_session_folder_as_root_for_file_viewer(self, session_id: str):@@ -645,7 +640,7 @@ class MainWindow(QMainWindow):self._setup_and_launch_anipose_calibration_thread_worker()else: # mocap videosif (- self._control_panel.record_motion_capture_videos_panel.process_recording_automatically_checkbox.isChecked()+ self._control_panel.motion_capture_panel.process_recording_automatically_checkbox.isChecked()):self._fully_process_mocap_videos()@@ -810,9 +805,9 @@ class MainWindow(QMainWindow):auto_process_next_stage=auto_process_next_stage,)- def _export_to_blender(self):+ def _generate_blend_file(self):logger.debug(- "Open Session in Blender button clicked (this will freeze the GUI while it is running, sorry! I tried to calculate_center_of_mass it in a thread instead of a 'subprocess' but I got some kind of permission error when it tried to save the `.blend` file, so.... here we are. Frozen in the GUI. How are you? "+ "Generating `.blend` file (this will freeze the GUI while it is running, sorry! I tried to calculate_center_of_mass it in a thread instead of a 'subprocess' but I got some kind of permission error when it tried to save the `.blend` file, so.... here we are. Frozen in the GUI. How are you? ")# self._thread_worker_manager.launch_export_to_blender_thread_worker(# get_session_folder_path(self._session_id)@@ -831,11 +826,11 @@ class MainWindow(QMainWindow):blender_file_path = export_to_blender(session_folder_path=get_session_folder_path(self._session_id),- blender_exe_path=self._control_panel.process_session_data_panel.blender_exe_path_str,+ blender_exe_path=self._control_panel.visualize_session_data_panel.blender_exe_path_str,)if (- self._control_panel.record_motion_capture_videos_panel.open_in_blender_automatically_checkbox.isChecked()+ self._control_panel.process_session_data_panel.open_in_blender_automatically_checkbox.isChecked()):if blender_file_path:self._open_blender_file(blender_file_path)@@ -853,9 +848,7 @@ class MainWindow(QMainWindow):os.startfile(str(blender_file_path))def _visualize_motion_capture_data(self):- logger.info(- "`self._control_panel.visualize_motion_capture_data.load_session_data_button` was pressed "- )+ logger.info("Loading data for visualization...")skeleton_3d_npy = load_post_processed_mediapipe3d_data(Path(get_output_data_folder_path(self._session_id))diff --git a/src/gui/main/qt_utils/set_font_size.py b/src/gui/main/qt_utils/set_font_size.pynew file mode 100644index 00000000..bcd5e4e9--- /dev/null+++ b/src/gui/main/qt_utils/set_font_size.py@@ -0,0 +1,7 @@+from PyQt6.QtWidgets import QLabel+++def set_font_size(label_widget: QLabel, size: int):+ font = label_widget.font()+ font.setPointSize(size)+ label_widget.setFont(font)diff --git a/src/gui/main/style_stuff/styled_widgets/page_title.py b/src/gui/main/style_stuff/styled_widgets/page_title.pyindex 93183b5e..435cc04a 100644--- a/src/gui/main/style_stuff/styled_widgets/page_title.py+++ b/src/gui/main/style_stuff/styled_widgets/page_title.py@@ -1,7 +1,7 @@from PyQt6.QtCore import Qtfrom PyQt6.QtWidgets import QLabel-from src.gui.icis_conference_main.qt_utils.set_font_size import set_font_size+from src.gui.main.qt_utils.set_font_size import set_font_sizeclass PageTitle(QLabel):diff --git a/src/gui/main/style_stuff/styled_widgets/panel_section_title.py b/src/gui/main/style_stuff/styled_widgets/panel_section_title.pynew file mode 100644index 00000000..b3f91323--- /dev/null+++ b/src/gui/main/style_stuff/styled_widgets/panel_section_title.py@@ -0,0 +1,13 @@+from PyQt6.QtCore import Qt+from PyQt6.QtWidgets import QLabel++from src.gui.main.qt_utils.set_font_size import set_font_size+++class PanelSectionTitle(QLabel):+ def __init__(self, *args, **kwargs):+ super().__init__(*args, **kwargs)+ set_font_size(self, 12)+ self.setStyleSheet("weight: bold")+ self.setAlignment(Qt.AlignmentFlag.AlignCenter)+ # self.setStyleSheet("padding-bottom: 5px")diff --git a/src/gui/main/tool_tips/tool_tips_strings.py b/src/gui/main/tool_tips_and_warning_labels/tool_tips_strings.pysimilarity index 100%rename from src/gui/main/tool_tips/tool_tips_strings.pyrename to src/gui/main/tool_tips_and_warning_labels/tool_tips_strings.pydiff --git a/src/gui/main/workers/thread_worker_manager.py b/src/gui/main/workers/thread_worker_manager.pyindex 80d822b3..46396560 100644--- a/src/gui/main/workers/thread_worker_manager.py+++ b/src/gui/main/workers/thread_worker_manager.py@@ -46,6 +46,7 @@ class ThreadWorkerManager(QWidget):start_3d_processing_signal = pyqtSignal()start_post_processing_signal = pyqtSignal()start_convert_npy_to_to_csv_signal = pyqtSignal()+ start_session_data_visualization_signal = pyqtSignal()start_blender_processing_signal = pyqtSignal()blender_file_created_signal = pyqtSignal(str)@@ -182,10 +183,11 @@ class ThreadWorkerManager(QWidget):)self._post_process_3d_data_thread_worker.start()- logger.info("Emitting `convert_to_csv_signal`")- self._post_process_3d_data_thread_worker.finished.connect(- self.start_convert_npy_to_to_csv_signal.emit- )+ if auto_process_next_stage:+ logger.info("Emitting `convert_to_csv_signal`")+ self._post_process_3d_data_thread_worker.finished.connect(+ self.start_convert_npy_to_to_csv_signal.emit+ )def launch_convert_npy_to_csv_thread_worker(self,@@ -202,7 +204,11 @@ class ThreadWorkerManager(QWidget):self._convert_npy_to_csv_thread_worker.start()if auto_process_next_stage:- logger.info("Emitting `start_export_to_blender_signal`")+ logger.info("Emitting `start_session_data_visualization_signal`")+ self._convert_npy_to_csv_thread_worker.finished.connect(+ self.start_session_data_visualization_signal.emit+ )+ logger.info("Emitting `start_blender_processing_signal`")self._convert_npy_to_csv_thread_worker.finished.connect(self.start_blender_processing_signal.emit)