summaryrefslogtreecommitdiff
path: root/src/qcam/main_window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qcam/main_window.cpp')
-rw-r--r--src/qcam/main_window.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index d6136910..b2f3a1f3 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -28,6 +28,7 @@ MainWindow::MainWindow(const OptionsParser::Options &options)
title_ = "QCam " + QString::fromStdString(libcamera::version);
setWindowTitle(title_);
+ connect(&titleTimer_, SIGNAL(timeout()), this, SLOT(updateTitle()));
viewfinder_ = new ViewFinder(this);
setCentralWidget(viewfinder_);
@@ -54,6 +55,19 @@ MainWindow::~MainWindow()
CameraManager::instance()->stop();
}
+void MainWindow::updateTitle()
+{
+ unsigned int duration = frameRateInterval_.elapsed();
+ unsigned int frames = framesCaptured_ - previousFrames_;
+ double fps = frames * 1000.0 / duration;
+
+ /* Restart counters. */
+ frameRateInterval_.start();
+ previousFrames_ = framesCaptured_;
+
+ setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps");
+}
+
int MainWindow::openCamera()
{
CameraManager *cm = CameraManager::instance();
@@ -148,6 +162,10 @@ int MainWindow::startCapture()
requests.push_back(request);
}
+ titleTimer_.start(2000);
+ frameRateInterval_.start();
+ previousFrames_ = 0;
+ framesCaptured_ = 0;
lastBufferTime_ = 0;
ret = camera_->start();
@@ -188,6 +206,9 @@ void MainWindow::stopCapture()
isCapturing_ = false;
config_.reset();
+
+ titleTimer_.stop();
+ setWindowTitle(title_);
}
void MainWindow::requestComplete(Request *request,
@@ -196,6 +217,8 @@ void MainWindow::requestComplete(Request *request,
if (request->status() == Request::RequestCancelled)
return;
+ framesCaptured_++;
+
Buffer *buffer = buffers.begin()->second;
double fps = buffer->timestamp() - lastBufferTime_;