Free Motion Capture for Everyone πβ¨
TypeScript
Cleanup groundplane UI (#735)
philipqueen10b2a69ec8c7
diff --git a/freemocap/gui/qt/freemocap_main.py b/freemocap/gui/qt/freemocap_main.pyindex a9f938d4..eb72258b 100644--- a/freemocap/gui/qt/freemocap_main.py+++ b/freemocap/gui/qt/freemocap_main.py@@ -59,7 +59,7 @@ def qt_gui_main():sys.exit()-def handle_pop_ups(freemocap_main_window):+def handle_pop_ups(freemocap_main_window: MainWindow):if freemocap_main_window._gui_state.show_welcome_screen:freemocap_main_window.open_welcome_screen_dialog()diff --git a/freemocap/gui/qt/main_window/freemocap_main_window.py b/freemocap/gui/qt/main_window/freemocap_main_window.pyindex 2ca0e89e..56bc1533 100644--- a/freemocap/gui/qt/main_window/freemocap_main_window.py+++ b/freemocap/gui/qt/main_window/freemocap_main_window.py@@ -68,6 +68,7 @@ from freemocap.gui.qt.widgets.set_data_folder_dialog import SetDataFolderDialogfrom freemocap.gui.qt.widgets.welcome_screen_dialog import WelcomeScreenDialogfrom freemocap.gui.qt.workers.download_sample_data_thread_worker import DownloadDataThreadWorkerfrom freemocap.gui.qt.workers.export_to_blender_thread_worker import ExportToBlenderThreadWorker+# reboot GUI method based on this - https://stackoverflow.com/a/56563926/14662833from freemocap.system.open_file import open_filefrom freemocap.system.paths_and_filenames.file_and_folder_names import (@@ -91,10 +92,10 @@ logger = logging.getLogger(__name__)class MainWindow(QMainWindow):def __init__(- self,- freemocap_data_folder_path: Union[str, Path],- pipedream_pings: PipedreamPings,- parent=None,+ self,+ freemocap_data_folder_path: Union[str, Path],+ pipedream_pings: PipedreamPings,+ parent=None,):super().__init__(parent=parent)self._log_view_widget = LogViewWidget(parent=self) # start this first so it will grab the setup logs@@ -146,6 +147,8 @@ class MainWindow(QMainWindow):self._control_panel_widget = self._create_control_panel_widget(log_update=self._log_view_widget.add_log)self._tools_dock_widget.setWidget(self._control_panel_widget)+ self._connect_calibration_updates()+log_view_dock_widget = QDockWidget("Log View", self)self.addDockWidget(Qt.DockWidgetArea.BottomDockWidgetArea, log_view_dock_widget)log_view_dock_widget.setWidget(self._log_view_widget)@@ -168,8 +171,8 @@ class MainWindow(QMainWindow):self._active_recording_info_widget.set_active_recording(recording_folder_path=folder_path)if (- self._controller_group_box.auto_process_videos_checked- and self._controller_group_box.mocap_videos_radio_button_checked+ self._controller_group_box.auto_process_videos_checked+ and self._controller_group_box.mocap_videos_radio_button_checked):logger.info("'Auto process videos' checkbox is checked - triggering 'Process Motion Capture Data' button")self._process_motion_capture_data_panel.process_motion_capture_data_button.click()@@ -357,7 +360,7 @@ class MainWindow(QMainWindow):try:self._process_motion_capture_data_panel.update_calibration_path()except (- AttributeError+ AttributeError): # Active Recording and Data Panel widgets rely on each other, so we're guaranteed to hit this every time the app openslogger.debug("Process motion capture data panel not created yet, skipping claibraiton setting")except Exception as e:@@ -482,7 +485,7 @@ class MainWindow(QMainWindow):dialog = TabbedReleaseNotesDialog(kill_thread_event=threading.Event(),gui_state=self._gui_state,- dark_mode=True # Set to True for dark mode, False for light mode+ dark_mode=True, # Set to True for dark mode, False for light mode)dialog.exec()@@ -525,12 +528,12 @@ class MainWindow(QMainWindow):if not synchronization_bool:for video_path in tqdm(- video_paths,- desc="Importing videos...",- colour=[255, 128, 0],- unit="video",- unit_scale=True,- leave=False,+ video_paths,+ desc="Importing videos...",+ colour=[255, 128, 0],+ unit="video",+ unit_scale=True,+ leave=False,):if not Path(video_path).exists():logger.error(f"{video_path} does not exist!")@@ -554,6 +557,14 @@ class MainWindow(QMainWindow):recording_folder_path=Path(folder_to_save_videos).parent)+ def _connect_calibration_updates(self):+ self._process_motion_capture_data_panel._calibration_control_panel.control_panel_calibration_updated.connect(+ self._controller_group_box.charuco_option_updated+ )+ self._controller_group_box.controller_group_box_calibration_updated.connect(+ self._process_motion_capture_data_panel._calibration_control_panel.charuco_option_updated+ )+def reboot_gui(self):logger.info("Rebooting GUI... ")get_qt_app().exit(EXIT_CODE_REBOOT)diff --git a/freemocap/gui/qt/style_sheet/qt_style_sheet.scss b/freemocap/gui/qt/style_sheet/qt_style_sheet.scssindex 3f4b7f93..f5a3ef86 100644--- a/freemocap/gui/qt/style_sheet/qt_style_sheet.scss+++ b/freemocap/gui/qt/style_sheet/qt_style_sheet.scss@@ -106,10 +106,6 @@ QPushButton:pressed {background-color: darken($secondary-button, 20%);}-QPushButton:pressed {- background-color: darken($secondary-button, 20%);-}-QPushButton#start_recording_button {font-size: 16px;background-color: $recording-button-red;diff --git a/freemocap/gui/qt/widgets/camera_controller_group_box.py b/freemocap/gui/qt/widgets/camera_controller_group_box.pyindex ba310436..be2dfab9 100644--- a/freemocap/gui/qt/widgets/camera_controller_group_box.py+++ b/freemocap/gui/qt/widgets/camera_controller_group_box.py@@ -1,7 +1,7 @@import loggingfrom pathlib import Path-from PySide6.QtCore import Qt+from PySide6.QtCore import Qt, Signal, Slotfrom PySide6.QtWidgets import (QGroupBox,QVBoxLayout,@@ -15,7 +15,7 @@ from PySide6.QtWidgets import ()from skellycam import SkellyCamControllerWidget, SkellyCamWidget-from freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, save_gui_state+from freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, load_gui_state, save_gui_statefrom freemocap.system.paths_and_filenames.file_and_folder_names import SPARKLES_EMOJI_STRING, SKULL_EMOJI_STRINGfrom freemocap.system.paths_and_filenames.path_getters import (create_new_recording_folder_path,@@ -31,6 +31,8 @@ logger = logging.getLogger(__name__)class CameraControllerGroupBox(QGroupBox):+ controller_group_box_calibration_updated = Signal()+def __init__(self, skellycam_widget: SkellyCamWidget, gui_state: GuiState, parent=None):super().__init__(parent=parent)self.setStyleSheet("font-size: 12px;")@@ -61,7 +63,7 @@ class CameraControllerGroupBox(QGroupBox):self._auto_process_videos_checkbox.toggled.connect(self._on_auto_process_videos_checkbox_changed)self._generate_jupyter_notebook_checkbox.toggled.connect(self._on_generate_jupyter_notebook_checkbox_changed)self._auto_open_in_blender_checkbox.toggled.connect(self._on_auto_open_in_blender_checkbox_changed)- self._charuco_square_size_line_edit.textChanged.connect(self._on_charuco_square_size_line_edit_changed)+ self._charuco_square_size_line_edit.textEdited.connect(self._on_charuco_square_size_line_edit_changed)self._use_charuco_as_groundplane_checkbox.toggled.connect(self._on_use_charuco_groundplane_checkbox_changed)self._board_dropdown.currentTextChanged.connect(self._on_charuco_board_dropdown_changed)@@ -157,12 +159,14 @@ class CameraControllerGroupBox(QGroupBox):hbox_bottom = QHBoxLayout()hbox_bottom.setAlignment(Qt.AlignmentFlag.AlignLeft)- self._annotate_charuco_checkbox = QCheckBox("Display Charuco Overlay")+ self._annotate_charuco_checkbox = QCheckBox("Charuco Overlay (requires camera restart)")self._annotate_charuco_checkbox.setChecked(self.gui_state.annotate_charuco_images)self._skellycam_widget.annotate_images = self._annotate_charuco_checkbox.isChecked()hbox_bottom.addWidget(self._annotate_charuco_checkbox)- self._use_charuco_as_groundplane_checkbox = QCheckBox("Use Charuco as groundplane")+ self._use_charuco_as_groundplane_checkbox = QCheckBox(+ "Use initial board position as origin"+ )self._use_charuco_as_groundplane_checkbox.setChecked(self.gui_state.use_charuco_as_groundplane)hbox_bottom.addWidget(self._use_charuco_as_groundplane_checkbox)@@ -302,10 +306,21 @@ class CameraControllerGroupBox(QGroupBox):save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())def _on_charuco_square_size_line_edit_changed(self):- self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())+ try:+ self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())+ except ValueError:+ returnsave_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())+ self.controller_group_box_calibration_updated.emit()def _on_charuco_board_dropdown_changed(self):selected_board_name = self._board_dropdown.currentText()self.gui_state.charuco_board_name = selected_board_namesave_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())+ self.controller_group_box_calibration_updated.emit()++ @Slot()+ def charuco_option_updated(self):+ self.gui_state = load_gui_state(file_pathstring=get_gui_state_json_path())+ self._board_dropdown.setCurrentText(self.gui_state.charuco_board_name)+ self._charuco_square_size_line_edit.setText(str(self.gui_state.charuco_square_size))diff --git a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.pyindex 04609f75..935e04bf 100644--- a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py+++ b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py@@ -4,7 +4,7 @@ import threadingfrom pathlib import Pathfrom typing import Callable, Optional, Union-from PySide6.QtCore import Qt, Slot, QObject+from PySide6.QtCore import Qt, Slot, Signal, QObjectfrom PySide6.QtGui import QDoubleValidatorfrom PySide6.QtWidgets import (QFileDialog,@@ -22,7 +22,7 @@ from PySide6.QtWidgets import ()from freemocap.data_layer.recording_models.recording_info_model import RecordingInfoModel-from freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, save_gui_state+from freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, load_gui_state, save_gui_statefrom freemocap.gui.qt.workers.anipose_calibration_thread_worker import (AniposeCalibrationThreadWorker,)@@ -38,6 +38,8 @@ logger = logging.getLogger(__name__)class CalibrationControlPanel(QWidget):+ control_panel_calibration_updated = Signal()+def __init__(self,get_active_recording_info: Callable[..., Union[RecordingInfoModel, Path]],@@ -71,7 +73,7 @@ class CalibrationControlPanel(QWidget):self._radio_button_layout = self._create_radio_button_layout()self._radio_button_layout.setAlignment(Qt.AlignmentFlag.AlignTop)self._layout.addLayout(self._radio_button_layout)- self._layout.addStretch()+ # self._layout.addStretch()@propertydef calibration_toml_path(self) -> str:@@ -90,6 +92,8 @@ class CalibrationControlPanel(QWidget):radio_button_form_layout.addRow(self._add_calibrate_from_active_recording_radio_button())+ radio_button_form_layout.addRow(self._create_charuco_options_layout())+self.update_calibration_toml_path()return radio_button_form_layout@@ -153,9 +157,7 @@ class CalibrationControlPanel(QWidget):failure_dialog.exec()def _add_calibrate_from_active_recording_radio_button(self):- vbox = QVBoxLayout()hbox = QHBoxLayout()- vbox.addLayout(hbox)self._calibrate_from_active_recording_radio_button = QRadioButton("Calibrate from Active Recording")hbox.addWidget(self._calibrate_from_active_recording_radio_button)@@ -170,38 +172,52 @@ class CalibrationControlPanel(QWidget):self._calibrate_from_active_recording_button.setEnabled(False)self._calibrate_from_active_recording_button.clicked.connect(self.calibrate_from_active_recording)- # Create existing form layout+ return hbox++ def _create_charuco_options_layout(self):+ vbox = QVBoxLayout()++ hbox1 = QHBoxLayout()+ hbox1.setAlignment(Qt.AlignmentFlag.AlignLeft)++ # Square size form layoutself._charuco_square_size_form_layout = self._create_charuco_square_size_form_layout()+ hbox1.addLayout(self._charuco_square_size_form_layout)++ hbox1.addSpacing(8)++ # Board dropdown + label+ self._board_dropdown_label = QLabel("Charuco Board:")+ self._board_dropdown_label.setStyleSheet("QLabel { font-size: 12px; }")+ self._board_dropdown_label.setEnabled(False)+ self._board_dropdown = self._create_board_dropdown()+ self._board_dropdown.currentTextChanged.connect(self._on_charuco_board_dropdown_changed)+ hbox1.addWidget(self._board_dropdown_label)+ hbox1.addWidget(self._board_dropdown)- # Create a horizontal layout to hold both form and checkbox+ vbox.addLayout(hbox1)++ # Groundplane checkbox rowhbox2 = QHBoxLayout()hbox2.setAlignment(Qt.AlignmentFlag.AlignLeft)- hbox2.addLayout(self._charuco_square_size_form_layout)- # Create checkbox- self._use_charuco_as_groundplane_checkbox = QCheckBox("Use Charuco board as groundplane")+ self._use_charuco_as_groundplane_checkbox = QCheckBox(+ "Use initial Charuco board position as groundplane origin"+ )+ self._use_charuco_as_groundplane_checkbox.setStyleSheet("QCheckBox { font-size: 12px; }")self._use_charuco_as_groundplane_checkbox.setToolTip("Set the Charuco board's coordinate system as the global origin")self._use_charuco_as_groundplane_checkbox.setChecked(False)self._use_charuco_as_groundplane_checkbox.setEnabled(False)+ self._use_charuco_as_groundplane_checkbox.setVisible(False)- hbox2.addSpacing(10)hbox2.addWidget(self._use_charuco_as_groundplane_checkbox)vbox.addLayout(hbox2)- hbox3 = QHBoxLayout()- hbox3.setAlignment(Qt.AlignmentFlag.AlignLeft)-- self._board_dropdown_label = QLabel("Charuco Board:")- self._board_dropdown_label.setStyleSheet("QLabel { font-size: 12px; }")- self._board_dropdown_label.setEnabled(False)- self._board_dropdown = self._create_board_dropdown()- hbox3.addWidget(self._board_dropdown_label)- hbox3.addWidget(self._board_dropdown)- vbox.addLayout(hbox3)-+ # Hide by defaultself._set_charuco_square_size_form_layout_visibility(False)+ self._set_charuco_board_dropdown_visibility(False)return vbox@@ -229,11 +245,6 @@ class CalibrationControlPanel(QWidget):self._calibrate_from_active_recording_button.setToolTip(active_path_str)def _handle_use_most_recent_calibration_toggled(self, checked):- pass- # if checked:- # self._most_recent_calibration_path_label.show()- # else:- # self._most_recent_calibration_path_label.hide()self.update_calibration_toml_path()def _handle_load_calibration_from_file_toggled(self, checked):@@ -253,11 +264,13 @@ class CalibrationControlPanel(QWidget):self._calibrate_from_active_recording_button.setEnabled(True)self._set_charuco_square_size_form_layout_visibility(True)self._use_charuco_as_groundplane_checkbox.setEnabled(True)+ self._use_charuco_as_groundplane_checkbox.setVisible(True)self._set_charuco_board_dropdown_visibility(True)else:self._calibrate_from_active_recording_button.setEnabled(False)self._set_charuco_square_size_form_layout_visibility(False)self._use_charuco_as_groundplane_checkbox.setEnabled(False)+ self._use_charuco_as_groundplane_checkbox.setVisible(False)self._set_charuco_board_dropdown_visibility(False)def _set_charuco_square_size_form_layout_visibility(self, visible):@@ -266,13 +279,19 @@ class CalibrationControlPanel(QWidget):if visible:self._charuco_square_size_form_layout.itemAt(label_index).widget().setEnabled(True)self._charuco_square_size_form_layout.itemAt(line_edit_index).widget().setEnabled(True)+ self._charuco_square_size_form_layout.itemAt(label_index).widget().setVisible(True)+ self._charuco_square_size_form_layout.itemAt(line_edit_index).widget().setVisible(True)else:self._charuco_square_size_form_layout.itemAt(label_index).widget().setEnabled(False)self._charuco_square_size_form_layout.itemAt(line_edit_index).widget().setEnabled(False)+ self._charuco_square_size_form_layout.itemAt(label_index).widget().setVisible(False)+ self._charuco_square_size_form_layout.itemAt(line_edit_index).widget().setVisible(False)def _set_charuco_board_dropdown_visibility(self, visible: bool):self._board_dropdown.setEnabled(visible)self._board_dropdown_label.setEnabled(visible)+ self._board_dropdown.setVisible(visible)+ self._board_dropdown_label.setVisible(visible)def open_load_camera_calibration_toml_dialog(self) -> str:# from this tutorial - https://www.youtube.com/watch?v=gg5TepTc2Jg&t=649s@@ -303,7 +322,7 @@ class CalibrationControlPanel(QWidget):self._charuco_square_size_line_edit = QLineEdit()self._charuco_square_size_line_edit.setValidator(QDoubleValidator())- self._charuco_square_size_line_edit.setFixedWidth(80)+ self._charuco_square_size_line_edit.setFixedWidth(65)self._charuco_square_size_label = QLabel("Charuco square size (mm)")self._charuco_square_size_label.setStyleSheet("QLabel { font-size: 12px; }")@@ -312,7 +331,7 @@ class CalibrationControlPanel(QWidget):self._charuco_square_size_line_edit.setToolTip("The length of one of the edges of the black squares in the calibration board in mm")- self._charuco_square_size_line_edit.textChanged.connect(self._on_charuco_square_size_line_edit_changed)+ self._charuco_square_size_line_edit.textEdited.connect(self._on_charuco_square_size_line_edit_changed)charuco_square_size_form_layout.addRow(self._charuco_square_size_label, self._charuco_square_size_line_edit)charuco_square_size_form_layout.setAlignment(Qt.AlignmentFlag.AlignRight)return charuco_square_size_form_layout@@ -320,7 +339,7 @@ class CalibrationControlPanel(QWidget):def _create_board_dropdown(self) -> QComboBox:board_dropdown = QComboBox()board_dropdown.setToolTip("Select the Charuco board to use for calibration")- board_dropdown.setFixedWidth(150)+ board_dropdown.setFixedWidth(130)board_dropdown.setStyleSheet("QComboBox { font-size: 12px; }")board_dropdown.setEnabled(False)board_dropdown.setEditable(False)@@ -328,8 +347,24 @@ class CalibrationControlPanel(QWidget):return board_dropdowndef _on_charuco_square_size_line_edit_changed(self):- self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())+ try:+ self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())+ except ValueError:+ return+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())+ self.control_panel_calibration_updated.emit()++ def _on_charuco_board_dropdown_changed(self):+ selected_board_name = self._board_dropdown.currentText()+ self.gui_state.charuco_board_name = selected_board_namesave_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())+ self.control_panel_calibration_updated.emit()++ @Slot()+ def charuco_option_updated(self):+ self.gui_state = load_gui_state(file_pathstring=get_gui_state_json_path())+ self._board_dropdown.setCurrentText(self.gui_state.charuco_board_name)+ self._charuco_square_size_line_edit.setText(str(self.gui_state.charuco_square_size))@Slot(str)def _log_calibration_progress_callbacks(self, message: str):