Skip to content

Commit

Permalink
add perf_counter widget for accuracy check
Browse files Browse the repository at this point in the history
  • Loading branch information
mprib committed Feb 13, 2024
1 parent a849952 commit e2c3324
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 4 additions & 4 deletions multiwebcam/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 8 additions & 1 deletion multiwebcam/gui/main_widget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import multiwebcam.logger
from pathlib import Path


import subprocess
import os
from threading import Thread
Expand All @@ -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__)
Expand Down Expand Up @@ -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()

Expand Down
47 changes: 47 additions & 0 deletions multiwebcam/gui/perf_counter_widget.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit e2c3324

Please sign in to comment.