From patchwork Sun Jul 3 04:37:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16521 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 6D040BD808 for ; Sun, 3 Jul 2022 04:37:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B681D65652; Sun, 3 Jul 2022 06:37:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656823035; bh=Slu+O+fZW1w4jednfVozuSqsmmLjs5PiAl0EhrINfMU=; 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=yCdE0YcKuHqS1BO406ULif+RtSOg83/O0rX5LUercDpW6ZI1DNVL1PoI/E2LD1FFj Kj7/YLaEuph3Cz6luL6O/HZ3n0dY+4/luVlyfXo/1NgHxgbdcqFmqVnq3PT4NdEbwS Pp3G5wSb8Ld+t5Z+yKUWMnrKRtYPECacPz7RCuUjxrIVQmpTAN8i8XGFWxJqjRuxj6 +4HIxeKzSEAJ5YSJg9msK/Hm0/KIK8BTsezbD4IMFZbPKf6TjLmzGhHmh2TZPHFJ5l lQKG9+YB9MnKcURwsYN02qDvedI/C1dFeKzGW6Ci3cOI3ABXjw1F6qr5N+fVy3AFXo arQOlY3DLNgmw== Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A6EE56564A for ; Sun, 3 Jul 2022 06:37:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NsOHUnP5"; dkim-atps=neutral Received: by mail-pl1-x630.google.com with SMTP id l12so451297plk.13 for ; Sat, 02 Jul 2022 21:37: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=wDcETgwSinFLReuS0BeWAkYv37eRLN/VM7Si6XYDqn0=; b=NsOHUnP5fOTH+Vu00ea4Nt4iNn88uHWq8clAv9LfpHm92ZzRjjkhNYpLDLxPEbGuGJ r7MZpyt1/vpjDNbSyWDOhZOUzYhATAmnktv5EQFd0MInQTsNTkozEV0Mv8Ag+SeN2JpO 4kHMwDSfkA4TNI5EP0BydwxrgBJ4ib1Kna1eBdPZrcM3r0xiGBKmOro+VePvvj7hMOm/ bmmX2kpotSG5bGKLHX+yypHkmqq2ZkEaGjoxRr5lyIyW9606ZIn/HuQa4JjwVo9AOiwh lu2RjREKCG+vrUcA9R26plkXXCI/EPVOqTDw5Cc8PlCjyE+3qoJFABrPkMTWO9IlvW6v zRMg== 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=wDcETgwSinFLReuS0BeWAkYv37eRLN/VM7Si6XYDqn0=; b=mxiuu9F17K8KsWaZ/0CcvNheU+1R36r5VFbB1RYALI/9o4L3xMeh4CSV8PPOwQVvZC E1yhlqRAAVKNPBZa4QA6JUtgdseKw5mraT0qyoF+OL5LlOPsya+6o80IIoq6fMU2wB8L ToxomR1LL4uwlixZAD1UA5BLzN2wnd5fIf7a7WkLWjexELYrJSTm5YYus/Dy2+82BpLX dDnhKKx2C6o5rl/3XlyB2CJzGMnaxSyaf13f9A35JLGYcxIijgTlq+pqrtTbXdrjdGrB Kl+Sjk5NucA7qaBwcTiJF/kltJgjz09dVU6MRVudulYuWn0THb8Pi8pNCRrM2vCZ6Pdb DJnA== X-Gm-Message-State: AJIora+OVvwg9G1mRge94hBCAx0OikkBW9ty6AxYR8V8Nwh9lPRfDkrB TdVT8RhhvofqQoblIGfiGb7YJbyQhVktxQ== X-Google-Smtp-Source: AGRyM1t84bBwTKRtbknJpPQgMr5qi5r7kKVgfEWxv3g0lFXRvjSFA8k2n/zvfJKbmlrEsim2Zfh0rw== X-Received: by 2002:a17:902:ec89:b0:16a:2a7d:5efa with SMTP id x9-20020a170902ec8900b0016a2a7d5efamr30328820plg.114.1656823032858; Sat, 02 Jul 2022 21:37:12 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:2dd0:3b05:f874:d165]) by smtp.gmail.com with ESMTPSA id me3-20020a17090b17c300b001ec84b0f199sm12122299pjb.1.2022.07.02.21.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jul 2022 21:37:12 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 12:37:02 +0800 Message-Id: <20220703043704.296872-2-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703043704.296872-1-utkarsh02t@gmail.com> References: <20220703043704.296872-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Reviewed-by: Umang Jain --- 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 Sun Jul 3 04:37:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16522 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 DB077BD808 for ; Sun, 3 Jul 2022 04:37:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 88E3A65655; Sun, 3 Jul 2022 06:37:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656823038; bh=X1uq2aHaaMyMUojnYyUvc2Nm3lJtwbIY5pf7TGe+KnU=; 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=lcdWO9uW9tMURqwpc0XF8L2FLAove0q8tJjv5hw+5vxHqo7fy7cMMZ+J3BYHaBVCY Dlq35tFqTbR0QNdKY6nGSX5MuBIUBuM/eTObjLLb9s/M4TRpTWNVSrgFZ/V/30TIeO 0uFsdZyFcfvMoUyUQiOBWAEjQAN54QxRzDFVXBw3EWm5K0zrEZKGkdaCSEL67/MlMz 9sg/9tfXp7yPT3MmL9dtqOj3Ue9soNPAAUyoq/WcqgqysN6M0PGpszZWWT/0V9ZudW /86dfmP0AzzAyRXZ9jKwgp3eu/7ExAT+8AzNt2IbFoRIy97iVBZMc5xRntgb03c/hr YU9bWUBvoL7Ww== Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 486E76564A for ; Sun, 3 Jul 2022 06:37:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q+pqyfgw"; dkim-atps=neutral Received: by mail-pj1-x102e.google.com with SMTP id n16-20020a17090ade9000b001ed15b37424so6459072pjv.3 for ; Sat, 02 Jul 2022 21:37:16 -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=d4tP4UbnOJfRrStNi8hJIyptEW8NnX+spcZcVCNLeiA=; b=Q+pqyfgwEVBvbiitUvslMGG7dm0vVr3vTHq+k3/8y8PIiYgEdCnESseGrYdROMUHMu bN4MQpl7hlbIRYNv8aaxcKxaOqH1tzAKwZL89gXgkPSUuYiS5tddb/o2WaJqtSLpV+Fu +0nx1uaVTgDocupxpHGNCqMNLJnjCsvNsMTNp0WWJlFkomV880IdoHBUM6015sf6ZsZ3 h2r73gzCnOUBKZ+4miJniSluQ0zr7NLOuxwQrYcQecmr7WObP3YEQ14YM8EW4pJROgMo dwHm4tQNRCsO2Ur+ITjilppe2bWdb6Yl1cdARHdRSxrLeAl6WW/BnoTJ+hn4hHe4Deci oJgQ== 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=d4tP4UbnOJfRrStNi8hJIyptEW8NnX+spcZcVCNLeiA=; b=nYRkV+js5wRNtZt3IlyPnGp6VLTDO8wNheqs534sdS2bY2q4w47isxRvw2hLHWV4/l xT5xaZO78riKV2vHF3ypJ7SMjCBKMgqV0c81VxPgLuuoHyg1Z8TbqL31WTFw792GGFG8 kJLrTuLr9WNzX+QgEhFH6lB52yz+Nnc2Sg+lq82KUhMkPaOAIuAK6xZ3oRSz2aXMioaj GHzm8utwMA+5PHe2/Xk/U14L81OxdJ8rZvKY9WKj4kwJ/id3Y2vpZP9wX7Q/k0YLvJbY 0CtQ3SNIo+8ZKFZnsWY0zSMT0sQBkiVGnyk9y21abfGVqTt3GKXmTM9CAiMOLJKFyH5j PpCQ== X-Gm-Message-State: AJIora8h8QTw+FIxjCmErWQGoycyHm3n91NaoKPQy9t+wCiyCzOKjwx3 08SNy5FGz8CXGgFH0yWobmchX25ym/nQ3w== X-Google-Smtp-Source: AGRyM1vSzWL5bDVB3V47W6Ju7uqN+pp8LOQuNfoDOjswKUqELg56TwOeDBKBUZw3vIFAW/m+KVLE8A== X-Received: by 2002:a17:90b:3b4e:b0:1ed:2236:34f3 with SMTP id ot14-20020a17090b3b4e00b001ed223634f3mr27578524pjb.6.1656823034423; Sat, 02 Jul 2022 21:37:14 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:2dd0:3b05:f874:d165]) by smtp.gmail.com with ESMTPSA id me3-20020a17090b17c300b001ec84b0f199sm12122299pjb.1.2022.07.02.21.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jul 2022 21:37:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 12:37:03 +0800 Message-Id: <20220703043704.296872-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703043704.296872-1-utkarsh02t@gmail.com> References: <20220703043704.296872-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 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 adeb3181..4fbaeccc 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,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 */ @@ -510,6 +572,7 @@ int MainWindow::startCapture() previousFrames_ = 0; framesCaptured_ = 0; lastBufferTime_ = 0; + queueCount_ = 0; ret = camera_->start(); if (ret) { @@ -789,5 +852,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 Sun Jul 3 04:37:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16523 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 65B87BD808 for ; Sun, 3 Jul 2022 04:37:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 24C536564F; Sun, 3 Jul 2022 06:37:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656823041; bh=FEkCk9Mw+xcHC9gOxznTZzuYzbYKnZ7km1FsOOFVeiQ=; 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=T3xlXafp3YVDW2xoNp2f2934iu0HBel9eANWz/eismiK3wKvEFmStmVSsP7uJ0a9i 8DW2TASy3yPV75Dw8qgMCLU0bw+fwc0hIaz7judM2RBPMtHoACVkWoTapdp0tTo0o6 z0fd4yzTXWlrLnqX4ziPBpW7mDGGyDMN13w+58rd0TRergUyg/6iTVbQMLw1PmqXJz Dl7ZPVDyn8OE30AJ7bHjHFYlCMgpFkJMUPx0jRX9S0dOoUz0R66ONS30xfILnEg7WV 02qmZ5VHetk6v88Xlm82fL7ADQUjxFIxqw8TZiieYCE8BSJw3Yu6QJNPFbufKAY/5t c/8Pm5RphZ3xA== Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87DE66564A for ; Sun, 3 Jul 2022 06:37:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E4hSxFaC"; dkim-atps=neutral Received: by mail-pj1-x1031.google.com with SMTP id go6so6400771pjb.0 for ; Sat, 02 Jul 2022 21:37: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=SojkkV1KgZHtRwZYehZcIeNN0EHB8sfznzvDHI1YuLw=; b=E4hSxFaCHwRas0sZ+2PPjfHzUb5m0Zlha038lP1C3/nmq/Pyj+zOoE51fXCZL7oKO8 BnpzSeG+wEITyamufE7Ic+xpfxZ4aGyvbxvPX6qsRZLxwAAa4V7Z+PfsZituVd3BYdGZ DfL2WmbrSI8b9nUc/GQK8aDuFoSyVFFcR3YLf/M8D8+O9FgkG5qLnIqKENjboP6vwgvI Gvbl97PxT0dRpKNVqtWIDLW8MDFW9L5pqt7r8aSdty8HARoqZQasujpMa1Fut9OCfEyj 6V7urtl5wphOF+L7iWXeq2w+/9FV3q79z9LQVBp6Xs1fwgtlnLgDfzF56/r+m5GBqIP1 faLA== 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=SojkkV1KgZHtRwZYehZcIeNN0EHB8sfznzvDHI1YuLw=; b=avFCRBncy5hWKXB2Q8lH7fki23l9cs/vdcxjiftGI1egWqKguK+25t8pQwI1Wy3pSA SUMYftZFSc6hegVBQbK+AnqyFJ4XUcdkShwFdTspld6Iqufc7EZjFqMdF6dnfqCrk2B5 XdVYGfb79KfvfXSrAT0r35bNuXJCUQMbZR+Ljy+wuGQIJgx057za5kMujC7nx3OyfXTe Bz7/+QLe3A3mwXjVH8hXx9HWl4xutEfqUay5TCQ8Y7s4/KRsI0g2Rhq0oU7gIG7s/dW9 /D5LcpBoafv1oZJoFTMA7+0DlM0DNVDod/sD69gAmUnJDBzVDC0QtIXpNJXF+NpPB2tB YeRw== X-Gm-Message-State: AJIora8om+VottFDD+5rOjiw3KsXjc970tNKvzuABnUeK6uLb1RH12Av U+TisZheQdIDUAtRoAFA7z3JArI11lzUcA== X-Google-Smtp-Source: AGRyM1tjwyyN7+qasJmlN9rhbLsJsAee2J77T0gURl8Bug9nfSXX5SYrwXKoIHtHpKJE9fe+gKmquQ== X-Received: by 2002:a17:902:f68f:b0:16a:7a95:466c with SMTP id l15-20020a170902f68f00b0016a7a95466cmr28187165plg.86.1656823035921; Sat, 02 Jul 2022 21:37:15 -0700 (PDT) Received: from localhost.localdomain ([2406:3003:2005:1c27:2dd0:3b05:f874:d165]) by smtp.gmail.com with ESMTPSA id me3-20020a17090b17c300b001ec84b0f199sm12122299pjb.1.2022.07.02.21.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jul 2022 21:37:15 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 12:37:04 +0800 Message-Id: <20220703043704.296872-4-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703043704.296872-1-utkarsh02t@gmail.com> References: <20220703043704.296872-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 4fbaeccc..7ec53a7c 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