From patchwork Sun Aug 7 20:32:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17019 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 2E500BE173 for ; Sun, 7 Aug 2022 20:32:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB0EF63329; Sun, 7 Aug 2022 22:32:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659904343; bh=c4VuuPECAHqtJT0jZXC2FUT3ZP7jseExejACAso5SdI=; 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=2AjKtwU9a4+Qy+v0QDn+eL7HPXgbR4uza8xMIyjm6284Or4e6iZOjIs9Yo+7SiYhT 9hHtHsYGHnB1q8o/WBcQMgh+2+gSUl59aiaQYc8wRpV0Wf/tnJV6mXaaCWjfC3Rlvt 37PFwwYsY5IVsMrtNr6hkv40BDCRClb9ntpRL/tzN+X3vUAunzG1JscI8fEoX61hy/ I8FHfIiSJl7qYH2AijY+dBixtRlYOV2WsUybJtnX/C11TNx9SWM7ry1zImEm76VQDu Vl218CBBCF28PS3W3hH92fJcojsqcPTMKJOeO9Zfq/LWjL9cASx/Pe4I64BcZNVswl 1pphgihSZF+rQ== Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97F4463327 for ; Sun, 7 Aug 2022 22:32:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n2q9B0To"; dkim-atps=neutral Received: by mail-pf1-x430.google.com with SMTP id k14so4502609pfh.0 for ; Sun, 07 Aug 2022 13:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=1BAur522nDly0wmsL7dBqSiwB12eYFtaaqg3Af9dIEk=; b=n2q9B0ToNkbzUsEf2cGg25IGvU0FT3BMOIy5dIgbrEWi1NLTRcHbT2Xgd1ZiLdJkCM w2uegcMa5Zr2bUzyhjIkJ7g1CSx8aReyh+T+eRzxCsyoMS/PneU5gbLN+OxZ7NC76q2f jjLeHt5ROh80+tDg3gQuRdkANPLeoEITg1p9yuCnhIIpwHl9Zv5IckC3I2YIwC3ulXg8 4HWDPu+CaX0HlA5mL3o+5s8hmwpPsSKpXm6PEeUe3I6AUJz8qPextkjxZ74YfHhOmUso PWcSVW5/XXvdLFH/2y6ydo5y6kfmfZMGHp4FWpU4GvSO2ywthaUUUijgF9vReK7zoYFz r8+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=1BAur522nDly0wmsL7dBqSiwB12eYFtaaqg3Af9dIEk=; b=Fue6DYMr0wNC8GbT7Xzrsm9tJFalIaZlSnVUZhNVHCtdiLa3gBibG4EsJEqJO7yu7Q bTY81IczDk/OSsGYdUE67QOzqlK97UBLANBZCxH5Dhv1MtO+nrkR8SnbpSzFGBj7YB6C ry6J/h6FRwSv9LA+TnHWK/Dqsy/BgVjrQQhCYVdjG+C8qYPY021J1XxJkPK3NRGl5uIN Ul3JSkwN1WJ05RcwN8y4zMqeX/Jri+HR+0zwVmu8KUjL+HiqI3lbEC8S7qgX9WOacOAF 3lvvHwSvSp0MnN9vYenNkYFMt4Wnbg/YCt6iQIIZ0Xypt1Zl6IWJZCE5l5okhElSGY/P JfXg== X-Gm-Message-State: ACgBeo13ssapx+6Jk2usLH9w/JbFu3fs3v+MieRuNOaZtXAfyyd/yg0g RYLxvh/yz473k7vh6xIGUrDEkEQRoxw= X-Google-Smtp-Source: AA6agR5WFh/bDOLdxeZzjIfcFpHonFrF6sNDrSssfonQQtR7hnwjIxOozkJRQD3P5XKuVkS+JY2f1A== X-Received: by 2002:a63:f54:0:b0:41b:a215:cb4b with SMTP id 20-20020a630f54000000b0041ba215cb4bmr12849699pgp.529.1659904340754; Sun, 07 Aug 2022 13:32:20 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:8eec:115d:8ea8:b700]) by smtp.gmail.com with ESMTPSA id x29-20020aa7941d000000b0052d194a6602sm7006334pfo.102.2022.08.07.13.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 13:32:20 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Aug 2022 02:02:01 +0530 Message-Id: <20220807203204.152358-2-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220807203204.152358-1-utkarsh02t@gmail.com> References: <20220807203204.152358-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 1/4] 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 --- Difference from v1: No changes 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 98c22b71..549af024 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 @@ -515,7 +515,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; @@ -749,7 +749,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer) viewfinder_->render(buffer, mappedBuffers_[buffer].get()); } -void MainWindow::queueRequest(FrameBuffer *buffer) +void MainWindow::renderComplete(FrameBuffer *buffer) { Request *request; { @@ -778,6 +778,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 fe0f5938..7982939e 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -70,7 +70,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(); @@ -84,6 +84,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 Aug 7 20:32: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: 17020 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 8F029BE173 for ; Sun, 7 Aug 2022 20:32:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4D57763331; Sun, 7 Aug 2022 22:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659904345; bh=ZKxp1KsJ4mvRmllU7wUk04TZnWO1Vjh4fMSlg/VQkw0=; 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=AhrUfwKldXWKqzsyg7YqszkMcAiQy5O+/L8Yt3OtIl96+/YoeIkUhzm7MlSPIY0Sn sJzQJDfjF+ho6ycmMNCaUmfc9Gn290GeFQOURqeH8tdfXoOA1QviJfi69h75yx8tql nBn84MsrI1xNRc0YXU0utuNdEXzjmkjx0csplY/3UtdKbvqFpX8YXVyDIMJyYdJO4j rKUlKILooCwPk1oRxq7bQxV7Vv+ZhPU2uN6AisAUIiJGDD5cLFJ/dIV4+/xyn/ILWe 71/xiPhhyK0AuLzOG0up7lB0CBb+M9l0/u2gWP3raKJtD2qImYjGAekUttKXlkOub2 q0FHMK08F15xQ== Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8142E63327 for ; Sun, 7 Aug 2022 22:32:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZIjgJjPm"; dkim-atps=neutral Received: by mail-pf1-x42b.google.com with SMTP id z187so6495598pfb.12 for ; Sun, 07 Aug 2022 13:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=qavyrCFTP++VA/WS4m58ciqEI9ghwGad3JE3DUvPKRk=; b=ZIjgJjPmRVpz78lKANhJu9O9VZf/0K8TBWx+SQUVnstNrLo2vOn6lKnki5+ZkebhLO UbwLF8M9cHBwsYUGmfnXhOsgrJ2auxqsjhQ2z/gqb5EkcUEVFIW5sJTMAmRYVOHrr4hi /dH8hkZsng63nZ0UdzE3ET63UQDhHNHx0BN4WUzMryrwUCVc7npSByAFpQFVstIEpIBJ 2ajOZ6gJDjGDkRvRGCTJjhLK+frm5R9YhKVZnkQQBLyALG7XncddJHk+CFNT31EkzSFg SR5Brw565s39iUbjmdEbgj3JI4XVYH6zevs3BDPAnXqVI3G1otHQcDB8MIp294B5tIL2 MtlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=qavyrCFTP++VA/WS4m58ciqEI9ghwGad3JE3DUvPKRk=; b=HsP2sl/Crfp6sSpk5MgCfKx0b/Plutv0hpEJigdwCpisS6oO7vT6H/SSOmLppVD60G pLHPYBBDc9Ypev/rPSjBaVfzF9bh/6U8GKKBLd8q67+Eycd1y8ij4CwGE5OuaXMrj95P g0CIphwD6FIkP84PKXLw7pGDvMvYxz6c+9sy+Tx/nMYl603js+eRPKwaXAf8TO0TT/YF YSgyL2foJ2acDgLcNWsrArX7JdB5oxiP4cLGYVc3qBFv8ENzXTTewogwGt6Hjv9I0Tq3 2K9XI8sy49YA/YbumSj3twa0t1Dlz6Kse/n0968MDrPbwhmT4xZNav/RSPnQ+55KxImP 97Jw== X-Gm-Message-State: ACgBeo2CIBf3DOCntFiP6SjYh0VQ/7VK1v1tDk0+Aa12BPxELrwvuO88 d4wzwdFt4FAGxviPdtybulP6PICK8GM= X-Google-Smtp-Source: AA6agR7wP3liw94tKGm/JtfTr4zmW9+9Gj15nyUQiLlylKHFt+4/U54Ak3aJJM+fqQL7/GuGn8LCZQ== X-Received: by 2002:a63:bd49:0:b0:41b:8a07:a6ed with SMTP id d9-20020a63bd49000000b0041b8a07a6edmr12826181pgp.124.1659904342804; Sun, 07 Aug 2022 13:32:22 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:8eec:115d:8ea8:b700]) by smtp.gmail.com with ESMTPSA id x29-20020aa7941d000000b0052d194a6602sm7006334pfo.102.2022.08.07.13.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 13:32:22 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Aug 2022 02:02:02 +0530 Message-Id: <20220807203204.152358-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220807203204.152358-1-utkarsh02t@gmail.com> References: <20220807203204.152358-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 2/4] qcam: CamSelectDialog: Add capture script button 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 Capture Script in CamSelectDialog button which would allow the user to open a Capture Script (*.yaml). This button has three states : - Open Capture Script - Loaded - 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. When the script is loaded the button displays "Loaded", the script has not been verified yet. Verifying the script and executing it happens after user presses Ok. 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 --- Difference from V1: No button on toolbar now it resides in CamSelectDialog src/qcam/cam_select_dialog.h | 47 +++++++++++++++++++++++++++++-- src/qcam/main_window.cpp | 54 +++++++++++++++++++++++++++++++++++- src/qcam/main_window.h | 7 +++++ src/qcam/meson.build | 2 ++ 4 files changed, 107 insertions(+), 3 deletions(-) diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index 6ba61cff..fc29b46a 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -18,16 +18,19 @@ #include #include #include +#include #include #include +#include #include class CamSelectDialog : public QDialog { Q_OBJECT public: - CamSelectDialog(libcamera::CameraManager *cameraManager, QWidget *parent) - : QDialog(parent), cm_(cameraManager) + CamSelectDialog(libcamera::CameraManager *cameraManager, + bool isScriptRunning, QWidget *parent) + : QDialog(parent), cm_(cameraManager), isScriptRunning_(isScriptRunning) { /* Use a QFormLayout for the dialog. */ QFormLayout *camSelectDialogLayout = new QFormLayout(this); @@ -48,6 +51,16 @@ public: cameraIdComboBox_->currentText().toStdString())); }); + captureScriptButton_ = new QPushButton; + connect(captureScriptButton_, &QPushButton::clicked, + this, &CamSelectDialog::handleCaptureScriptButton); + + /* Display the action that would be performed when button is clicked. */ + if (isScriptRunning_) + captureScriptButton_->setText("Stop"); + else + captureScriptButton_->setText("Open"); + /* Setup the QDialogButton Box */ QDialogButtonBox *dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | @@ -62,6 +75,7 @@ public: camSelectDialogLayout->addRow("Camera: ", cameraIdComboBox_); camSelectDialogLayout->addRow("Location: ", cameraLocation_); camSelectDialogLayout->addRow("Model: ", cameraModel_); + camSelectDialogLayout->addRow("Capture Script: ", captureScriptButton_); camSelectDialogLayout->addWidget(dialogButtonBox); } @@ -72,6 +86,11 @@ public: return cameraIdComboBox_->currentText().toStdString(); } + std::string getCaptureScript() + { + return scriptPath_; + } + /* Hotplug / Unplug Support. */ void cameraAdded(libcamera::Camera *camera) { @@ -122,11 +141,35 @@ public: cameraModel_->setText(QString()); } + /* Capture script support. */ + void handleCaptureScriptButton() + { + if (isScriptRunning_) { + Q_EMIT stopCaptureScript(); + isScriptRunning_ = false; + captureScriptButton_->setText("Open"); + } else { + scriptPath_ = QFileDialog::getOpenFileName(this, "Run Capture Script", + QDir::currentPath(), "Capture Script (*.yaml)") + .toStdString(); + + if (!scriptPath_.empty()) + captureScriptButton_->setText("Loaded"); + } + } + +Q_SIGNALS: + void stopCaptureScript(); + private: libcamera::CameraManager *cm_; + bool isScriptRunning_; + std::string scriptPath_; + /* UI elements. */ QComboBox *cameraIdComboBox_; QLabel *cameraLocation_; QLabel *cameraModel_; + QPushButton *captureScriptButton_; }; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 549af024..e0219e5e 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -151,6 +153,9 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) return; } + /* Start capture script. */ + loadCaptureScript(); + startStopAction_->setChecked(true); } @@ -290,14 +295,55 @@ void MainWindow::switchCamera() startStopAction_->setChecked(true); } +void MainWindow::stopCaptureScript() +{ + if (script_) { + script_.reset(); + } +} + +void MainWindow::loadCaptureScript() +{ + if (scriptPath_.empty() || camera_ == nullptr) + return; + + script_ = std::make_unique(camera_, scriptPath_); + + /* + * If we are already capturing, stop so we don't have stuck image + * in viewfinder. + */ + bool wasCapturing = isCapturing_; + if (isCapturing_) + toggleCapture(false); + + if (!script_->valid()) { + script_.reset(); + + QMessageBox::critical(this, "Invalid Script", + "Couldn't load the capture script"); + } + + /* Start capture again if we were capturing before. */ + if (wasCapturing) + toggleCapture(true); +} + std::string MainWindow::chooseCamera() { - camSelectDialog_ = new CamSelectDialog(cm_, this); + bool scriptRunning = script_ != nullptr; + camSelectDialog_ = new CamSelectDialog(cm_, scriptRunning, this); + + connect(camSelectDialog_, &CamSelectDialog::stopCaptureScript, + this, &MainWindow::stopCaptureScript); if (camSelectDialog_->exec() == QDialog::Accepted) { std::string cameraId = camSelectDialog_->getCameraId(); cameraSwitchButton_->setText(QString::fromStdString(cameraId)); + scriptPath_ = camSelectDialog_->getCaptureScript(); + loadCaptureScript(); + return cameraId; } else return std::string(); @@ -504,6 +550,7 @@ int MainWindow::startCapture() previousFrames_ = 0; framesCaptured_ = 0; lastBufferTime_ = 0; + queueCount_ = 0; ret = camera_->start(); if (ret) { @@ -783,5 +830,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 7982939e..01466e28 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -28,6 +28,7 @@ #include #include +#include "../cam/capture_script.h" #include "../cam/stream_options.h" #include "cam_select_dialog.h" @@ -90,6 +91,9 @@ private: void processHotplug(HotplugEvent *e); void processViewfinder(libcamera::FrameBuffer *buffer); + void loadCaptureScript(); + void stopCaptureScript(); + /* UI elements */ QToolBar *toolbar_; QAction *startStopAction_; @@ -130,6 +134,9 @@ private: QElapsedTimer frameRateInterval_; uint32_t previousFrames_; uint32_t framesCaptured_; + uint32_t queueCount_; std::vector> requests_; + std::unique_ptr script_; + std::string scriptPath_; }; diff --git a/src/qcam/meson.build b/src/qcam/meson.build index 70615e92..80c97cc5 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', @@ -38,6 +39,7 @@ qcam_resources = files([ qcam_deps = [ libatomic, libcamera_public, + libyaml, qt5_dep, ] From patchwork Sun Aug 7 20:32: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: 17021 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 1812BBE173 for ; Sun, 7 Aug 2022 20:32:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CBE076332D; Sun, 7 Aug 2022 22:32:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659904347; bh=mDM/AqDCeM00UHYfpX5f1RIyHRRuplHtHJbTxOHBOE0=; 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=zx46pBe9D3wWUmitRSbd0Lcy+lvliMiZhKK2g5Wz2706ba7zdhLWpq87f/TEgI1mt c6htj8b3A+tPvyA0SvKtw1Ta/ZJHJnCzNl5WnVHNj2Wx9f+xnCR5Y33pgKYfh8p3DD NdlHwQ7MfWjQK8wpimqRIKj2r/rZutUxOkTwT/UGbNAHMhAKEV7i32YLc0v2K7F19t NutOU0AIqhwZZstIgy5RKiWqpoyzVnfQai3JVwLP72XAzH17dh3RN1RHPmhVlUluXg n/PX0NmsJzFRe8e9tdxaSNj9eCSGJnlvtaqsLO72LYYQIGaPA8+1WauoQWzjrx0OMu 6vYgJfxKDtXGw== Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B424C63327 for ; Sun, 7 Aug 2022 22:32:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aFVbkFsR"; dkim-atps=neutral Received: by mail-pg1-x52e.google.com with SMTP id q16so6933479pgq.6 for ; Sun, 07 Aug 2022 13:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=kanfHGJITr6TvtYEOvkfhBTL2ZgRI2xaXV9xshtHLHQ=; b=aFVbkFsR/DYbdVHhyDWiW5hHP+g7mUlZxQekw7t41QsUjQkxsfHOPQQg+t6hxW58Lk gByMVMwE47rVWK1f/whu4cJzcVLGIzPdpCLcLvzGlkEPRLfMIkLylo7jZ7wTNFF0GYjK ULqvDxvckHtbraOQ6daEN+f1JXF/RHTblTdl/3iFnxzpuY/kRNm6e0NAuz31HNW/VNOM 1jb9aMGf8NrJ0/C1yguyPccY9yTpSsQGfRa9OPZK1WQJHReZrww/HKNjE+WhCnd9rumY HQHKvX5hGcWTdVWofWD2LSZAoEZu6H+5ooZJ/zZ1zhXsvGDxEwtwy1I6rh7plVEEC000 eVcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=kanfHGJITr6TvtYEOvkfhBTL2ZgRI2xaXV9xshtHLHQ=; b=wZCaODH2PXU0qWMqMc5t7w785N4oaKIsFxM7yQiTq4g/RmeDh02LjD/XgO7rJVFkPR s/vUcyBp6qQE2J5x0Ws5m98hFWKCCLsb/bK8ElPq89NoQ4XUFs8T3kLXhYp/OJAW42C8 Edj29LN+8Hvg5JTn6AnhNvGLF1ghX4R4IQiOzJy5PxEZoscHy22O03b02G+Aq7llAAtA 8fvfv82qPEPHLjWX8HW8AMlRu3nC7pEF8h94RnkTTdllv0C0uBwWZMSbQjOzVtL2nrUL 1zKra/xxW5lsLMuSgDAIswBGH5OpGoKKQWMI6b4vzLzgfVZ0Ymkwy1n9vFctsQagjCYj lVSg== X-Gm-Message-State: ACgBeo0aVa6d7PIv9hFbj8TYr5ilO9RH51Nq88C6u0lzkWMcVhHWwhTl tnK81ERdHw3+AbgtsJjPFx1hjd3xKII= X-Google-Smtp-Source: AA6agR6QOQwiYt+oqsL4/JMcMLTIDiDkeT23pakktQs0fs2aSXzZ4JhTHMNuaRVqwi7pyBKEObzuOg== X-Received: by 2002:aa7:9157:0:b0:52f:20d6:e4f6 with SMTP id 23-20020aa79157000000b0052f20d6e4f6mr4616705pfi.40.1659904344877; Sun, 07 Aug 2022 13:32:24 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:8eec:115d:8ea8:b700]) by smtp.gmail.com with ESMTPSA id x29-20020aa7941d000000b0052d194a6602sm7006334pfo.102.2022.08.07.13.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 13:32:24 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Aug 2022 02:02:03 +0530 Message-Id: <20220807203204.152358-4-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220807203204.152358-1-utkarsh02t@gmail.com> References: <20220807203204.152358-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 3/4] qcam: CamSelectDialog: Display Capture script path 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" Display the path of the selected capture script in a thinner font. Signed-off-by: Utkarsh Tiwari --- Difference from V5: came to existance. src/qcam/cam_select_dialog.h | 41 +++++++++++++++++++++++++++++++----- src/qcam/main_window.cpp | 3 ++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h index fc29b46a..7dc44794 100644 --- a/src/qcam/cam_select_dialog.h +++ b/src/qcam/cam_select_dialog.h @@ -19,18 +19,22 @@ #include #include #include +#include #include #include #include #include +#include +#include class CamSelectDialog : public QDialog { Q_OBJECT public: CamSelectDialog(libcamera::CameraManager *cameraManager, - bool isScriptRunning, QWidget *parent) - : QDialog(parent), cm_(cameraManager), isScriptRunning_(isScriptRunning) + bool isScriptRunning, std::string scriptPath, QWidget *parent) + : QDialog(parent), cm_(cameraManager), + isScriptRunning_(isScriptRunning), scriptPath_(scriptPath) { /* Use a QFormLayout for the dialog. */ QFormLayout *camSelectDialogLayout = new QFormLayout(this); @@ -51,14 +55,31 @@ public: cameraIdComboBox_->currentText().toStdString())); }); + /* Setup widget for capture script button. */ + QWidget *captureWidget = new QWidget; + captureWidgetLayout_ = new QVBoxLayout(captureWidget); + captureWidgetLayout_->setMargin(0); + captureScriptButton_ = new QPushButton; connect(captureScriptButton_, &QPushButton::clicked, this, &CamSelectDialog::handleCaptureScriptButton); + captureWidgetLayout_->addWidget(captureScriptButton_); + + /* Use a thinner font to indicate script info. */ + QFont smallFont; + smallFont.setWeight(QFont::Thin); + + scriptPathLabel_ = new QLabel; + scriptPathLabel_->setFont(smallFont); + scriptPathLabel_->setWordWrap(true); /* Display the action that would be performed when button is clicked. */ - if (isScriptRunning_) + if (isScriptRunning_) { captureScriptButton_->setText("Stop"); - else + + scriptPathLabel_->setText(QString::fromStdString(scriptPath_)); + captureWidgetLayout_->addWidget(scriptPathLabel_); + } else captureScriptButton_->setText("Open"); /* Setup the QDialogButton Box */ @@ -75,7 +96,7 @@ public: camSelectDialogLayout->addRow("Camera: ", cameraIdComboBox_); camSelectDialogLayout->addRow("Location: ", cameraLocation_); camSelectDialogLayout->addRow("Model: ", cameraModel_); - camSelectDialogLayout->addRow("Capture Script: ", captureScriptButton_); + camSelectDialogLayout->addRow("Capture Script: ", captureWidget); camSelectDialogLayout->addWidget(dialogButtonBox); } @@ -148,6 +169,8 @@ public: Q_EMIT stopCaptureScript(); isScriptRunning_ = false; captureScriptButton_->setText("Open"); + + captureWidgetLayout_->removeWidget(scriptPathLabel_); } else { scriptPath_ = QFileDialog::getOpenFileName(this, "Run Capture Script", QDir::currentPath(), "Capture Script (*.yaml)") @@ -155,6 +178,11 @@ public: if (!scriptPath_.empty()) captureScriptButton_->setText("Loaded"); + else + return; + + scriptPathLabel_->setText(QString::fromStdString(scriptPath_)); + captureWidgetLayout_->addWidget(scriptPathLabel_); } } @@ -171,5 +199,8 @@ private: QComboBox *cameraIdComboBox_; QLabel *cameraLocation_; QLabel *cameraModel_; + + QVBoxLayout *captureWidgetLayout_; QPushButton *captureScriptButton_; + QLabel *scriptPathLabel_ = new QLabel; }; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index e0219e5e..e354ba10 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -332,7 +332,8 @@ void MainWindow::loadCaptureScript() std::string MainWindow::chooseCamera() { bool scriptRunning = script_ != nullptr; - camSelectDialog_ = new CamSelectDialog(cm_, scriptRunning, this); + camSelectDialog_ = new CamSelectDialog(cm_, scriptRunning, + scriptPath_, this); connect(camSelectDialog_, &CamSelectDialog::stopCaptureScript, this, &MainWindow::stopCaptureScript); From patchwork Sun Aug 7 20:32: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: 17022 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 8D55BBE173 for ; Sun, 7 Aug 2022 20:32:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 45E7463336; Sun, 7 Aug 2022 22:32:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659904349; bh=k4GIaMoB7l5a+5j5zmU+WTsJMR1CqBU9pK40vIr6+Ps=; 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=fn5HRKWo8T6Lk0jenH0YVkMJtlt8QOqRl5vlJqsQKxeQ1sE9NlP2d3dVm2/ttzdk3 49tZwk/KrFNE42kJuDsSqeQkqoXz+EhvflzHONZpamDql4jHZfVvCu1w+zTxUBsJ51 5cGjeBQZdmF6nj9p1IKmgbxB9P3cQCwlZVlBPz4FCxj8tO98NeF5mdI8XNI1FVFyVS tgn/lonwy7ud+znofcLYqo8njwqUULDY1l7CUR8It+oKehr6eKnUweo8oA2c1np5EI q5jlL5hYfc/HrLbAaAlniFvWPbN/sGKnuaEaPOoINS7au/FaUsKZtipRPztPAzvMuj w6eJPU0BZCTRw== Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6990063327 for ; Sun, 7 Aug 2022 22:32:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bTP0kbPs"; dkim-atps=neutral Received: by mail-pj1-x102a.google.com with SMTP id b4so7082311pji.4 for ; Sun, 07 Aug 2022 13:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=OFhf8uHWyTxzs9/ji3mmENRnTkopYCwLKyaZSOgDTG4=; b=bTP0kbPsMT9Qn1qLO+qPRveqtplevHN/NTDMYdoEQA+XI136tfv9JEDl3Nb1ZH7ZQd 7sIeqFWx8+pdw/R1uO6wqjrSs6SdMDZde2vC1kgzER6lCVjVCiHWLWTqBmcI+/MNTNzs 2d0MqJ+qpUY1cbXtB56715i9hZtqOpp+bZRIrXBH7oP6BtELmnP1sepP3iEZ95oWgUcd L4fKbHKVnC6lr7o1hUyRif+rM5HKp+xgmyaAFJnLq5/lFTNtqusPfvePL6PBPQEWszdp BHBIEnLKAPiZeW9SsMQTl7w6kX2VMnRAsNCJ5iT/n6ZLefV+AXKv0mw7SX8YVvLaL2sc gyMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=OFhf8uHWyTxzs9/ji3mmENRnTkopYCwLKyaZSOgDTG4=; b=dvR1zd0J7m3WIzr7ITzGXCtgQxyKUFIbCCN0z804u+xIZymWc8aNjoXzGtjf+xOMFv FdK9LXSXAcfEFeSSeury3+gFkNFCkxAYoKbkbEeQSlqBjMKoVTUZaRaDmpz8SSFcxB7y BrVX9+1XBWaanFkLAuNguvS1C9dAAO47ASHa/xX7DOiSGEsN4XMKAK68es3ryZ3yfFqw tkOGs6eVKbnrvcFyhcEYVr5rBRcKyQSBKMn7wD2D198RgEkPtO5lFURLrQTQ4NohRpiN 37MyPxPT3Ntc2OHdj0YQNdlA3uAcn9ixKCuRCYXxfLoV1cxtEg7P3ZL9W4i8CVViLEIK Dwwg== X-Gm-Message-State: ACgBeo0OQ/nAY2K+P5PU0/GYN9dY/nXkMuq/dlT/13PD94iFBRmbtqIL VvyiCoFQyw3TlyxkkmU80hdRJeFCqJ0= X-Google-Smtp-Source: AA6agR5FWWMcERP+vtqsYN+lRzS41wBg1s6CCIED9lQMG9zHDY3PnWWUfu8pTZwuaWwQbzMOc3bIig== X-Received: by 2002:a17:902:e952:b0:16d:2552:f2eb with SMTP id b18-20020a170902e95200b0016d2552f2ebmr15788985pll.76.1659904346791; Sun, 07 Aug 2022 13:32:26 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:8eec:115d:8ea8:b700]) by smtp.gmail.com with ESMTPSA id x29-20020aa7941d000000b0052d194a6602sm7006334pfo.102.2022.08.07.13.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 13:32:26 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Aug 2022 02:02:04 +0530 Message-Id: <20220807203204.152358-5-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220807203204.152358-1-utkarsh02t@gmail.com> References: <20220807203204.152358-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 4/4] 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, quit the application. Signed-off-by: Utkarsh Tiwari --- src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 6 ++++++ src/qcam/main_window.h | 1 + 3 files changed, 10 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 e354ba10..51088658 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -146,6 +146,9 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) cm_->cameraAdded.connect(this, &MainWindow::addCamera); cm_->cameraRemoved.connect(this, &MainWindow::removeCamera); + if (options_.isSet(OptCaptureScript)) + scriptPath_ = options_[OptCaptureScript].toString(); + /* Open the camera and start capture. */ ret = openCamera(); if (ret < 0) { @@ -320,6 +323,9 @@ void MainWindow::loadCaptureScript() if (!script_->valid()) { script_.reset(); + if (options_.isSet(OptCaptureScript)) + quit(); + QMessageBox::critical(this, "Invalid Script", "Couldn't load the capture script"); } diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 01466e28..fe4dba8d 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -46,6 +46,7 @@ enum { OptRenderer = 'r', OptStream = 's', OptVerbose = 'v', + OptCaptureScript = 256, }; class MainWindow : public QMainWindow