From patchwork Tue Jul 2 11:48:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1584 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 13E9061F67 for ; Tue, 2 Jul 2019 13:48:50 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A876F524; Tue, 2 Jul 2019 13:48:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562068129; bh=lK8GD458CQXK9G4Kv7p20o6wxLv1mGNibXiiEc3regY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CfGogUh+cREQCpwKKiRnRNGQ9Y+80jC3RQ52FZttgKBpaZSFOzkq0AY+eAVK+MY2F lilQ9DsMO2pf2LrBrphVDprUOMbawlGYyAjMvnPjHbJsGoDRNZi+ueXnf18kMuBXdg BYqckHpF1pFhkef1urummu5luA7KlPMXzKvAP+xs= From: Kieran Bingham To: LibCamera Devel Date: Tue, 2 Jul 2019 12:48:41 +0100 Message-Id: <20190702114841.19101-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702114841.19101-1-kieran.bingham@ideasonboard.com> References: <20190702114841.19101-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] qcam: Update window title with FPS X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2019 11:48:50 -0000 Provide an average FPS in the QCam title bar to show the current rate of frame processing. Signed-off-by: Kieran Bingham --- src/qcam/main_window.cpp | 23 ++++++++++++++++++++--- src/qcam/main_window.h | 4 +++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 61d7aa9469f0..c093bd0c809e 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -26,7 +26,7 @@ MainWindow::MainWindow(const OptionsParser::Options &options) { int ret; - setWindowTitle(); + setWindowTitle(""); viewfinder_ = new ViewFinder(this); setCentralWidget(viewfinder_); viewfinder_->setFixedSize(500, 500); @@ -52,10 +52,11 @@ MainWindow::~MainWindow() CameraManager::instance()->stop(); } -void MainWindow::setWindowTitle() +void MainWindow::setWindowTitle(QString fps) { QMainWindow::setWindowTitle("QCam : " - + QString::fromStdString(libcamera::version.toString())); + + QString::fromStdString(libcamera::version.toString()) + + " (" + fps + ")"); } int MainWindow::openCamera() @@ -152,6 +153,9 @@ int MainWindow::startCapture() requests.push_back(request); } + firstFrameTime = 0; + framesCaptured = 0; + ret = camera_->start(); if (ret) { std::cout << "Failed to start capture" << std::endl; @@ -215,6 +219,19 @@ void MainWindow::requestComplete(Request *request, display(buffer); + if (firstFrameTime == 0) + firstFrameTime = buffer->timestamp(); + + uint64_t duration = buffer->timestamp() - firstFrameTime; + if (duration) + fps = framesCaptured * 1000000000.0 / duration; + else + fps = 0.0; + + setWindowTitle(QString::number(fps, 'f', 2) + " fps"); + + framesCaptured++; + request = camera_->createRequest(); if (!request) { std::cerr << "Can't create request" << std::endl; diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index b30a86768efc..792f89c2d831 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -33,7 +33,7 @@ public: ~MainWindow(); private: - void setWindowTitle(); + void setWindowTitle(QString info); int openCamera(); @@ -49,6 +49,8 @@ private: std::shared_ptr camera_; bool isCapturing_; std::unique_ptr config_; + uint64_t firstFrameTime; + uint32_t framesCaptured; ViewFinder *viewfinder_; };