{"id":16205,"url":"https://patchwork.libcamera.org/api/patches/16205/?format=json","web_url":"https://patchwork.libcamera.org/patch/16205/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220613060345.229191-3-utkarsh02t@gmail.com>","date":"2022-06-13T06:03:44","name":"[libcamera-devel,2/3] qcam: Add a GUI way to use capture script","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"67ceebd62204c5a73493f195be75641160ff548d","submitter":{"id":114,"url":"https://patchwork.libcamera.org/api/people/114/?format=json","name":"Utkarsh Tiwari","email":"utkarsh02t@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16205/mbox/","series":[{"id":3171,"url":"https://patchwork.libcamera.org/api/series/3171/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3171","date":"2022-06-13T06:03:42","name":"Introduce capture scripts to qcam","version":1,"mbox":"https://patchwork.libcamera.org/series/3171/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16205/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16205/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C6854C3273\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jun 2022 06:04:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B91365638;\n\tMon, 13 Jun 2022 08:04:06 +0200 (CEST)","from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com\n\t[IPv6:2607:f8b0:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0CAE865631\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jun 2022 08:04:03 +0200 (CEST)","by mail-pf1-x42a.google.com with SMTP id e11so4871005pfj.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 12 Jun 2022 23:04:02 -0700 (PDT)","from localhost.localdomain ([2404:bd00:3:d6be:8959:67fc:32d7:74a0])\n\tby smtp.gmail.com with ESMTPSA id\n\tx14-20020a170902a38e00b00161478027f5sm4087908pla.150.2022.06.12.23.04.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 12 Jun 2022 23:04:02 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655100246;\n\tbh=S272PG9khK2UdLsS/+qtNUrA8EW2d0ahIV16iv7o/oA=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Aasko7P4FavVZSkZb81+wLfuDCu9id6OVlegHIhugXk8W9AhM+wqaEb+32W7xJOGe\n\tq/F7MHxGAkFv5k8mXMpqQ2b2QHMG8id0DzwHH/2KHqmzH97H2yfoAo/UhkkJAHl1dh\n\tczlFHk44NvoZvgmfBEruza75XeuIte1WTYvyyaB2mVr3kg42BpHps9e2WfFpsC3QI1\n\t+Z8qobVNXf5B732/kD6EAZgfHavmsSh6Z6bhE4n0KYgrjtTvSSPOTuhvMjCAFSgZtY\n\tItN3DkW5SARvaF29dUYl+Jasc5EJJ5fNaUtC66zZpKOtPPpXu+fwdY4X/oEjnPKAAL\n\tRX4lI/aq1sOpg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=wWnX22DgtmEKWHKuXNpIM1KRw7Bkk844LDOVXAf7urQ=;\n\tb=gDVgpKVi01ZOggbwltQ1JoJVNGKDqfz1r5moVG+wEq0rQ4jpbGvu8oPwIlMs9K9Wt/\n\tiiQbdhHv4O6VXy4W1iz7OIRGn2DFlnsi2IEd+nmB2Lly0R8oIU7AjR24XgLJ4UJ5ZbRK\n\t9bj42cEWZLnMFtOuFQ4Z9ZU0RPEr5IzKxt225yY/B3f+i+P6fvwLXpRJFUthhgG70iyW\n\tubSt0TI1TnyXb3QYN4kyKoSd2MUryjgvxOPcnyj1w2Z7JJsUx3dSLyByFk00QkZbWqJo\n\ttaHDZkRRwo4EqUZk0iXZaNtdD2VXCNrYK+zLIzEx6TjhJg2lOWgZmSG0e9yC81MNnB87\n\tE4Zw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"gDVgpKVi\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=wWnX22DgtmEKWHKuXNpIM1KRw7Bkk844LDOVXAf7urQ=;\n\tb=kTGqgGiEG9smhfOnkb/7xEpl9QAaF01xF5xLo09qZD0xTHm0qSGy6X6WOW7osHVOLP\n\t9w06TfSpq5HYkxfibEAgHoIey7WSykh8cYDEzf5LNOylNNuukxBAURvhlMD0lxxKNSdN\n\tiCNuAAOZKfpfNrNbsAM8Dw6AFU27j1qRvEK+kDoyt0GWRXlHmU4giAjN6NxNuE7i7LB7\n\tx/ElUMdyWIzmEK3b9vLaerSApD3yRCb4GfvvaMRXBd31j3EHNoP7mTP41ygJmqbKVgSb\n\tqU87sMRnIdCPAgEJUfPV5cRWzVyZeT4ShyfIqvrU6EeH+IBAYEGzR0G4dV46ngEmyoao\n\t0O9w==","X-Gm-Message-State":"AOAM530Fo+an7l9KAWUVJve22AdIk3UMR/27l+FHhIrUrwHxq6fvYez6\n\tmnndupOvoQQBjDCJZjFwYItCTYkxExM=","X-Google-Smtp-Source":"ABdhPJz2klRjpGNY6wNHUQIDZyAGjEtC02p4eZ9fQ4V6VK+Hk4e1JAie6FtQeSTRqrW1L5B+SqmVUg==","X-Received":"by 2002:a05:6a00:1307:b0:50d:b02e:11df with SMTP id\n\tj7-20020a056a00130700b0050db02e11dfmr59124477pfu.4.1655100242337; \n\tSun, 12 Jun 2022 23:04:02 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 13 Jun 2022 11:33:44 +0530","Message-Id":"<20220613060345.229191-3-utkarsh02t@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220613060345.229191-1-utkarsh02t@gmail.com>","References":"<20220613060345.229191-1-utkarsh02t@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/3] qcam: Add a GUI way to use capture\n\tscript","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Utkarsh Tiwari via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Utkarsh Tiwari <utkarsh02t@gmail.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Implement an Open Capture Script button which would allow the user to open a Capture Script (*.yaml). When clicked present them with a QFileDialog to allow them to select a single file.\n\nIntroduce a queueCount_ to keep track of the requests queued.\n\nInitialize 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_.\nThe queueCount_ is incremented after the getting controls from the parser, so the first request is for frame 0.\n\nSigned-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n---\n src/qcam/assets/feathericons/feathericons.qrc |  1 +\n src/qcam/main_window.cpp                      | 38 +++++++++++++++++++\n src/qcam/main_window.h                        |  5 +++\n src/qcam/meson.build                          |  2 +\n 4 files changed, 46 insertions(+)","diff":"diff --git a/src/qcam/assets/feathericons/feathericons.qrc b/src/qcam/assets/feathericons/feathericons.qrc\nindex c5302040..f0d1e3d0 100644\n--- a/src/qcam/assets/feathericons/feathericons.qrc\n+++ b/src/qcam/assets/feathericons/feathericons.qrc\n@@ -3,6 +3,7 @@\n <qresource>\n \t<file>aperture.svg</file>\n \t<file>camera-off.svg</file>\n+\t<file>file.svg</file>\n \t<file>play-circle.svg</file>\n \t<file>save.svg</file>\n \t<file>stop-circle.svg</file>\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 5ac31d9a..7cdb1238 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -20,6 +20,7 @@\n #include <QImage>\n #include <QImageWriter>\n #include <QInputDialog>\n+#include <QMessageBox>\n #include <QMutexLocker>\n #include <QStandardPaths>\n #include <QStringList>\n@@ -232,6 +233,12 @@ int MainWindow::createToolbars()\n \tsaveRaw_ = action;\n #endif\n \n+\t/* Open Script... action. */\n+\taction = toolbar_->addAction(QIcon::fromTheme(\"document-open\",\n+\t\t\t\t\t\t      QIcon(\":file.svg\")),\n+\t\t\t\t     \"Open Capture Script\");\n+\tconnect(action, &QAction::triggered, this, &MainWindow::chooseScript);\n+\n \treturn 0;\n }\n \n@@ -255,6 +262,31 @@ void MainWindow::updateTitle()\n \tsetWindowTitle(title_ + \" : \" + QString::number(fps, 'f', 2) + \" fps\");\n }\n \n+/**\n+ *\t\\brief Load a capture script for handling the capture session.\n+ *\n+ *\tIf already capturing, it would restart the capture.\n+ */\n+void MainWindow::chooseScript()\n+{\n+\tQString scriptFile = QFileDialog::getOpenFileName(this, tr(\"Open Capture Script\"), QDir::currentPath(),\n+\t\t\t\t\t\t\t  tr(\"Capture Script (*.yaml)\"));\n+\tif (scriptFile.isEmpty())\n+\t\treturn;\n+\tscript_ = std::make_unique<CaptureScript>(camera_, scriptFile.toStdString());\n+\tif (!script_->valid()) {\n+\t\tscript_.reset();\n+\t\tQMessageBox::critical(this, tr(\"Invalid Script\"), tr(\"Couldn't execute the capture script\"));\n+\t\treturn;\n+\t}\n+\n+\t//Restart the capture so we can reset every counter\n+\tif (isCapturing_) {\n+\t\ttoggleCapture(false);\n+\t\ttoggleCapture(true);\n+\t}\n+}\n+\n /* -----------------------------------------------------------------------------\n  * Camera Selection\n  */\n@@ -510,6 +542,7 @@ int MainWindow::startCapture()\n \tpreviousFrames_ = 0;\n \tframesCaptured_ = 0;\n \tlastBufferTime_ = 0;\n+\tqueueCount_ = 0;\n \n \tret = camera_->start();\n \tif (ret) {\n@@ -789,5 +822,10 @@ void MainWindow::refillRequest(FrameBuffer *buffer)\n \n int MainWindow::queueRequest(Request *request)\n {\n+\tif (script_)\n+\t\trequest->controls() = script_->frameControls(queueCount_);\n+\n+\tqueueCount_++;\n+\n \treturn camera_->queueRequest(request);\n }\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 251b8335..cde5842f 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -26,6 +26,7 @@\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n+#include \"../cam/capture_script.h\"\n #include \"../cam/stream_options.h\"\n #include \"viewfinder.h\"\n \n@@ -86,6 +87,8 @@ private:\n \tvoid processHotplug(HotplugEvent *e);\n \tvoid processViewfinder(libcamera::FrameBuffer *buffer);\n \n+\tvoid chooseScript();\n+\n \t/* UI elements */\n \tQToolBar *toolbar_;\n \tQAction *startStopAction_;\n@@ -124,6 +127,8 @@ private:\n \tQElapsedTimer frameRateInterval_;\n \tuint32_t previousFrames_;\n \tuint32_t framesCaptured_;\n+\tuint32_t queueCount_;\n \n \tstd::vector<std::unique_ptr<libcamera::Request>> requests_;\n+\tstd::unique_ptr<CaptureScript> script_;\n };\ndiff --git a/src/qcam/meson.build b/src/qcam/meson.build\nindex c46f4631..67074252 100644\n--- a/src/qcam/meson.build\n+++ b/src/qcam/meson.build\n@@ -15,6 +15,7 @@ endif\n qcam_enabled = true\n \n qcam_sources = files([\n+    '../cam/capture_script.cpp',\n     '../cam/image.cpp',\n     '../cam/options.cpp',\n     '../cam/stream_options.cpp',\n@@ -37,6 +38,7 @@ qcam_resources = files([\n qcam_deps = [\n     libatomic,\n     libcamera_public,\n+    libyaml,\n     qt5_dep,\n ]\n \n","prefixes":["libcamera-devel","2/3"]}