diff --git a/README.md b/README.md index f0008d6..60f82e0 100644 --- a/README.md +++ b/README.md @@ -88,3 +88,13 @@ Once you've launched MultiWebCam, choose a new project directory through the Fil MWC will attempt to connect to the cameras currently and will create a `recording_config.toml` file in the project directory. From the `Mode` menu you can select single camera to change camera settings (such as resolution and exposure). On the MultCamera mode you can set the target fps to achieve a desired dropped frame rate and record batches of videos. + +## Checking Against System Clock + +To provide a check of the accuracy of the time stamps, you can launch a widget that displays the `perf_counter` from the system by running from the command line: + +``` +mwc clock +``` + +Cross checking the frames with the recorded time stamp value can provide a sense of the temporal accuracy of the recording. \ No newline at end of file diff --git a/multiwebcam/__main__.py b/multiwebcam/__main__.py index e598186..06e466e 100644 --- a/multiwebcam/__main__.py +++ b/multiwebcam/__main__.py @@ -11,10 +11,10 @@ def CLI_parser(): if len(sys.argv) == 1: - launch_main() + launch_main(show_clock=False) if len(sys.argv) == 2: - launch_widget = sys.argv[1] + modifiers = sys.argv[1] - if launch_widget in ["record", "rec", "-r"]: - pass + if modifiers in ["clock", "-c"]: + launch_main(show_clock=True) diff --git a/multiwebcam/gui/main_widget.py b/multiwebcam/gui/main_widget.py index cc6f8b2..291d294 100644 --- a/multiwebcam/gui/main_widget.py +++ b/multiwebcam/gui/main_widget.py @@ -1,6 +1,7 @@ import multiwebcam.logger from pathlib import Path + import subprocess import os from threading import Thread @@ -23,6 +24,7 @@ from multiwebcam.gui.single_camera_widget import ( SingleCameraWidget, ) +from multiwebcam.gui.perf_counter_widget import PerfCounterWidget from multiwebcam.gui.multicamera_widget import MultiCameraWidget logger = multiwebcam.logger.get(__name__) @@ -250,12 +252,17 @@ def update_app_settings(self): rtoml.dump(self.app_settings, f) -def launch_main(): +def launch_main(show_clock=False): # import qdarktheme app = QApplication(sys.argv) # qdarktheme.setup_theme("auto") window = MainWindow() + + if show_clock: + widget = PerfCounterWidget() + widget.show() + window.show() app.exec() diff --git a/multiwebcam/gui/perf_counter_widget.py b/multiwebcam/gui/perf_counter_widget.py new file mode 100644 index 0000000..67a3b0f --- /dev/null +++ b/multiwebcam/gui/perf_counter_widget.py @@ -0,0 +1,47 @@ +import sys +from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel +from PySide6.QtCore import QTimer +from PySide6.QtGui import QFont +import time + +class PerfCounterWidget(QWidget): + def __init__(self): + super().__init__() + + # Set up the layout + self.layout = QVBoxLayout() + self.perfLabel = QLabel(self) + + font = QFont() + font.setPointSize(100) + self.perfLabel.setFont(font) + + self.layout.addWidget(self.perfLabel) + self.setLayout(self.layout) + + + + # Timer to update the label every 100 milliseconds for smoother updates + self.timer = QTimer(self) + self.timer.timeout.connect(self.updateLabel) + self.timer.start(10) # Update interval in milliseconds + + + def updateLabel(self): + # Calculate elapsed time since the start of the application + elapsedTime = time.perf_counter() + # Update the label with the current perf_counter value + self.perfLabel.setText(f"{elapsedTime:.4f}") + + + +def main(): + app = QApplication(sys.argv) + widget = PerfCounterWidget() + widget.show() + sys.exit(app.exec_()) + +if __name__ == "__main__": + + main() +