From patchwork Mon Jun 27 03:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16372 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 530E5BD808 for ; Mon, 27 Jun 2022 03:02:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1B1FB65638; Mon, 27 Jun 2022 05:02:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656298933; bh=4Aq824HZHPf2PmvNblVn/eW6i8DB/sJg0DcK4tanfZg=; 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=zCNdGnobwUOGAduBknwh46SpsWO6JmAsPEvDLi1ADwXltgSobeddIkiZd5yrHnKmC FFim6yZZpGqfYgB7u55XGincF1xleJPs+uUywxmflLPZIZrRbbMg9J5TPpDGudRxD3 WVQCX9eNVrcw2TbwnswM0Odf9pfv6x098E8Ok1NQdI8qBQKO5JqxIjyPNIrBLndiTl XjoN3P0PcFOPSbapBA5IHDqQYLn2kYc1ajvKjonGVcQCmD9UYfzSEshgQDnYZvqEFF K05BMsQeVq2pLyvjQ4SJfFceXiep4lMgJE7ULF3vHO3BbW0gFmHS50vLhv18zkZ4FM 2VDK7fXYPvymQ== Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C10A465633 for ; Mon, 27 Jun 2022 05:02:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SCEAtlGf"; dkim-atps=neutral Received: by mail-pl1-x631.google.com with SMTP id jh14so6982773plb.1 for ; Sun, 26 Jun 2022 20:02:11 -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=FiD29FzPLJ25vLGERZCLerCSVMUJH90zaw1E+agM5O0=; b=SCEAtlGfwk49UxN7mPHexmMdodfka2PxBvF89qwfJe5VvBVNa0H0seolnDvQ5vAC2u YW62qTkzeOkWsr0EW2v4iBysXEPTiLynjj7UviH6lCUOSA4RGSlLNoozWHcgm4EfVtgG D1u7JzCIq17IiqmAel6QK4t2HFqUoSd78rl3SgMICpPXEt9fSAsnb9U/2Oatxg8DeGyp 9EoQy4QQrnATVHiNUocJq1BGBLiqMWBzEBwxzG8afwaj0xxTUALT5rlOtbegA6H2PRfT q59/hWO93bD3mEGAo282CzeXbqIGgQ5UhV57ao/PZu7n/CwV25wa/4dqWDU7LqN5bR0V +UJg== 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=FiD29FzPLJ25vLGERZCLerCSVMUJH90zaw1E+agM5O0=; b=1kLFZ26/t278t5yuHUBpQJlcjtyVlt/AskPuN+Ar8z+bsXH4JYlFMqCgh6cUbIBO6g SHBMkmjQjegXXv7Wrlk/YvpljZWMzgQH6Oe7Iv9qx3mkSsK6kLDXr/MB1FPiWsyzWH7M mYYCi8qhwvkiSP8E17IeMW1w3hUuclEvvHyBB3B+E/AsS8V5nWr4Ws8Z1DAa4MtonJep My2P2GQ0a8tlwGE3NnFdUdr+4UZ5cu4h87KXxh9JSsJZTbnSUYojYwWJwihPAY7bjXYs LtUVpFtrCWY/Nt1ILIelZ3lIDnTU/g8+MQvbqz3O0BvyCz/IG/Wm9oMzDLZh9tvuPzYJ dHvg== X-Gm-Message-State: AJIora/qHSvxObpidI989R+roKx+5esg7KDu/PJW5tv4nDif0rxcM51o h/fMSAej2uak1uW7ZmOB7XtrTFu5fS/Fmg== X-Google-Smtp-Source: AGRyM1sUKfy7wj7H2EvAP545c3aqw+6wmob9Zpp0Z+O1eBLRYlS9l5V0thyrT99V1Gq3/vsCFlnEeg== X-Received: by 2002:a17:902:ce85:b0:16a:3db5:5966 with SMTP id f5-20020a170902ce8500b0016a3db55966mr12687542plg.79.1656298930059; Sun, 26 Jun 2022 20:02:10 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:cf57:31af:7925:f9e6]) by smtp.gmail.com with ESMTPSA id s7-20020aa78d47000000b0051bba89c2bcsm5899378pfe.58.2022.06.26.20.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 20:02:09 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Jun 2022 11:01:57 +0800 Message-Id: <20220627030159.30730-2-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220627030159.30730-1-utkarsh02t@gmail.com> References: <20220627030159.30730-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 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 --- 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 dd0e51f5..adeb3181 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -119,14 +119,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 @@ -521,7 +521,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; @@ -755,7 +755,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer) viewfinder_->render(buffer, mappedBuffers_[buffer].get()); } -void MainWindow::queueRequest(FrameBuffer *buffer) +void MainWindow::renderComplete(FrameBuffer *buffer) { Request *request; { @@ -784,6 +784,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 3fbe872c..c3e4b665 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -66,7 +66,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(); @@ -80,6 +80,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 Mon Jun 27 03:01:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16373 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 DFE38BD808 for ; Mon, 27 Jun 2022 03:02:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A01F26563B; Mon, 27 Jun 2022 05:02:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656298936; bh=kchz076yAq7g5k6a5eerV9zYjh5cFKK+MXG5bltsbew=; 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=UuaY2fWL0D7eXWwJ5MK3DqsJOozLhiILt/i3fTQupzxKyriVrj9vQKmSfq6pk0d84 4MzqmrwpJQ7UxO78r36PenU/JU+GLxYPf8e+DltuE3rpDIfWIc+PgJp1nKQf8B4erX XSHeA7PovUZPTlEAiEHiJc5gug9pVIJdYsPf0q68JYuJsxrH4rXAkXlJ3CWbzXN4EZ CqU1hzJz+S2GsoVBRl1weSZ1t8Wza/fEuUHn89ukAOmT7l7ARAbCCvJ+zotNBQQxIY jl+pn/G4dbmIEF1+VAY6HjXSiUFPJ9mzV8otLu13f7FP1ikRMtcb/PJRla68SgMMRX deAtyVHamogsQ== Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AFD3B65633 for ; Mon, 27 Jun 2022 05:02:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CsFcpyPb"; dkim-atps=neutral Received: by mail-pf1-x434.google.com with SMTP id w6so7720528pfw.5 for ; Sun, 26 Jun 2022 20:02:14 -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=GNK6U/WvuXK4SXU0wPhP4gevq0vBN26GKYSlu4X1K6s=; b=CsFcpyPbM1eHK7r5RZr32Tpc58+2NMzXrMc3WD7g6q2Rd3EuG9FmFBJZhGN4ZuAW28 78joMi3eZi63n0uo1IJUMPTuX4xL6DOy9Xwp4swuKABrH/ajF43Jd5svceru784Aszv5 NubpSxOSW7IHNMkfV88rZ9k4OeFJ4CpmOjlhVhFyIKaYy2YJP2jgCEl5lpGdqHMqmQgP pgiA/cEOSH1IIhziQ4UCb31QdPccAieTrAWgTIUZ2v/HWjaMjE6ir0edNLPUg6u0KjOt KyO1SWyvuL97sRwn9Hee4z/7ziZcj80S0XwYWCUHR+NjK6X3YycncjzTjY51BCX3Rnhs FJ5Q== 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=GNK6U/WvuXK4SXU0wPhP4gevq0vBN26GKYSlu4X1K6s=; b=zh2MjFjqgpOn+opgJCkkjyj11Tee9SwaDWVKcVzLG6POF6Xuabtx36oKYsAFF0105Y UAjW9c9yvBievrGYzAD7ATIWXDGuIJXKHaxpjaUxWd+YVqUns77rIgWKj6V6+y716Meu tkXRAdLFsmO4UaoPIi/tvQDx28RKYXxZzvDmWesAoODazrLTtI0D7XkYltJs70TK6p3i tiMc5yKtkMAm5Wopt7tpr0b2muhN4pVnONEVdUzdJZC2x518f9rKvtvRbBca0vxfPhAp I2IIWHPLLQOu87+4j7HmJV9T8vSXa14QfH6k1olf9ddZiZU1hyfljU0C+FxFcEvrKjbG KGbQ== X-Gm-Message-State: AJIora+7KmxMxo4wufsqI+DrGhzC3XJ+eGSPfI1nYpUYEHKjZBeGCNoU 3ZBf5mrLNMLv2QjbonbKHjjVkZIU8bbsHA== X-Google-Smtp-Source: AGRyM1sHQNuYCrNGpUTVljd67vJymso+VPaR4J0FHDQ8FbLTWDBsdByxz3rjVx8ljRq2ZKX8OZbJZA== X-Received: by 2002:a05:6a00:ad2:b0:4f1:2734:a3d9 with SMTP id c18-20020a056a000ad200b004f12734a3d9mr12259241pfl.61.1656298932972; Sun, 26 Jun 2022 20:02:12 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:cf57:31af:7925:f9e6]) by smtp.gmail.com with ESMTPSA id s7-20020aa78d47000000b0051bba89c2bcsm5899378pfe.58.2022.06.26.20.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 20:02:11 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Jun 2022 11:01:58 +0800 Message-Id: <20220627030159.30730-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220627030159.30730-1-utkarsh02t@gmail.com> References: <20220627030159.30730-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 and Stop. Open state allows user to load a capture script. When clicked in open state present them with a QFileDialog to allow user to select a single file. Stop state stops the execution of the current capture script. Introduce a queueCount_ to keep track of the requests queued. When stopping the execution no count is reset and the capture continues as it is. Requests are queued with any controls the script matching the current queueCount_ Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- src/qcam/assets/feathericons/feathericons.qrc | 2 + src/qcam/main_window.cpp | 66 +++++++++++++++++++ src/qcam/main_window.h | 6 ++ src/qcam/meson.build | 2 + 4 files changed, 76 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 adeb3181..e133b618 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -232,6 +233,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; } @@ -255,6 +263,58 @@ 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 */ @@ -510,6 +570,7 @@ int MainWindow::startCapture() previousFrames_ = 0; framesCaptured_ = 0; lastBufferTime_ = 0; + queueCount_ = 0; ret = camera_->start(); if (ret) { @@ -789,5 +850,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 c3e4b665..2cdf7169 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" @@ -86,11 +87,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_; @@ -124,6 +128,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 Mon Jun 27 03:01:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16374 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 F3DA3BD808 for ; Mon, 27 Jun 2022 03:02:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 97DAF6563D; Mon, 27 Jun 2022 05:02:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656298938; bh=nJwrVPR4ZAlnfmWMTSQFRPq2klsrAV5yBzQQtDaVMjE=; 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=Wlw5aTfQcFyrO8yH9jAF+TycTZZLy/wbjX3vNNdGNWrsVTa7lB/f6c9ZYKNb1k4lS umRI+MFibFv0x14vB1sG/NT4VcBEdvU4rs8Jj+gqRaRNOuOBLorMB5zB1UNNhv3tZZ eksn4vOTXQoUJ24ARThrZRtYzmi5HxKk9gNp+epC+7Mj2w6Yka7ocYn5VJFKLrHySt 7cM1v0Ls2w4XSdbAlJz5Rxo2wOZ40cIZGherYdAefVM3Rv4LAphVrktJtM1hxZPh2J AE1ESx2i45K0eq0htJe6IBXZhS19/BaCWZry2TDs1geysihlAFeYO4T/iWAaj02Dfb BZTBDlTiXChxQ== Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8096D65641 for ; Mon, 27 Jun 2022 05:02:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JSTdbL0A"; dkim-atps=neutral Received: by mail-pj1-x1029.google.com with SMTP id g10-20020a17090a708a00b001ea8aadd42bso8133264pjk.0 for ; Sun, 26 Jun 2022 20:02:17 -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=wiQrIUZLI0w8Ss0m5XfMh2KHeapw8RY7kWyrjafNGrs=; b=JSTdbL0A/MJbgBjSXoOlohzqDJzrH9AIDJIjMVDsu2Ilxz1ebYrhGpBq50rMSIsk8q BoofUQJk0IW+Hg9tmJhZk0g9vFWhRnzOgL6O25JTJV1x6IODaOUvf+zh6oXRjR3Acy2g EDiIDqyZlwObt9s7MII4MFQ0vuTQ1fx/ZCofec/dWJs/r5mgS8Q6ePAfEHxKHp6qO4jn W4UQf/pOY0z4r5hTBd6DW1saBLz1f2qKF0NuqvjtSUlNuIjuzAEQxMUXLbXLeoo1axye YgXgjHujOtXyVoMoaQhNUELyhSxmLumpT0UOsxuPDB8b/z/TMJV5rvKOzhbfWq3RpOGe BpBw== 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=wiQrIUZLI0w8Ss0m5XfMh2KHeapw8RY7kWyrjafNGrs=; b=UA6lbclqx5uuAXjeJqI7lRpjv6eY7xRUZl0Rfloena3U24Z87xUQs4Fk5aw3ReyFHU B/JWpvDe1tMl6MOKPyA58Px8Q496XrwsXUf40dPYC8SLB4uzEgCpesIwGmXnO76UutI7 1oagXiAIrRn9viaaRs6C0fJ2C6ey8rVMgBw/SIeOw5er4hGELEI/wn9csNq9c9tGEfg5 rxUqf6p2jgkuo9QQJXsQznM2HlHE1wXhj3K56PfVNxt3ECX03l1regjoBduOP5mXhzRw XgucfVYlWGgWDP+/xED5kfjp7EN6QXv7xyoo9jXvfak9KO5xHzyj6GosiSGSI4r4sUJp +/YQ== X-Gm-Message-State: AJIora97CBVCoeajS0JqBIiByr6EaC6TiEn/nHTRHwSxFM5axomr1E6c U9urobZJPt7MfKozQZ7e7MR8yUO1TjrUFg== X-Google-Smtp-Source: AGRyM1vAFKloXMmH18K9g1uaFokSkfzk3hdSCwZdKF4cMNsJSIqbq2SvTGu1Tu29mHKvr2VI9OFvAw== X-Received: by 2002:a17:90b:895:b0:1ec:827c:ef0f with SMTP id bj21-20020a17090b089500b001ec827cef0fmr18040743pjb.10.1656298935770; Sun, 26 Jun 2022 20:02:15 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:cf57:31af:7925:f9e6]) by smtp.gmail.com with ESMTPSA id s7-20020aa78d47000000b0051bba89c2bcsm5899378pfe.58.2022.06.26.20.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 20:02:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Jun 2022 11:01:59 +0800 Message-Id: <20220627030159.30730-4-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220627030159.30730-1-utkarsh02t@gmail.com> References: <20220627030159.30730-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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, show error but start the capture without the script. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 14 ++++++++++++++ src/qcam/main_window.h | 1 + 3 files changed, 18 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 e133b618..8e6bde32 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -151,6 +151,20 @@ 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"); + script_.reset(); + } + + /* 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 2cdf7169..4d19ab64 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -42,6 +42,7 @@ enum { OptRenderer = 'r', OptStream = 's', OptVerbose = 'v', + OptCaptureScript = 256, }; class MainWindow : public QMainWindow