From patchwork Tue Aug 9 20:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17060 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 E61EFBE173 for ; Tue, 9 Aug 2022 20:53:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A58196332F; Tue, 9 Aug 2022 22:53:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660078404; bh=Mh458UP2fIbdUlAJuSxCqrj9cpiKx0IlnO1iGdmcrJs=; 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=vA55UoBaU5B3f14icWFKoXMoO6W+oIHmP5vQq7udY3fU7ZdMRsAlWREq4jouFtkKk s/T7yHXlHuPIDPMSWLA+RK1477/u/X2961Y7kyd6pZfq2s//HoLzT7OR9HL/UmzsLH 0jjW9ge3cHLN0cNZB5gWBE4sMu4RbyeyFKDXR7h2lmMDx/1yo8J0GcVhxp7cI2RvTi vC/FsradFQmr6dCJJHsF58nBQMLD057ht4zHDs4wPSKdf0/mSpEREBQXMsiqdue94Z XpZFy8qsXgESOQUbmZQEcKzN8pLcYctjIb2Gw/7HXUmTIw3sgLf4b6JjNJH1JAVuL9 8rbpTheSsro/A== Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 022B863326 for ; Tue, 9 Aug 2022 22:53:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HghvDntf"; dkim-atps=neutral Received: by mail-pg1-x535.google.com with SMTP id f65so12428788pgc.12 for ; Tue, 09 Aug 2022 13:53:21 -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=4kJc2X3IFnYFC/i3pZnsTvmeQjYWGAtyZAF3am6hQFI=; b=HghvDntfyzWVtJ1HEDVC+pMzAAwYYvbo3+X3lkH61qWa+uViHkPgvmA/0t0mZqtcJm KXrHQz/jN818HilaTFTAW2Jw1ZiQtFqGyq19Z+dnrE8vE29dSpL8BvlQl55n8Tsh3gY8 og77Cr+00Dq3jnuX2okK7xdmD48BGRI1OHnsLO2WTSfDEaKt8ubhEPgV1x5NMCuvfA7E J0WNEYa+mUG1D+2/0QLHVakebmdi6pr5MMakJQgIrkKwghFKu+VPchbW6rvnqMMbTeIf iSyRlY9cryg62po/+0rFDfJWlsvbsv3S3zwnAZv2xuoarYcMleoDXtoRawNhkbRYFtQ2 505w== 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=4kJc2X3IFnYFC/i3pZnsTvmeQjYWGAtyZAF3am6hQFI=; b=pEk3XtAggDXlrJnO3JgBREJJdxogx5MA4f8kjG5mDK65WgcZ7IAcHaHHvz84pLIk5x OAg9lWhFrHxIy7caOS9S/jqelWWMwqf3iNLpptfqzDSkB384JcQ2WttCwFcyZwPTdSmV /Sd5LvWWaaMhPSk1b1z32A6hP4tuGcwmZWlyjHpFzDZR6/cfH3T6wupk8er+LRZ6TmoX pN0dyI95ADq/32K+HNP06AwhWjh0MPwvCKSG/1Sj8KdSvZHT5zzxKx2DLWUiG7oM8RMF IkbRrbUfIvpRIFsRMRurwRGelaT2+9PbM6BuffvBksmOdzoM6V/PD9oeqehCKPXYZ2GR EUzw== X-Gm-Message-State: ACgBeo1FhT5Vn8xXu9+PmT2LRI7Y0KsdFXdqCyRaN+JtcEXfDYBG55t4 FyWruRz7XygkMrR4n8VUcNNooIihL0k= X-Google-Smtp-Source: AA6agR6yTOQL9duoirMgjBc/pFzH+oKgMVDyuk9UCzOMYYBdoHdH8iDIurdbyS2u7YogHna4ycDjQg== X-Received: by 2002:a05:6a00:240f:b0:52e:f99d:1157 with SMTP id z15-20020a056a00240f00b0052ef99d1157mr15371950pfh.70.1660078400416; Tue, 09 Aug 2022 13:53:20 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d2bc:2358:3bcd:fb4f:cbb7]) by smtp.gmail.com with ESMTPSA id d3-20020a623603000000b0052d981e7842sm301936pfa.208.2022.08.09.13.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 13:53:20 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Aug 2022 02:20:42 +0530 Message-Id: <20220809205042.344923-9-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220809205042.344923-1-utkarsh02t@gmail.com> References: <20220809205042.344923-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 8/8] 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, display an critical error QMessageBox and close the application. Signed-off-by: Utkarsh Tiwari --- Difference: 1. firstCameraSelect_ newly introduced to keep track if its the first time dialog is been opened. src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 16 ++++++++++++++-- src/qcam/main_window.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) 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 f2e3c576..d6ad0083 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -100,7 +100,7 @@ private: MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) : saveRaw_(nullptr), options_(options), cm_(cm), allocator_(nullptr), - isCapturing_(false), captureRaw_(false) + isCapturing_(false), captureRaw_(false), firstCameraSelect_(true) { int ret; @@ -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) { @@ -324,6 +327,13 @@ void MainWindow::loadCaptureScript() QMessageBox::critical(this, "Invalid Script", "Couldn't load the capture script"); + /* + * Close the camera if started by command line and its the first capture + * script. + */ + if (firstCameraSelect_ && options_.isSet(OptCaptureScript)) + quit(); + } else cameraSelectorDialog_->informScriptRunning(scriptPath_); @@ -347,8 +357,10 @@ std::string MainWindow::chooseCamera() * Use the camera specified on the command line, if any, or display the * camera selection dialog box otherwise. */ - if (options_.isSet(OptCamera)) + if (firstCameraSelect_ && options_.isSet(OptCamera)) { + firstCameraSelect_ = false; return static_cast(options_[OptCamera]); + } if (cameraSelectorDialog_->exec() == QDialog::Accepted) { std::string cameraId = cameraSelectorDialog_->getCameraId(); diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 887f1db1..3a264f96 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 @@ -123,6 +124,7 @@ private: /* Capture state, buffers queue and statistics */ bool isCapturing_; bool captureRaw_; + bool firstCameraSelect_; libcamera::Stream *vfStream_; libcamera::Stream *rawStream_; std::map> freeBuffers_;