Free Motion Capture for Everyone πβ¨
TypeScript
Trent/better pipedream pings (#356)
trentwirth895726e5b612
diff --git a/freemocap/gui/qt/main_window/freemocap_main_window.py b/freemocap/gui/qt/main_window/freemocap_main_window.pyindex 31308641..41f2ec6e 100644--- a/freemocap/gui/qt/main_window/freemocap_main_window.py+++ b/freemocap/gui/qt/main_window/freemocap_main_window.py@@ -334,6 +334,8 @@ class FreemocapMainWindow(QMainWindow):logger.info(f"New active recording selected: {recording_info_model.path}")# self._calibration_control_panel.update_calibrate_from_active_recording_button_text()+ self._pipedream_pings.update_pings_dict(key=recording_info_model.name,+ value=self._active_recording_info_widget.active_recording_info.status_check)path = Path(recording_info_model.path)path.mkdir(parents=True, exist_ok=True)@@ -481,7 +483,8 @@ class FreemocapMainWindow(QMainWindow):logger.info("Main window `closeEvent` detected")self._pipedream_pings.update_pings_dict(key="gui_closed", value=True)- self._pipedream_pings.update_pings_dict(key="active recording status on close", value=self._active_recording_info_widget.active_recording_info.status_check)+ self._pipedream_pings.update_pings_dict(key="active recording status on close",+ value=self._active_recording_info_widget.active_recording_info.status_check)self._pipedream_pings.send_pipedream_ping()remove_empty_directories(get_recording_session_folder_path())diff --git a/freemocap/parameter_info_models/recording_info_model.py b/freemocap/parameter_info_models/recording_info_model.pyindex eababdb2..1238176c 100644--- a/freemocap/parameter_info_models/recording_info_model.py+++ b/freemocap/parameter_info_models/recording_info_model.py@@ -1,6 +1,9 @@import loggingfrom pathlib import Path-from typing import Union, Dict+from typing import Union, Dict, Any++import numpy as np+import tomlfrom freemocap.system.paths_and_files_names import (CENTER_OF_MASS_FOLDER_NAME,@@ -145,13 +148,19 @@ class RecordingFolderStatusChecker:self.recording_info_model = recording_info_model@property- def status_check(self) -> Dict[str, bool]:+ def status_check(self) -> Dict[str, Union[bool, str, float]]:return {'synchronized_videos_status_check': self.check_synchronized_videos_status(),'data2d_status_check': self.check_data2d_status(),'data3d_status_check': self.check_data3d_status(),'center_of_mass_data_status_check': self.check_center_of_mass_data_status(),- 'blender_file_status_check': self.check_blender_file_status(), }+ 'blender_file_status_check': self.check_blender_file_status(),+ 'video_and_camera_info': {+ 'number_of_synchronized_videos': self.get_number_of_mp4s_in_synched_videos_directory(),+ 'number_of_frames_in_videos': self.get_number_of_frames_in_videos(),+ # 'camera_rotation_and_translation': self.get_camera_rotation_and_translation_from_calibration_toml()+ }+ }def check_synchronized_videos_status(self) -> bool:try:@@ -199,3 +208,50 @@ class RecordingFolderStatusChecker:def check_calibration_toml_status(self) -> bool:return Path(self.recording_info_model.calibration_toml_path).is_file()++ def get_number_of_mp4s_in_synched_videos_directory(self) -> float:+ synchronized_directory_path = Path(self.recording_info_model.synchronized_videos_folder_path)+ video_count = 0.0++ for file in synchronized_directory_path.iterdir():+ if file.is_file() and file.suffix.lower() == '.mp4':+ video_count += 1++ logger.info(f"Number of `.mp4`'s in {self.recording_info_model.synchronized_videos_folder_path}: {video_count}")+ return video_count++ def get_number_of_frames_in_videos(self):+ timestamps_directory_path = Path(self.recording_info_model.synchronized_videos_folder_path) / "timestamps"++ if timestamps_directory_path.exists() and timestamps_directory_path.is_dir():+ frame_counts = {}++ for npy_file in timestamps_directory_path.iterdir():+ if npy_file.is_file() and npy_file.suffix.lower() == '.npy':+ video_npy = np.load(str(npy_file))+ frame_counts[npy_file.name] = str(len(video_npy)-1)++ return frame_counts+ else:+ return "No 'timestamps' directory found"++ # def get_camera_rotation_and_translation_from_calibration_toml(self):+ # calibration_toml_path = Path(self.recording_info_model.calibration_toml_path)+ #+ # logger.info(f"Looking for calibration file at {calibration_toml_path}")+ #+ # if calibration_toml_path.exists() and calibration_toml_path.is_file():+ # calibration_data = toml.load(str(calibration_toml_path))+ #+ # camera_data = {}+ #+ # for cam_key, cam_values in calibration_data.items():+ # if cam_key.startswith("cam_"):+ # camera_data[cam_key] = {+ # 'rotation': cam_values['rotation'],+ # 'translation': cam_values['translation']+ # }+ #+ # return camera_data+ # else:+ # return "No 'calibration.toml' file found"