From patchwork Tue Jul 26 19:41:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16809 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A3000C3275 for ; Tue, 26 Jul 2022 19:41:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B74D63312; Tue, 26 Jul 2022 21:41:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658864504; bh=3Z0HBm5+psRkG8twCvvKP2WPwiLjQU/h7vfRLmk55Dc=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lZmzRyV7idjx8VglloiuG6fkHB6HXETIdGi0sUIdDLoGkvfmlp6YHKF1+Vb/R1ScP QzaJlHtdIkaOgIcMlmwqIaU/y9u6uV5jbVSnuenqDMOotpMaLrEbrNdL36C9c7FNDc tnYi9wxt1DqF0WdXAUg8Q++0PZg2i9FO/p2aG/wLXYzKUfU66rC/UZNPvTJ2MAWSAd 3go7yh7ekIcBc4K9khmefRv4UpBf8fspnA94pSO3tB6xBlOcNGrcOWmZZfxTxrVcp6 uzaCt8RILdRx1bJW6E3aFwqCeeHyNq+WyNFKyH1RE+hnFvSVCNpJGxwmglbETqVtGN +mOUNDCuRV9Vw== Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A85B60487 for ; Tue, 26 Jul 2022 21:41:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bvI4PscM"; dkim-atps=neutral Received: by mail-pf1-x431.google.com with SMTP id w205so10790382pfc.8 for ; Tue, 26 Jul 2022 12:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jHwjnUKeUvBi6o6pk+wq5ks5LIpCU8fe7V02l2HJH9U=; b=bvI4PscMhgP0mENGrWEYufs5dQbVbG1H70bafeaqCmBxeej4Mw4pMWpFmjou6gij19 v5Pr62EdCRLoQdg9GoA22yYW04sM4cPEhbSRCTtwn4iltrhzATTfg7GXRzvz9Yl4gTPR pnnRL7+omjbiADQkDQtI6A4gg32d+GWApGG8HBhcOVUn4RG6ikEiCfoB8G7z5aIZsu65 nwxx8X619lPbwfPuodQtvQA2yU2aBIe5dOgGSov+Br/OM6qZQUdJTG1QOI8r7OSjsP0Q CtsEDQsxmy9YDHCRMO9IIFomDe0KqvVOqm9DsIsV03pt/o0WQpAWCRZUc0XSp/JN14im XbnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jHwjnUKeUvBi6o6pk+wq5ks5LIpCU8fe7V02l2HJH9U=; b=TtVXEVBD6En1AI8+OzxO5b0xfYvzVm5Xmt2oE5oULT0x/Ao+wPkS7oCfWEcLXi/vmC LSseF5pxI37cypBpSKUjrQcqGnNlJfFr/XqYrY314QlMUWm2HyIz1W6uKTJmFcFrC3ar Kvj4PbVj7pW8e8g9Xs54l8DJnMyFP3ybGyE8oYKmQsO6F+Aus0mBg4ALEOdi19YKHaTb XIaYuT/kwPFpeL3EZiSgwmmEzzlzxpyfwxo9TjOJu4pKeCQueDGAHYsV2LwZgdft1vaV 1moTlZEPv+g6XcB+n5+6cNWFUaettHS5yVof3k9YdlXq6zkY/DUmqdPSn2249BwTAuJe oZyQ== X-Gm-Message-State: AJIora8hpnPHv7tneBVIEAR9DbZq/tgHnu66lcSUzHx57wvAF5e4rjtA JffGyGDBJ+waih1qBvoeDUtYY62MvsI= X-Google-Smtp-Source: AGRyM1vBl5wOGb/u08a2ObvnJbXE95vEnIHYx4T1sXjCWMLegriF/s78livev+ZOsTKP1Xdpva/Yog== X-Received: by 2002:a63:2bcc:0:b0:40c:95b5:46a4 with SMTP id r195-20020a632bcc000000b0040c95b546a4mr16018155pgr.535.1658864501566; Tue, 26 Jul 2022 12:41:41 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d6bf:24ea:3f52:4c78:7bd8]) by smtp.gmail.com with ESMTPSA id a5-20020aa794a5000000b0052ac1af926fsm12017782pfl.20.2022.07.26.12.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:41:41 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 01:11:21 +0530 Message-Id: <20220726194123.170208-1-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 1/3] qcam: Queue requests only through MainWindow::queueRequest() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Utkarsh Tiwari via libcamera-devel From: Utkarsh Tiwari Reply-To: Utkarsh Tiwari Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently to request a frame, we operate the camera directly. This approach is also scattered in two places, MainWindow::startCapture() and MainWindow::queueRequest(). This makes it difficult to account for requests. Centralize all the queuing to a single function queueRequest() Rename the current queueRequest() to renderComplete(). This makes more sense as this slot is triggered when the render is complete and we want to queue another request. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- Changes from v4 - Grammer fixes in the commit message src/qcam/main_window.cpp | 14 +++++++++----- src/qcam/main_window.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 7433d647..4e773c31 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -120,14 +120,14 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) if (renderType == "qt") { ViewFinderQt *viewfinder = new ViewFinderQt(this); connect(viewfinder, &ViewFinderQt::renderComplete, - this, &MainWindow::queueRequest); + this, &MainWindow::renderComplete); viewfinder_ = viewfinder; setCentralWidget(viewfinder); #ifndef QT_NO_OPENGL } else if (renderType == "gles") { ViewFinderGL *viewfinder = new ViewFinderGL(this); connect(viewfinder, &ViewFinderGL::renderComplete, - this, &MainWindow::queueRequest); + this, &MainWindow::renderComplete); viewfinder_ = viewfinder; setCentralWidget(viewfinder); #endif @@ -522,7 +522,7 @@ int MainWindow::startCapture() /* Queue all requests. */ for (std::unique_ptr &request : requests_) { - ret = camera_->queueRequest(request.get()); + ret = queueRequest(request.get()); if (ret < 0) { qWarning() << "Can't queue request"; goto error_disconnect; @@ -756,7 +756,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer) viewfinder_->render(buffer, mappedBuffers_[buffer].get()); } -void MainWindow::queueRequest(FrameBuffer *buffer) +void MainWindow::renderComplete(FrameBuffer *buffer) { Request *request; { @@ -785,6 +785,10 @@ void MainWindow::queueRequest(FrameBuffer *buffer) qWarning() << "No free buffer available for RAW capture"; } } + queueRequest(request); +} - camera_->queueRequest(request); +int MainWindow::queueRequest(Request *request) +{ + return camera_->queueRequest(request); } diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index fc70920f..bc844711 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -67,7 +67,7 @@ private Q_SLOTS: void processRaw(libcamera::FrameBuffer *buffer, const libcamera::ControlList &metadata); - void queueRequest(libcamera::FrameBuffer *buffer); + void renderComplete(libcamera::FrameBuffer *buffer); private: int createToolbars(); @@ -81,6 +81,7 @@ private: void addCamera(std::shared_ptr camera); void removeCamera(std::shared_ptr camera); + int queueRequest(libcamera::Request *request); void requestComplete(libcamera::Request *request); void processCapture(); void processHotplug(HotplugEvent *e); From patchwork Tue Jul 26 19:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16810 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B17BEC3275 for ; Tue, 26 Jul 2022 19:41:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6953463315; Tue, 26 Jul 2022 21:41:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658864509; bh=B/wjX/CiabQtTbA2lH4jK0Q9SRy7gRPZ7b6EznReXrk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xd8v+ujh9TM6yU0PtHUMXuGRTOEYJZOB441uHRtqkkbiHfgothWjOKdNx1/+EeTJe TAb23YTAKgX7asvD/rG8MohjGb6wIWgSt+OcNgrxWYZr/sYAayPtAQhINpuV6cmGko C8WPFDpnK1MeB4EXAcxmqghAtVpCNpf78ydbN4zKY4ZhtRh7+051yEuhm2VDFa0hbj pLx/xqZMZfTop+h0qEZHYWE7VxUBuc+N+A+Ml5x1pPfAZqzt8K3w8KJuAkG4K2vazz vLZqYvljetUin2JJGmUV1YohURiyu4Z4HTrHlreVizxRr0nI33HPNbHZOd9uvSCd4Q aRLFkgf6ZgVcA== Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 46FB160487 for ; Tue, 26 Jul 2022 21:41:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kqMS5IfU"; dkim-atps=neutral Received: by mail-pj1-x102f.google.com with SMTP id b10so14349302pjq.5 for ; Tue, 26 Jul 2022 12:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3ngs0oX40Iiqxk9DsOXNqG4eDRWgWD07yRSe0zd2ziA=; b=kqMS5IfUiQb5QQfvojsH1gkpqQ7529LNBbfH/8Zi8+twwTIqmkGMBPdAQS3qFC0aaI CQvTOwu+al9xeXV6ibqZAerKJ8kbm/02ctOhYSYqKCwXErxG/PZP0nIWuKSlzdVp9XDv 579dLGvNORPhndz/i8fD+Ilgrz89VtHVYBnVMjt71Ou1p4XdYDsB6tQw1L+VENk6z2z2 c85n3Kr80ToWEi+IBFitHdMGYUlEfg73YJbwRWVEa4kFdwYhYH+MKTuB5uCveHsrcHEt o034jhwWrkWcEQ0yyMylkcnf1m2p34wAVeV1OAKfI9lr+0igmJ8DKfku6fWIfrK6XwGf CKcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3ngs0oX40Iiqxk9DsOXNqG4eDRWgWD07yRSe0zd2ziA=; b=5F0LemjGtS+HfgO9C2z+2TriwEXq5K9bWCkUKUAwiWoBbBdLddQDxkPZg5LVcVpa5S brPBAgtauZdp/n36Xmy5vpuuQG0HtfCO4VCY3yr4j9zAYtsv4dpHvuNiwFnfTt4mU/S6 qeDDR2NvoydeSK1t7skB0e6xFVdwmMMv9oTfV/Tu0dRAlw6s4VGrMGGC39Iqkg7y5sa/ vIOWrOVjRjGKDNgxgcAmzoislhsLlkKQqsi4edEkwWcWEjxzV+k3KKdMlrBevEWB75V+ tceFOusoZADkdcJF9rl5vyHn+AxeZTpjBZMF233uXA7szcwO2nbCkoTSWd8PUy1+Ra3c Kvvw== X-Gm-Message-State: AJIora+Br/PRwSPjlAWkgIuKarRJ0yc6HxlacuB5B02zjJdUwIPBhw6t VSZBPXChQkVop1j5NLo0jL6WE1F0AZI= X-Google-Smtp-Source: AGRyM1vHOkfj+GCNuOneR0RTk3WTYZME4YN5rbG6aXfVEYm3dT1rfEXO/mqMDMaJfKtdU14Td20eKw== X-Received: by 2002:a17:903:32c6:b0:16d:328f:898d with SMTP id i6-20020a17090332c600b0016d328f898dmr17828612plr.143.1658864506585; Tue, 26 Jul 2022 12:41:46 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d6bf:24ea:3f52:4c78:7bd8]) by smtp.gmail.com with ESMTPSA id a5-20020aa794a5000000b0052ac1af926fsm12017782pfl.20.2022.07.26.12.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:41:46 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 01:11:22 +0530 Message-Id: <20220726194123.170208-2-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726194123.170208-1-utkarsh02t@gmail.com> References: <20220726194123.170208-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 2/3] qcam: Add a GUI way to use capture script X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Utkarsh Tiwari via libcamera-devel From: Utkarsh Tiwari Reply-To: Utkarsh Tiwari Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Implement an Open Capture Script button which would allow the user to open a Capture Script (*.yaml). This button has two states : - Open Capture Script - Stop the execution of current capture script When being clicked in open state, present them with a QFileDialog to allow user to select a single file. Introduce a queueCount_ to keep track of the requests queued. When stopping the execution of the capture script the queueCount_ is not reseted and the capture is continues as it is (i.e it is not stopped or restarted). Requests are queued with any controls the script matching the current queueCount_. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- Changes from v4 - Reworded the commit message to clarify button states and queueCount_ reseting. src/qcam/assets/feathericons/feathericons.qrc | 2 + src/qcam/main_window.cpp | 68 +++++++++++++++++++ src/qcam/main_window.h | 6 ++ src/qcam/meson.build | 2 + 4 files changed, 78 insertions(+) diff --git a/src/qcam/assets/feathericons/feathericons.qrc b/src/qcam/assets/feathericons/feathericons.qrc index c5302040..6b08395a 100644 --- a/src/qcam/assets/feathericons/feathericons.qrc +++ b/src/qcam/assets/feathericons/feathericons.qrc @@ -3,9 +3,11 @@ aperture.svg camera-off.svg + file.svg play-circle.svg save.svg stop-circle.svg x-circle.svg + x-square.svg diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 4e773c31..9dc96fbb 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -233,6 +234,13 @@ int MainWindow::createToolbars() saveRaw_ = action; #endif + /* Open Script... action. */ + action = toolbar_->addAction(QIcon::fromTheme("document-open", + QIcon(":file.svg")), + "Open Capture Script"); + connect(action, &QAction::triggered, this, &MainWindow::chooseScript); + scriptExecAction_ = action; + return 0; } @@ -256,6 +264,60 @@ void MainWindow::updateTitle() setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps"); } +/** + * \brief Load a capture script for handling the capture session. + * + * If already capturing, it would restart the capture. + */ +void MainWindow::chooseScript() +{ + if (script_) { + /* + * This is the second valid press of load script button, + * It indicates stopping, Stop and set button for new script. + */ + script_.reset(); + scriptExecAction_->setIcon(QIcon::fromTheme("document-open", + QIcon(":file.svg"))); + scriptExecAction_->setText("Open Capture Script"); + return; + } + + QString scriptFile = QFileDialog::getOpenFileName(this, "Open Capture Script", QDir::currentPath(), + "Capture Script (*.yaml)"); + if (scriptFile.isEmpty()) + return; + + /* + * If we are already capturing, + * stop so we don't have stuck image in viewfinder. + */ + bool wasCapturing = isCapturing_; + if (isCapturing_) + toggleCapture(false); + + script_ = std::make_unique(camera_, scriptFile.toStdString()); + if (!script_->valid()) { + script_.reset(); + QMessageBox::critical(this, "Invalid Script", + "Couldn't load the capture script"); + if (wasCapturing) + toggleCapture(true); + return; + } + + /* + * Valid script verified + * Set the button to indicate stopping availibility. + */ + scriptExecAction_->setIcon(QIcon(":x-square.svg")); + scriptExecAction_->setText("Stop Script execution"); + + /* Start capture again if we were capturing before. */ + if (wasCapturing) + toggleCapture(true); +} + /* ----------------------------------------------------------------------------- * Camera Selection */ @@ -511,6 +573,7 @@ int MainWindow::startCapture() previousFrames_ = 0; framesCaptured_ = 0; lastBufferTime_ = 0; + queueCount_ = 0; ret = camera_->start(); if (ret) { @@ -790,5 +853,10 @@ void MainWindow::renderComplete(FrameBuffer *buffer) int MainWindow::queueRequest(Request *request) { + if (script_) + request->controls() = script_->frameControls(queueCount_); + + queueCount_++; + return camera_->queueRequest(request); } diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index bc844711..eb398c1d 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -26,6 +26,7 @@ #include #include +#include "../cam/capture_script.h" #include "../cam/stream_options.h" #include "viewfinder.h" @@ -87,11 +88,14 @@ private: void processHotplug(HotplugEvent *e); void processViewfinder(libcamera::FrameBuffer *buffer); + void chooseScript(); + /* UI elements */ QToolBar *toolbar_; QAction *startStopAction_; QComboBox *cameraCombo_; QAction *saveRaw_; + QAction *scriptExecAction_; ViewFinder *viewfinder_; QIcon iconPlay_; @@ -125,6 +129,8 @@ private: QElapsedTimer frameRateInterval_; uint32_t previousFrames_; uint32_t framesCaptured_; + uint32_t queueCount_; std::vector> requests_; + std::unique_ptr script_; }; diff --git a/src/qcam/meson.build b/src/qcam/meson.build index c46f4631..67074252 100644 --- a/src/qcam/meson.build +++ b/src/qcam/meson.build @@ -15,6 +15,7 @@ endif qcam_enabled = true qcam_sources = files([ + '../cam/capture_script.cpp', '../cam/image.cpp', '../cam/options.cpp', '../cam/stream_options.cpp', @@ -37,6 +38,7 @@ qcam_resources = files([ qcam_deps = [ libatomic, libcamera_public, + libyaml, qt5_dep, ] From patchwork Tue Jul 26 19:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16811 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 556F5C3275 for ; Tue, 26 Jul 2022 19:41:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1EA0963317; Tue, 26 Jul 2022 21:41:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658864512; bh=zqUukScYu10qMuBjWoarzIHgUagwY2WlG1g02kH8NWs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=dfRrer3PlnxLeZPTmebAFd6x6ltqHFKtwQ+NHjMYgyYr6dPvyHuVAC3a0Tix1w3SK bwcgktRwH+4xyLPXGI5NuTdCXFrAc7f7sux6fezmYClPN4PEWzEIujneXs8VJNN2EI i3/Gug/YedrA0Co8+OzTtmX3wuNiYP/rgp3Eyblzw2hB5Tsi1wrgvYa2u9WXelqH+T DMaJ/8TTY6BKczH29tRvuIS8iQUqAv1weBejaT4+933h7a6sZzu/UzHsT2HzUNPVoI Bb2Jo1W785Wy1qdGq82TKUrT0CIKLhNAsAqhlev5dYXashEk8ICabrFK621h4clC9u uKQWZ9fLJQaRA== Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BE5C60487 for ; Tue, 26 Jul 2022 21:41:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="U7wQwO+Z"; dkim-atps=neutral Received: by mail-pl1-x62c.google.com with SMTP id z3so14274504plb.1 for ; Tue, 26 Jul 2022 12:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C9Qz3WEv8GHqsyhmoNi2/XFeD1co4638A+i8dJzm75o=; b=U7wQwO+ZsSJhl/O+08tUK2csulTtq8+YKvlHSXDKFf+GR22CNffvLn8tKNTF0qwrzk JGsuZudH1aTAJ1CdSvME6vbYUw9LYyfm9/s20C0skDpui8Ecs75kmH9F1aCI3jwz3JoJ vZJf1dzL/4kjq03My+9N61UTuj07lX2f12ONgifCDkynh9NEzluUrHQQtr+TRDbikDFw z/Q7bdMPFQjcT70Y+saz1cmdjRfyvdEeU5sOhtejsz4FGA0yIeWtmgFzORzU0zJbGn67 DPDr4+axzq5c1uZYTAgL/WHzfJtlGJBuUXsS9Np+C8PZ2Gsdoo5KbRh2MZbCpgdFZ1U1 9X1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C9Qz3WEv8GHqsyhmoNi2/XFeD1co4638A+i8dJzm75o=; b=wqDqhp6R5/WvzTAwmcjINf0BzOsAW9HDkM2Aki1IndjWZedGR89UpLqIU6j4a9QaZm 3rW+yQa69RDz7JMRHSVLFFrMPhouBE5W2OhYrbjLrrqmiOeVb4uoyKVsVvcYmpbBUC3P 2D48hkOaDZ1H1fiPBmqCbQ4IeoYpXpIURwcgHZ0J10B2z94JzI8EtQxETZMGkXFFHvSP XEeIXkhtGao/lYHOogRUJ2EOFshKOErHUyy0sLsldgJ5uAhK06/jpBiEIpuWVNYhVWFZ J/bsp9lghOF0R4xsT6nDic7ia20gbi5QUkWnwjQ/VKi1k4Kc6YxVaZEAhx6K+IuL6t98 J/WA== X-Gm-Message-State: AJIora/jWjXALSyjf/xX5mHos5ySt+9avR6cuB8Q2eh9JQhwRmL7tqq3 ZAidD+ebQeqN8BQVGKl4UjSMCNPaAUo= X-Google-Smtp-Source: AGRyM1vQrnGzlFbjN+GjjqF/0pStL4/3hH0KVpFYMzOEmW6wv6f5w6xviPj9+2ilq8XvGAwtMnGJqA== X-Received: by 2002:a17:902:8693:b0:16c:db86:1c86 with SMTP id g19-20020a170902869300b0016cdb861c86mr17803564plo.9.1658864509478; Tue, 26 Jul 2022 12:41:49 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d6bf:24ea:3f52:4c78:7bd8]) by smtp.gmail.com with ESMTPSA id a5-20020aa794a5000000b0052ac1af926fsm12017782pfl.20.2022.07.26.12.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:41:49 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 01:11:23 +0530 Message-Id: <20220726194123.170208-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726194123.170208-1-utkarsh02t@gmail.com> References: <20220726194123.170208-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/3] qcam: Add --script to load capture script X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Utkarsh Tiwari via libcamera-devel From: Utkarsh Tiwari Reply-To: Utkarsh Tiwari Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add --script as an individual option to load capture scripts. Load the capture script before starting the capture. If an invalid capture script has been given, display a QMessageBox and print it on the console informing that the script is invalid. Do not start the capture. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- Changes from v4 - Now when we have an invalid script we quit and don't start the capture. src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 20 ++++++++++++++++++++ src/qcam/main_window.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp index d3f01a85..91166be5 100644 --- a/src/qcam/main.cpp +++ b/src/qcam/main.cpp @@ -43,6 +43,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[]) "Set configuration of a camera stream", "stream", true); parser.addOption(OptVerbose, OptionNone, "Print verbose log messages", "verbose"); + parser.addOption(OptCaptureScript, OptionString, + "Load a capture session configuration script from a file", + "script", ArgumentRequired, "script"); OptionsParser::Options options = parser.parse(argc, argv); if (options.isSet(OptHelp)) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 9dc96fbb..7b2bc84b 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -152,6 +152,26 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) return; } + if (options_.isSet(OptCaptureScript)) { + std::string scriptName = options_[OptCaptureScript].toString(); + script_ = std::make_unique(camera_, scriptName); + if (!script_->valid()) { + QMessageBox::critical(this, "Invalid Script", + "Couldn't load the capture script"); + qInfo() << "Invalid Capture Script"; + + script_.reset(); + + /* Do not start capture if invalid script. */ + quit(); + return; + } + + /* Show stopping availability. */ + scriptExecAction_->setIcon(QIcon(":x-square.svg")); + scriptExecAction_->setText("Stop Script execution"); + } + startStopAction_->setChecked(true); } diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index eb398c1d..59e50b5e 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -43,6 +43,7 @@ enum { OptRenderer = 'r', OptStream = 's', OptVerbose = 'v', + OptCaptureScript = 256, }; class MainWindow : public QMainWindow