[libcamera-devel,v2,3/3] qcam: Add --script to load capture script
diff mbox series

Message ID 20220622131638.79122-4-utkarsh02t@gmail.com
State Superseded
Headers show
Series
  • Introduce capture scripts to qcam
Related show

Commit Message

Utkarsh Tiwari June 22, 2022, 1:16 p.m. UTC
Add --script as an individual option to load capture scripts.
Load the capture script before starting the capture.

Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>
---
 src/qcam/main.cpp        |  3 +++
 src/qcam/main_window.cpp | 10 ++++++++++
 src/qcam/main_window.h   |  1 +
 3 files changed, 14 insertions(+)

Comments

Kieran Bingham June 22, 2022, 4 p.m. UTC | #1
Quoting Utkarsh Tiwari via libcamera-devel (2022-06-22 14:16:38)
> Add --script as an individual option to load capture scripts.
> Load the capture script before starting the capture.

I think this is missing the update to the isScriptExecuting_; however -
I think it's better to use the presence of script_ as the marker to know
if there is a valid script anyway, so I don't think it should be added.


This does leave the state of the capture script button incorrect though
- as it will be in the 'load' icon state, not the 'stop' icon.

That also makes me wonder if the script stop button would confuse people
with the camera stop button...

But otherwise, I think being able to load the script at commandline
could be useful too so:


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>
> ---
>  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<CaptureScript>(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
> -- 
> 2.25.1
>

Patch
diff mbox series

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<CaptureScript>(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