From patchwork Wed Jun 22 13:16:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16318 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 80369BD808 for ; Wed, 22 Jun 2022 13:17:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2E4506563A; Wed, 22 Jun 2022 15:17:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655903847; 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=DJ7RWXkBTzzdTBhiM0Cs2+F5XQYM+c7QfeWRWm3aJ1rhofMnfn4pboQ+wiywZ4TSB AxEFSe3drP9e1+SWBSyOGX5LUQQntOfowTbP1pc7nYoSY+pZBhznnLk5fQafGnAdDG 2Hm4Azah2UietihCbboSUrh866vQqoFmx6NRZX6c0f9BeUzdPic3BfEMUuCsFZC/71 SR5dIsgBduT/gkYQj1kedOtLP7TwDmC9xpz186g9LWWKlbbqlNHk74QjC4VybjYmYH fEBVkiFhlcIGN0P8I8G82qD+Z1kyEbS6GvRAVtwpgNYU4zKYgeKkp7e6q0wbgyVYfZ a3LjCrpt6m8gw== Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 44BAE61FB2 for ; Wed, 22 Jun 2022 15:17:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ps0d5oe2"; dkim-atps=neutral Received: by mail-pg1-x531.google.com with SMTP id 23so9912475pgc.8 for ; Wed, 22 Jun 2022 06:17:26 -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=ps0d5oe26rNZFXb0d+J0LdAjfF4PI1DmBb/Mp4up9QcN0kJGQt5dQCusEdKX/o5BNU ghcR+OerDpXSl7pExx+giez0wzguKQ9uZ+gsqU9dMKg4pUWL1Rc5nPeuWtalHi64hRFY ulgAjJfGXmQre3CdlQLKC+StJSOupp1qY3efBNvCzCdCzJors8xrZKi5O1dePSdenWks e53h1ZitwJpO8XT5beNif2vlGcDuZ/+7gNDxqaBIHhRG5qZ4pZws1iGXpyztiK5zFp+P pcoNRoxF0tqVX2hCt5YL3w63bEpAJYyDSOQJ/xhWQp08ZpIIyVczbekmpUcV3UMTGrgj fiFg== 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=ib8IUlrJJ31+mJN9FyZbMNxsuO6duJ7L+bBYjzRwk2zkqwKr8wBIWx+z72M4dV1Rzj rZezMKmiqI4byG0N1atL7NAWtK/kW8gyLssGJPquXG23Xg3AyoA5fM6EYjEvRYGKo4nH KBiQLTkSXeGpEJJbVTDKnapg9pnQ3q44WtUMeECxl0Zf4gyWnzzoRkZaOJAJ1VAghvGj o8aJwXyxGfCIl2/12w8xbOFPJX80XMXrkjf8ianXHqzx/+QgNEotDdDdzxL1bFroIqQ1 IDFT4KARAamXSIgknkuuDo29ux/AX9uDFnZmEustV+8QOFgVxPmko9tKO2EoUycG0EWJ tcyA== X-Gm-Message-State: AJIora+nYW56+SuJvb2c3/NVQXRt16cwOmcaOxj0cZ2ZRJdoD3nU4b9s nZL9L8Z/49mDedLx1wzd9rwIS4Jzc0E= X-Google-Smtp-Source: AGRyM1u0N8h03VohKHxkGbU3dHurk20+9VnnBIP3Cy5Z48U0C51bVl4uOBK6aTO7vdiLDb7mx9ueLg== X-Received: by 2002:a65:6a4f:0:b0:3fe:9ef:1c49 with SMTP id o15-20020a656a4f000000b003fe09ef1c49mr2904086pgu.229.1655903844732; Wed, 22 Jun 2022 06:17:24 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1f6b:fd12:eca1:fe45:bbdb]) by smtp.gmail.com with ESMTPSA id x82-20020a627c55000000b0052089e1b88esm7124540pfc.192.2022.06.22.06.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 06:17:23 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Jun 2022 21:16:36 +0800 Message-Id: <20220622131638.79122-2-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220622131638.79122-1-utkarsh02t@gmail.com> References: <20220622131638.79122-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 Wed Jun 22 13:16:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16319 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 F3D17BD808 for ; Wed, 22 Jun 2022 13:17:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9FD2F6563E; Wed, 22 Jun 2022 15:17:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655903851; bh=/PA8YHABfHDJNX1mLlcQY3k6LKfuswo8x9H9/wnml7o=; 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=jZ+ewN5KHJdY7X0CJd5QxLQIkTyJLnG7bcCPQfvRjYkI7bjA0b14DTnSZmcxRDStP k4gwWMFpU42PoBdaCqcOdaJmbinPWbxrRVqF6aGqL8keOIzEv0ko2EeA10x+Kg37RK MbOxw3uVpi77/TjeMC0q0IIsPKVzhwQKCouzIYr0p78l8vrSdxjeZ8WZkOS4tTEqEh cKicCmAbeUpCllh4C20vS6pMiXSZrgIWreVuMTT9cI7LRQ3nRhAwtuXhr/kOOK6RlB DNuKCmTMgvmvsQc24d2R/xn+5yAGNoejyEVqQnCFUKCJlV0iDgoUehr4tRcFKwcD0J 2zGOez++0ktgQ== Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B165761FB2 for ; Wed, 22 Jun 2022 15:17:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zn70NR76"; dkim-atps=neutral Received: by mail-pg1-x531.google.com with SMTP id s185so10336186pgs.3 for ; Wed, 22 Jun 2022 06:17:29 -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=xkf2q1NPqU5B59rU94nWkF8pe6fEleUpU2eY39SlwBs=; b=Zn70NR76UTBPuVB+uDivmSblpdpJPaBxLNRc0Q9qo5Qos8I9ATpKohCkB8H8SYqiZP Wykaa7niTrMcLZLaJ8sULkXRDhPR0DsW8HMajKUo5oYdC+mdP4lnW8KWdcV7NqmZ0h6r SA9XvWg+ZwMTq+OaLlhmpgLZk8Vfwbva5vU54zgQbjZ6YPKlrTENF7IYpNZVQHDyVo2P vjbHQw5W7tao3pvgG/J1fsKqM/lUBtcekEeqnSekuexrJPp3OLapYmbkHDZMB8IlMvoj 1kk7u3vpe/HKxjJN3PSq1EChDyr8GZ6nfbF+/LEytcbNJuuzYCnZ+4H8Yd1yaSACu/dS aSHg== 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=xkf2q1NPqU5B59rU94nWkF8pe6fEleUpU2eY39SlwBs=; b=Vttg2YY58fA0//KEeITr56gFJ0YOBjbiN0MBcfPb6hAjNwPmCu7KNOIpVS9sMuXzgO VYmxAl8Drxrxgbz9NN8ZSYAHWTQMLQt6u8smiptbtzKvORrgT9L1fGSnRdQEQOKzsqGU BW+l0Mce0sNUca3ypf2HI/ZTgXKg8vqDItF09AbpKWxPaQeYCl/N2osSQM/1L52u39Do CCfOoNi0tvjM+UvbzcTPdd85ubDHJ/Yq/Eb72Z7G7p5VKvC0tclLjU7gdOZwYvHPDLk8 WXehNqoIC873qF1G20ocq/re+9VGpy0hqJM1V6zoyfpm+BYxT3osOmFrl/W1WFbc4/JQ BEVQ== X-Gm-Message-State: AJIora/rMLFTXdMniy0OfQKuSx75Km87xDWNaTjkzGxSnpOX2DH80HWK Tizgc1tjYwS8ATmXnpSTOokvlCXL2Xs= X-Google-Smtp-Source: AGRyM1ulXiEdjqPsJadFOVCJKk5y3wxryc/jBkh/JJR9PWXef64cZtq1pnoMv/K4Us3XsfTOgaIz5g== X-Received: by 2002:a63:8949:0:b0:40d:44d6:423e with SMTP id v70-20020a638949000000b0040d44d6423emr24782pgd.525.1655903847771; Wed, 22 Jun 2022 06:17:27 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1f6b:fd12:eca1:fe45:bbdb]) by smtp.gmail.com with ESMTPSA id x82-20020a627c55000000b0052089e1b88esm7124540pfc.192.2022.06.22.06.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 06:17:27 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Jun 2022 21:16:37 +0800 Message-Id: <20220622131638.79122-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220622131638.79122-1-utkarsh02t@gmail.com> References: <20220622131638.79122-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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, this would allow better testing as we can stop in between script and observe. Initialize a Script Parser instance when the user selects a valid capture script. At queueRequest() time if script parser has been initialized, then populate the Request::controls() with it at queueRequest time providing the queueCount_. The queueCount_ is incremented after the getting controls from the parser, so the first request is for frame 0. Signed-off-by: Utkarsh Tiwari --- src/qcam/assets/feathericons/feathericons.qrc | 2 + src/qcam/main_window.cpp | 61 +++++++++++++++++++ src/qcam/main_window.h | 7 +++ src/qcam/meson.build | 2 + 4 files changed, 72 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..29da3947 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,53 @@ 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 (isScriptExecuting_) { + /* + * 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"); + isScriptExecuting_ = false; + return; + } + + QString scriptFile = QFileDialog::getOpenFileName(this, "Open Capture Script", QDir::currentPath(), + "Capture Script (*.yaml)"); + if (scriptFile.isEmpty()) + return; + script_ = std::make_unique(camera_, scriptFile.toStdString()); + if (!script_->valid()) { + script_.reset(); + QMessageBox::critical(this, "Invalid Script", + "Couldn't load the capture script"); + return; + } + + /* + * Valid script verified + * Set the button to indicate stopping availibility + */ + scriptExecAction_->setIcon(QIcon(":x-square.svg")); + scriptExecAction_->setText("Stop Script execution"); + isScriptExecuting_ = true; + + /* Restart the capture so we can reset every counter */ + if (isCapturing_) { + toggleCapture(false); + toggleCapture(true); + } +} + /* ----------------------------------------------------------------------------- * Camera Selection */ @@ -510,6 +565,7 @@ int MainWindow::startCapture() previousFrames_ = 0; framesCaptured_ = 0; lastBufferTime_ = 0; + queueCount_ = 0; ret = camera_->start(); if (ret) { @@ -789,5 +845,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..58df4e15 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_; @@ -112,6 +116,7 @@ private: /* Capture state, buffers queue and statistics */ bool isCapturing_; + bool isScriptExecuting_; bool captureRaw_; libcamera::Stream *vfStream_; libcamera::Stream *rawStream_; @@ -124,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 Wed Jun 22 13:16:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16320 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 85217BD808 for ; Wed, 22 Jun 2022 13:17:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C1FA65640; Wed, 22 Jun 2022 15:17:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655903856; bh=Hw0bTFcArbGH3QjhfHrHCqlJeBV4ipe2g8lAthiGb1k=; 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=DpUI/uFuRljRoF7tbjGw2XYsnhRWRCKj3NWZlenwG4Lh5nCbL5X8jnK2REFLJ2yVD KrNytZs/fKecA/WYJWPxnSORAjrdfGvyW7aLP9oZeOcP4lxkYIiRrqvLcY+uc8vZE/ iLVxPjEoQeJOr9uQhNFJJjFgxJie8K15cWcljfH8oQgG6dx2BARhUMPbJX4DzuCQX/ qsDb0v+D8QYPHtVX8GvhiwVeVsssJgXQxWHnW2B2YZNh9d4zEyl0Al+znKMLkNAPgi rm/0vxAhnCEzAel+Je+qz7QBduB3bSXElbFA57zR+HyWqlptM3rkBn5s5GyRNEQQmk 6w408YrtgVAYg== Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A8B9465639 for ; Wed, 22 Jun 2022 15:17:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hzSLmeCA"; dkim-atps=neutral Received: by mail-pj1-x1036.google.com with SMTP id p5so10189317pjt.2 for ; Wed, 22 Jun 2022 06:17:34 -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=38Yvl/pHFg1W9hkWxfTar39nZsC/yR/GGyBTgoF+ELU=; b=hzSLmeCAptINCXF9zdMnqgywQrFegP5kIR0fJ3bzddbrG4wDQchNGSAGca6wuL/0zk 4FZnxWsJ32if4LBF/iHHpYSE8iv//SD6u7Dsn28DtWZjtutLtEprBEpGhULv27uRyiDD XEiJQv3DzdrUpQHUF1yh8qHFRBQ6Of2xJDWoP2N7Al6NyPfr6F772zpw6D+lIbEMtYo/ MSEHrLYijR65TJ28o8mcSs2VubVOtvTyUJ3orQTzJqvzZeb8gOjfy3JOvUAhAERfL+8W DAo8oD5XxVHBXDI69yI+fRvNQBhitGLv5cL597G6Be5YAYAOrOVmFtyEeRHzqKv2G9z5 ej3g== 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=38Yvl/pHFg1W9hkWxfTar39nZsC/yR/GGyBTgoF+ELU=; b=YTeUHhm2Qdx3pQcgALjpswzmjL/XRvqgKpYZuhHc51V6IVXjRB23HyttVyhBXSqjFd mwa0Eo2An2/53SQaD7z5qzrVflW1n3kKtGVxOuW3pZa23zGDLBG8h/k000rEFwP8kGgH iKcCKhOoHEjjU/cNX5NSWiqgDVtBAoaxAZnSwn2bZDLumRRyCGVZ/NXyfJv51lgVHdCv Fcu/fh44XLz6lUAKbEtK+9Ice7jGUFIOvC+rWCz8McRYb3DtP53MG6J5BwD7t11b3/1g lClg3u1IhtMWvq9Cyr4GtJlFfHG+TejR/P8h0rdibjBcBDk6Uw5iATIzycOplxqe2ulo Kg5g== X-Gm-Message-State: AJIora8JqufRAwBPCIP7e9o6IPaHOfEQObjAj+6V/SyrvFXWUqr4wQPR ZT5dYMHvL9PRRDrEi933ScHII4JCsYM= X-Google-Smtp-Source: AGRyM1vyL8wfemJG+u8QRY76RaOikAmLP63AOMBAGC5htslmWtld3UEvhDNcG2BXUDOWt1P+I9Rdew== X-Received: by 2002:a17:90a:430a:b0:1ea:e7f4:9f59 with SMTP id q10-20020a17090a430a00b001eae7f49f59mr3704238pjg.75.1655903853067; Wed, 22 Jun 2022 06:17:33 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1f6b:fd12:eca1:fe45:bbdb]) by smtp.gmail.com with ESMTPSA id x82-20020a627c55000000b0052089e1b88esm7124540pfc.192.2022.06.22.06.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 06:17:30 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Jun 2022 21:16:38 +0800 Message-Id: <20220622131638.79122-4-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220622131638.79122-1-utkarsh02t@gmail.com> References: <20220622131638.79122-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 10 ++++++++++ src/qcam/main_window.h | 1 + 3 files changed, 14 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 29da3947..17cc3185 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -151,6 +151,16 @@ 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(); + } + } + startStopAction_->setChecked(true); } diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 58df4e15..1b4a4fd6 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