From patchwork Thu Jul 4 14:59:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1614 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BCBD6156A for ; Thu, 4 Jul 2019 16:59:46 +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 0E9182AF; Thu, 4 Jul 2019 16:59:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562252386; bh=E1dDyxS1kb60RBPGCuJSImrNS/XhBKNg22uLyjcxOA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lf+2x0yRcV2KXC7SVl5Qo5I8CTG9gYGAiqLhtKwp+7Wia+h+ZBdUATCvoFGRuEz93 Z4mjDPRtsIxc0czqJy13ZCeuCYiiDtW+xEKK2w4aLM+4/Jbgf44Wf/pacxy4d4aWWv Tr8rX5T5Rid1CKzGSKadjEVE+IqJU2B3TU6130Ig= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 15:59:37 +0100 Message-Id: <20190704145942.17879-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> References: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/6] Documentation: Make the project brief more expressive 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 14:59:46 -0000 The current project brief lacks any quotation marks, and causes the Doxygen API documents to show the header "libcameraframework". Replace the simplistic definition with a better brief, and ensure quotation marks are provided to maintain spacing. Fixes: 53c4d4c34fc4 ("Documentation: Generate source code documentation using Doxygen") Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Documentation/Doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in index 9ca32241b895..cad85ff979f8 100644 --- a/Documentation/Doxyfile.in +++ b/Documentation/Doxyfile.in @@ -44,7 +44,7 @@ PROJECT_NUMBER = @VERSION@ # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = libcamera framework +PROJECT_BRIEF = "Supporting cameras in Linux since 2019" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 From patchwork Thu Jul 4 14:59:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1615 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 B44B761570 for ; Thu, 4 Jul 2019 16:59:46 +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 5EF57E21; Thu, 4 Jul 2019 16:59:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562252386; bh=VGqz/AzG41DuC2n0LebX3Xhl3EN3sVPDX8EOHeVAVdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=otxkXsHNvTmEZ/9jLqPp/smnYOuBal2PCCEtFFU47acAkVVXGUJOWhGz4dQ6lgGnM yHEX2S92CS81tXkdW4sqlvR1Nu846aPQ93iqqQSWlRIFUDEaa0Z901qKBx8sMlGiKP aHwO9RBM/B5/xCb6vhpR3w9HLiGVLl0iAh09SVoo= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 15:59:38 +0100 Message-Id: <20190704145942.17879-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> References: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/6] libcamera: Auto generate version information 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 14:59:46 -0000 Generate a version string, and provide a global singleton object which allows applications to interrogate the current libcamera version information. The version header is automatically updated by meson on each build. The string roughly follows the semver [0] conventions of major.minor.patch-label as a value. [0] https://semver.org/ A script (utils/gen-version.sh) is provided which is modelled upon the processing from autoconf's git-version-gen. The gen-version.sh script will look for tags in the form vX.Y as starting points for the version string. While the repository does not have any matching tags, v0.0 will be assumed, resulting in versions with both major and minor being set to '0', and the patch count resulting from the number of patches in the history to that point. Finally, a uniquely identifying shortened hash is provided from git: v0.0.509+0ec0edf7 Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v2: - Store VCS_Tag return reference for dependancy linking - Fix indentation on meson.build - fix shell usage and shellcheck warnings in version-gen - Make LibcameraVersion version global - Sphinx version now explicit as to it's source from Documentation/meson.build - Pass project_version() through api_version - Use Camera object to report version rather than global constructor. v3: - Add dependency to the vcs tag to ensure libcamera builds the header - Fix up commit title - Rename version-gen to gen-version.sh - Append git sha and any -dirty flag with a '+' separator - Move version generation to single libcamera/version.h file. - Remove version.cpp and store the const std::string version in camera_manager.cpp v4: - Fix commit message - Use path_join() to reference gen-version.sh - change Docuementation/conf.py comment - trivial fixups. --- Documentation/conf.py | 7 ++---- Documentation/meson.build | 7 ++++-- include/libcamera/meson.build | 7 ++++++ include/libcamera/version.h.in | 22 +++++++++++++++++++ meson.build | 9 +++----- src/libcamera/camera_manager.cpp | 8 +++++++ src/libcamera/meson.build | 1 + utils/gen-version.sh | 37 ++++++++++++++++++++++++++++++++ 8 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 include/libcamera/version.h.in create mode 100755 utils/gen-version.sh diff --git a/Documentation/conf.py b/Documentation/conf.py index 970edf3d7298..bffd1d8f1e5d 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -23,11 +23,8 @@ project = 'libcamera' copyright = '2018-2019, The libcamera documentation authors' author = u'Kieran Bingham, Jacopo Mondi, Laurent Pinchart, Niklas Söderlund' -# The short X.Y version -version = '' -# The full version, including alpha/beta/rc tags -release = '0.1' - +# Version information is provided by the build environment, through the +# sphinx command line. # -- General configuration --------------------------------------------------- diff --git a/Documentation/meson.build b/Documentation/meson.build index 629e853120cb..2db80b39989b 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -1,4 +1,4 @@ -doc_install_dir = join_paths(get_option('datadir'), 'doc', 'libcamera-@0@'.format(api_version)) +doc_install_dir = join_paths(get_option('datadir'), 'doc', 'libcamera-@0@'.format(meson.project_version())) # # Doxygen @@ -47,8 +47,11 @@ if sphinx.found() 'index.rst', ] + release = 'release=' + meson.project_version() + custom_target('documentation', - command : [sphinx, '-q', '-W', '-b', 'html', meson.current_source_dir(), '@OUTPUT@'], + command : [sphinx, '-D', release, '-q', '-W', '-b', 'html', + meson.current_source_dir(), '@OUTPUT@'], input : docs_sources, output : 'html', build_by_default : true, diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 3067120a1598..6f81f1117318 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -16,6 +16,13 @@ libcamera_api = files([ 'timer.h', ]) +gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh') + +version_h = vcs_tag(command : [gen_version, meson.current_source_dir()], + input : 'version.h.in', + output : 'version.h', + fallback : 'v0.0') + gen_header = files('gen-header.sh') libcamera_h = custom_target('gen-header', diff --git a/include/libcamera/version.h.in b/include/libcamera/version.h.in new file mode 100644 index 000000000000..e49b36962aed --- /dev/null +++ b/include/libcamera/version.h.in @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * version.h - Library version information + * + * This file is auto-generated. Do not edit. + */ +#ifndef __LIBCAMERA_VERSION_H__ +#define __LIBCAMERA_VERSION_H__ + +#include + +#define LIBCAMERA_VERSION "@VCS_TAG@" + +namespace libcamera { + +extern const std::string version; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_VERSION_H__ */ diff --git a/meson.build b/meson.build index a3b0bc820072..342b3cc76a93 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,8 @@ project('libcamera', 'c', 'cpp', meson_version : '>= 0.40', - version : '0.1', + version : run_command('utils/gen-version.sh', + '@0@'.format(meson.source_root()), + check : true).stdout().strip(), default_options : [ 'werror=true', 'warning_level=2', @@ -8,11 +10,6 @@ project('libcamera', 'c', 'cpp', ], license : 'LGPL 2.1+') -# TODO: Extract this from project.version. -# Ideally the version at Documentation/conf.py should be -# generated from this too. -api_version = '0.1' - cc = meson.get_compiler('c') config_h = configuration_data() diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index cf881ce2e641..2df24d44e284 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -9,6 +9,7 @@ #include #include +#include #include "device_enumerator.h" #include "event_dispatcher_poll.h" @@ -64,6 +65,11 @@ CameraManager::~CameraManager() { } +/** + * \brief Declare the library global version string + */ +const std::string version(LIBCAMERA_VERSION); + /** * \brief Start the camera manager * @@ -79,6 +85,8 @@ int CameraManager::start() if (enumerator_) return -EBUSY; + LOG(Camera, Info) << "libcamera " << version; + enumerator_ = DeviceEnumerator::create(); if (!enumerator_ || enumerator_->enumerate()) return -ENODEV; diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 8075b1f696f5..336f4f066fac 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -80,6 +80,7 @@ control_types_cpp = custom_target('control_types_cpp', libcamera_sources += control_types_cpp libcamera_deps = [ + declare_dependency(sources : version_h), cc.find_library('dl'), libudev, ] diff --git a/utils/gen-version.sh b/utils/gen-version.sh new file mode 100755 index 000000000000..b3003d7a80d3 --- /dev/null +++ b/utils/gen-version.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0-or-later +# Generate a version string using git describe + +if [ -n "$1" ] +then + cd "$1" 2>/dev/null || exit 1 +fi + +# Get a short description from the tree. +version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null) + +if [ -z "$version" ] +then + # Handle an un-tagged repository + sha=$(git describe --abbrev=8 --always 2>/dev/null) + commits=$(git log --oneline | wc -l 2>/dev/null) + version=v0.0.$commits.$sha +fi + +# Prevent changed timestamps causing -dirty labels +git update-index --refresh > /dev/null 2>&1 +dirty=$(git diff-index --name-only HEAD 2>/dev/null) || dirty= + +# Strip the 'g', and replace the preceeding '-' with a '+' to denote a label +version=$(echo "$version" | sed -e 's/-g/+/g') + +# Fix the '-' (the patch count) to a '.' as a version increment. +version=$(echo "$version" | sed -e 's/-/./g') + +if [ -n "$dirty" ] +then + version=$version-dirty +fi + +echo "$version" From patchwork Thu Jul 4 14:59:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1616 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3731561570 for ; Thu, 4 Jul 2019 16:59:47 +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 B41A2F7B; Thu, 4 Jul 2019 16:59:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562252386; bh=hpAdJ1Frx97sr3AhhePfmNLQau/b6lCTcUYGLPg0jKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vKV1akXsYnXDqv49yDyLmy2DLYTshPLONztt7FWYnMfI5ilAH3D3hVepcHrO9KaXz cEY92MEo9S9mjngK1y1TMdTuOHu+2x8FDG0EgGCZnouy3EGtksS8YCAFQSyPTqbowe BIKXZpYv4i0Eq0GeCGGFfSmnlD8IHXwVGiFh3x7A= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 15:59:39 +0100 Message-Id: <20190704145942.17879-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> References: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/6] qcam: Move static timestamp to MainWindow 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 14:59:47 -0000 The 'last' buffer timestamp is stored as a static. Rename the variable to a more descritive 'lastBufferTime' and move it to the class instance. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/qcam/main_window.cpp | 10 +++++----- src/qcam/main_window.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 16b123132dd9..0f737d852960 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -144,6 +144,8 @@ int MainWindow::startCapture() requests.push_back(request); } + lastBufferTime_ = 0; + ret = camera_->start(); if (ret) { std::cout << "Failed to start capture" << std::endl; @@ -187,16 +189,14 @@ void MainWindow::stopCapture() void MainWindow::requestComplete(Request *request, const std::map &buffers) { - static uint64_t last = 0; - if (request->status() == Request::RequestCancelled) return; Buffer *buffer = buffers.begin()->second; - double fps = buffer->timestamp() - last; - fps = last && fps ? 1000000000.0 / fps : 0.0; - last = buffer->timestamp(); + double fps = buffer->timestamp() - lastBufferTime_; + fps = lastBufferTime_ && fps ? 1000000000.0 / fps : 0.0; + lastBufferTime_ = buffer->timestamp(); std::cout << "seq: " << std::setw(6) << std::setfill('0') << buffer->sequence() << " buf: " << buffer->index() diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index fe565cbcb460..345bdaaed354 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -48,6 +48,8 @@ private: bool isCapturing_; std::unique_ptr config_; + uint64_t lastBufferTime_; + ViewFinder *viewfinder_; }; From patchwork Thu Jul 4 14:59:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1617 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 90E7C6156A for ; Thu, 4 Jul 2019 16:59:47 +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 1E1D824B; Thu, 4 Jul 2019 16:59:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562252387; bh=+toJ6tFIT3NmctEyT3PS89aPx4+CdywtxJrmszY7Znw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GUrr5jDgOUhPoWjGWZ9L0fk7SwOghMuRZybwpDPcTlQstDHSPAvLm9rrBBBCKEAtD HyF8SRax49Ukr1olTAjB2ujPUXtdGkw/dTwnCGg76V2Ng/63XPa08duCcPg7iqEH0w vXGY5QV/jxU18nPkeqrxrJPNjrsc8Rlvtreow9YU= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 15:59:40 +0100 Message-Id: <20190704145942.17879-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> References: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/6] qcam: Add the version string to the title 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 14:59:48 -0000 Provide the version string reported by the libcamera library on the qcam test utility. This helps confirm the exact version of the library that is being used while testing. The version string is stored in the MainWindow so that it can be reused without reconstructing. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/qcam/main_window.cpp | 4 ++++ src/qcam/main_window.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 0f737d852960..d61369109d66 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -14,6 +14,7 @@ #include #include +#include #include "main_window.h" #include "viewfinder.h" @@ -25,6 +26,9 @@ MainWindow::MainWindow(const OptionsParser::Options &options) { int ret; + title_ = "QCam " + QString::fromStdString(libcamera::version); + setWindowTitle(title_); + viewfinder_ = new ViewFinder(this); setCentralWidget(viewfinder_); viewfinder_->setFixedSize(500, 500); diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 345bdaaed354..46a494a9d783 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -42,6 +42,7 @@ private: const std::map &buffers); int display(Buffer *buffer); + QString title_; const OptionsParser::Options &options_; std::shared_ptr camera_; From patchwork Thu Jul 4 14:59: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: 1618 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EF8946157B for ; Thu, 4 Jul 2019 16:59:47 +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 7DC742AF; Thu, 4 Jul 2019 16:59:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562252387; bh=SmEDt2vdm7wf1fhUB5FuqYR9+6h5HD1FrHFWr5tWWjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mePJG7yR4IRcwO+uKYnpvcvY17G7c+yo0bhJxQXayh8czyqKsOUcz/3mAV1elevAe AX6g9S9bsx6kOkw9O8Gca5s5U9F1UlMRSo9s4c7ZzUM4BtbdjKhFHg5Qnrqqlgb4m3 UlYVaHJLFU9yGYDeSbo+2DhR1/p9bxJjlgWXKaHw= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 15:59:41 +0100 Message-Id: <20190704145942.17879-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> References: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 5/6] 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 14:59:49 -0000 Provide an average FPS in the QCam title bar to show the current rate of frame processing. The QCam compilation is updated to process the QT MoC headers to support signals and slots accordingly. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v4 - Start and stop title timer with the stream --- src/qcam/main_window.cpp | 23 +++++++++++++++++++++++ src/qcam/main_window.h | 15 +++++++++++++++ src/qcam/meson.build | 11 +++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index d61369109d66..5693b9256a08 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_; diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 46a494a9d783..e97d92402f1e 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -10,7 +10,11 @@ #include #include + +#include #include +#include +#include #include #include @@ -28,10 +32,15 @@ enum { class MainWindow : public QMainWindow { + Q_OBJECT + public: MainWindow(const OptionsParser::Options &options); ~MainWindow(); +public Q_SLOTS: + void updateTitle(); + private: int openCamera(); @@ -43,6 +52,8 @@ private: int display(Buffer *buffer); QString title_; + QTimer titleTimer_; + const OptionsParser::Options &options_; std::shared_ptr camera_; @@ -51,6 +62,10 @@ private: uint64_t lastBufferTime_; + QElapsedTimer frameRateInterval_; + uint32_t previousFrames_; + uint32_t framesCaptured_; + ViewFinder *viewfinder_; }; diff --git a/src/qcam/meson.build b/src/qcam/meson.build index 9f1fa75f9813..21f91f25cec0 100644 --- a/src/qcam/meson.build +++ b/src/qcam/meson.build @@ -7,14 +7,21 @@ qcam_sources = files([ 'viewfinder.cpp', ]) -import('qt5') +qcam_moc_headers = files([ + 'main_window.h', +]) + +qt5 = import('qt5') qt5_dep = dependency('qt5', method : 'pkg-config', modules : ['Core', 'Gui', 'Widgets'], required : false) if qt5_dep.found() - qcam = executable('qcam', qcam_sources, + moc_files = qt5.preprocess(moc_headers: qcam_moc_headers, + dependencies: qt5_dep) + + qcam = executable('qcam', qcam_sources, moc_files, install : true, dependencies : [libcamera_dep, qt5_dep], cpp_args : '-DQT_NO_KEYWORDS') From patchwork Thu Jul 4 14:59:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1619 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 48CA161576 for ; Thu, 4 Jul 2019 16:59:48 +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 CED4F24B; Thu, 4 Jul 2019 16:59:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562252388; bh=Q+7E+ZHICzw40F2vD5bFLajyL2NeyBwIvZ79X1v7rfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jvGEhNbRVBVQVKuVW0uJliSCnSH2xh3J/PktVv38SGUdulWGx7PZiPEXUsm1L0izv T7MNArCDQyi4gKGN7c4OBHQc8RF+fr8mSU5XzhYlY46lDWfvevj3jCwI7h3ijTKIUd i2O+/5e4t3jllDPy3cBvBYSb0gZ8VyLUQJdE/5iw= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 15:59:42 +0100 Message-Id: <20190704145942.17879-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> References: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/6] Documentation: Wrap extended doc_install_dir line 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 14:59:49 -0000 The doc_install_dir is longer than 80 chars. Wrap it accordingly. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Documentation/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/meson.build b/Documentation/meson.build index 2db80b39989b..c355d5feb504 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -1,4 +1,5 @@ -doc_install_dir = join_paths(get_option('datadir'), 'doc', 'libcamera-@0@'.format(meson.project_version())) +doc_install_dir = join_paths(get_option('datadir'), 'doc', + 'libcamera-@0@'.format(meson.project_version())) # # Doxygen