Skip to content

Commit

Permalink
Merge pull request #558 from mprib/557-main-gui-loads-post-processing…
Browse files Browse the repository at this point in the history
…-tab-if-recordings-available

check if recordings exist
  • Loading branch information
mprib authored Dec 4, 2023
2 parents d42c0fc + 5fb7bf0 commit 6106514
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pyxy3d/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ def all_extrinsics_estimated(self)->bool:
point_estimates_good = self.config.point_estimates_toml_path.exists()
return cameras_good and point_estimates_good

def recordings_available(self)->bool:
"""
Checks if for each camera_data object in the camera_array, there is a corresponding
'port_#.mp4' file in any of the subfolders of the recording directory.
Returns:
bool: True if all required recordings are available, False otherwise.
"""

# Iterate over each CameraData in the camera array
for port, camera_data in self.camera_array.cameras.items():
file_name = f"port_{port}.mp4"
file_found = False

# Check each subfolder in the recording directory
for subfolder in self.recording_dir.iterdir():
if subfolder.is_dir(): # Make sure it's a directory
# Check if the required file exists in this subfolder
expected_file_path = subfolder / file_name
if expected_file_path.exists():
file_found = True
break

# If the file was not found for this camera, return False
if not file_found:
return False

# All required files were found
return True

def get_charuco_params(self) -> dict:
return self.config.dict["charuco"]

Expand Down
12 changes: 12 additions & 0 deletions pyxy3d/gui/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from pyxy3d.gui.vizualize.calibration.capture_volume_widget import CaptureVolumeWidget
from pyxy3d.gui.workspace_widget import WorkspaceSummaryWidget
from pyxy3d.gui.camera_management.multiplayback_widget import MultiIntrinsicPlaybackWidget
from pyxy3d.gui.post_processing_widget import PostProcessingWidget
from pyxy3d.controller import Controller

logger = pyxy3d.logger.get(__name__)
Expand Down Expand Up @@ -119,6 +120,17 @@ def build_central_tabs(self):
capture_volume_enabled = False
self.central_tab.addTab(self.capture_volume_widget, "Capture Volume")
self.central_tab.setTabEnabled(self.find_tab_index_by_title("Capture Volume"),capture_volume_enabled)


logger.info("About to load post-processing tab")
if self.controller.recordings_available():
self.post_processing_widget = PostProcessingWidget(self.controller)
post_processing_enabled = True
else:
self.post_processing_widget = QWidget()
post_processing_enabled = False
self.central_tab.addTab(self.post_processing_widget, "Post Processing")
self.central_tab.setTabEnabled(self.find_tab_index_by_title("Post Processing"),post_processing_enabled)

def build_docked_logger(self):
# create log window which is fixed below main window
Expand Down

0 comments on commit 6106514

Please sign in to comment.