From patchwork Thu Jul 4 13:03: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: 1606 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 C628861569 for ; Thu, 4 Jul 2019 15:03:52 +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 68DCA24B; Thu, 4 Jul 2019 15:03:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562245432; bh=lK8GD458CQXK9G4Kv7p20o6wxLv1mGNibXiiEc3regY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNbSQM2t/8Ft1+A/qCAdDUo16xfq4Lv6eL7R6asCdFQyYl1+eYUCNOH04Sl1Pp8e3 YHtro6hW1dK7V8upzvvHHba9kXSh4l/PYWy6IVXd+NCHr876GbXJsUvLLRo4MQK7Km xHE2J7/I5H1DndVTm4zzeRCtTeNYs1ayYQvNoLfg= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 14:03:41 +0100 Message-Id: <20190704130347.9372-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704130347.9372-1-kieran.bingham@ideasonboard.com> References: <20190704130347.9372-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: Thu, 04 Jul 2019 13:03:52 -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_; };