summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qcam/cam_select_dialog.cpp12
-rw-r--r--src/qcam/cam_select_dialog.h5
-rw-r--r--src/qcam/main_window.cpp7
3 files changed, 22 insertions, 2 deletions
diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp
index a49d822b..07f53f40 100644
--- a/src/qcam/cam_select_dialog.cpp
+++ b/src/qcam/cam_select_dialog.cpp
@@ -48,3 +48,15 @@ std::string CameraSelectorDialog::getCameraId()
{
return cameraIdComboBox_->currentText().toStdString();
}
+
+/* Hotplug / Unplug Support. */
+void CameraSelectorDialog::addCamera(QString cameraId)
+{
+ cameraIdComboBox_->addItem(cameraId);
+}
+
+void CameraSelectorDialog::removeCamera(QString cameraId)
+{
+ int cameraIndex = cameraIdComboBox_->findText(cameraId);
+ cameraIdComboBox_->removeItem(cameraIndex);
+}
diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h
index bce258b2..44b081a5 100644
--- a/src/qcam/cam_select_dialog.h
+++ b/src/qcam/cam_select_dialog.h
@@ -13,6 +13,7 @@
#include <libcamera/camera_manager.h>
#include <QDialog>
+#include <QString>
class QComboBox;
@@ -26,6 +27,10 @@ public:
std::string getCameraId();
+ /* Hotplug / Unplug Support. */
+ void addCamera(QString cameraId);
+ void removeCamera(QString cameraId);
+
private:
libcamera::CameraManager *cm_;
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 3bddb1f1..385b0059 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -594,10 +594,12 @@ void MainWindow::stopCapture()
void MainWindow::processHotplug(HotplugEvent *e)
{
Camera *camera = e->camera();
+ QString cameraId = QString::fromStdString(camera->id());
HotplugEvent::PlugEvent event = e->hotplugEvent();
if (event == HotplugEvent::HotPlug) {
- cameraCombo_->addItem(QString::fromStdString(camera->id()));
+ cameraCombo_->addItem(cameraId);
+ cameraSelectorDialog_->addCamera(cameraId);
} else if (event == HotplugEvent::HotUnplug) {
/* Check if the currently-streaming camera is removed. */
if (camera == camera_.get()) {
@@ -607,8 +609,9 @@ void MainWindow::processHotplug(HotplugEvent *e)
cameraCombo_->setCurrentIndex(0);
}
- int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id()));
+ int camIndex = cameraCombo_->findText(cameraId);
cameraCombo_->removeItem(camIndex);
+ cameraSelectorDialog_->removeCamera(cameraId);
}
}
ort Enum, IntEnum class Color(IntEnum): R = 0 GR = 1 GB = 2 B = 3 class Debug(Enum): Plot = 1 # @brief What to do with the leftover pixels after dividing them into ALSC # sectors, when the division gradient is uniform # @var Float Force floating point division so all sectors divide equally # @var DistributeFront Divide the remainder equally (until running out, # obviously) into the existing sectors, starting from the front # @var DistributeBack Same as DistributeFront but starting from the back class Remainder(Enum): Float = 0 DistributeFront = 1 DistributeBack = 2 # @brief A helper class to contain a default value for a module configuration # parameter class Param(object): # @var Required The value contained in this instance is irrelevant, and the # value must be provided by the tuning configuration file. # @var Optional If the value is not provided by the tuning configuration # file, then the value contained in this instance will be used instead. # @var Hardcode The value contained in this instance will be used class Mode(Enum): Required = 0 Optional = 1 Hardcode = 2 # @param name Name of the parameter. Shall match the name used in the # configuration file for the parameter # @param required Whether or not a value is required in the config # parameter of get_value() # @param val Default value (only relevant if mode is Optional) def __init__(self, name: str, required: Mode, val=None): self.name = name self.__required = required self.val = val def get_value(self, config: dict): if self.__required is self.Mode.Hardcode: return self.val if self.__required is self.Mode.Required and self.name not in config: raise ValueError(f'Parameter {self.name} is required but not provided in the configuration') return config[self.name] if self.required else self.val @property def required(self): return self.__required is self.Mode.Required # @brief Used by libtuning to auto-generate help information for the tuning # script on the available parameters for the configuration file # \todo Implement this @property def info(self): raise NotImplementedError class Tuner(object): # External functions def __init__(self, platform_name): self.name = platform_name self.modules = [] self.parser = None self.generator = None self.output_order = [] self.config = {} self.output = {} def add(self, module): self.modules.append(module) def set_input_parser(self, parser): self.parser = parser def set_output_formatter(self, output): self.generator = output def set_output_order(self, modules): self.output_order = modules # @brief Convert classes in self.output_order to the instances in self.modules def _prepare_output_order(self): output_order = self.output_order self.output_order = [] for module_type in output_order: modules = [module for module in self.modules if module.type == module_type.type] if len(modules) > 1: eprint(f'Multiple modules found for module type "{module_type.type}"') return False if len(modules) < 1: eprint(f'No module found for module type "{module_type.type}"') return False self.output_order.append(modules[0]) return True # \todo Validate parser and generator at Tuner construction time? def _validate_settings(self): if self.parser is None: eprint('Missing parser') return False if self.generator is None: eprint('Missing generator') return False if len(self.modules) == 0: eprint('No modules added') return False if len(self.output_order) != len(self.modules): eprint('Number of outputs does not match number of modules') return False return True def _process_args(self, argv, platform_name): parser = argparse.ArgumentParser(description=f'Camera Tuning for {platform_name}') parser.add_argument('-i', '--input', type=str, required=True, help='''Directory containing calibration images (required). Images for ALSC must be named "alsc_{Color Temperature}k_1[u].dng", and all other images must be named "{Color Temperature}k_{Lux Level}l.dng"''') parser.add_argument('-o', '--output', type=str, required=True, help='Output file (required)') # It is not our duty to scan all modules to figure out their default # options, so simply return an empty configuration if none is provided. parser.add_argument('-c', '--config', type=str, default='',