summaryrefslogtreecommitdiff
path: root/utils/tuning/libtuning
diff options
context:
space:
mode:
Diffstat (limited to 'utils/tuning/libtuning')
-rw-r--r--utils/tuning/libtuning/average.py2
-rw-r--r--utils/tuning/libtuning/generators/generator.py2
-rw-r--r--utils/tuning/libtuning/generators/raspberrypi_output.py2
-rw-r--r--utils/tuning/libtuning/generators/yaml_output.py2
-rw-r--r--utils/tuning/libtuning/gradient.py2
-rw-r--r--utils/tuning/libtuning/image.py2
-rw-r--r--utils/tuning/libtuning/libtuning.py2
-rw-r--r--utils/tuning/libtuning/macbeth.py2
-rw-r--r--utils/tuning/libtuning/modules/agc/__init__.py6
-rw-r--r--utils/tuning/libtuning/modules/agc/agc.py21
-rw-r--r--utils/tuning/libtuning/modules/agc/rkisp1.py79
-rw-r--r--utils/tuning/libtuning/modules/lsc/raspberrypi.py2
-rw-r--r--utils/tuning/libtuning/modules/lsc/rkisp1.py2
-rw-r--r--utils/tuning/libtuning/modules/module.py2
-rw-r--r--utils/tuning/libtuning/parsers/parser.py2
-rw-r--r--utils/tuning/libtuning/parsers/raspberrypi_parser.py2
-rw-r--r--utils/tuning/libtuning/parsers/yaml_parser.py2
-rw-r--r--utils/tuning/libtuning/smoothing.py2
-rw-r--r--utils/tuning/libtuning/utils.py2
19 files changed, 122 insertions, 16 deletions
diff --git a/utils/tuning/libtuning/average.py b/utils/tuning/libtuning/average.py
index e28770d7..c41075a1 100644
--- a/utils/tuning/libtuning/average.py
+++ b/utils/tuning/libtuning/average.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# average.py - Wrapper for numpy averaging functions to enable duck-typing
+# Wrapper for numpy averaging functions to enable duck-typing
import numpy as np
diff --git a/utils/tuning/libtuning/generators/generator.py b/utils/tuning/libtuning/generators/generator.py
index 7c8c9b99..77a8ba4a 100644
--- a/utils/tuning/libtuning/generators/generator.py
+++ b/utils/tuning/libtuning/generators/generator.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# generator.py - Base class for a generator to convert dict to tuning file
+# Base class for a generator to convert dict to tuning file
from pathlib import Path
diff --git a/utils/tuning/libtuning/generators/raspberrypi_output.py b/utils/tuning/libtuning/generators/raspberrypi_output.py
index 813491cd..47b49059 100644
--- a/utils/tuning/libtuning/generators/raspberrypi_output.py
+++ b/utils/tuning/libtuning/generators/raspberrypi_output.py
@@ -2,7 +2,7 @@
#
# Copyright 2022 Raspberry Pi Ltd
#
-# raspberrypi_output.py - Generate tuning file in Raspberry Pi's json format
+# Generate tuning file in Raspberry Pi's json format
#
# (Copied from ctt_pretty_print_json.py)
diff --git a/utils/tuning/libtuning/generators/yaml_output.py b/utils/tuning/libtuning/generators/yaml_output.py
index effb4fb3..8f22d386 100644
--- a/utils/tuning/libtuning/generators/yaml_output.py
+++ b/utils/tuning/libtuning/generators/yaml_output.py
@@ -2,7 +2,7 @@
#
# Copyright 2022 Paul Elder <paul.elder@ideasonboard.com>
#
-# yaml_output.py - Generate tuning file in YAML format
+# Generate tuning file in YAML format
from .generator import Generator
diff --git a/utils/tuning/libtuning/gradient.py b/utils/tuning/libtuning/gradient.py
index 5106f821..b643f502 100644
--- a/utils/tuning/libtuning/gradient.py
+++ b/utils/tuning/libtuning/gradient.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# gradient.py - Gradients that can be used to distribute or map numbers
+# Gradients that can be used to distribute or map numbers
import libtuning as lt
diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py
index aa9d20b5..e2181b11 100644
--- a/utils/tuning/libtuning/image.py
+++ b/utils/tuning/libtuning/image.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2019, Raspberry Pi Ltd
#
-# image.py - Container for an image and associated metadata
+# Container for an image and associated metadata
import binascii
import numpy as np
diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py
index d84c148f..5e22288d 100644
--- a/utils/tuning/libtuning/libtuning.py
+++ b/utils/tuning/libtuning/libtuning.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# libtuning.py - An infrastructure for camera tuning tools
+# An infrastructure for camera tuning tools
import argparse
diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py
index 5faddf66..e1182464 100644
--- a/utils/tuning/libtuning/macbeth.py
+++ b/utils/tuning/libtuning/macbeth.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2019, Raspberry Pi Ltd
#
-# macbeth.py - Locate and extract Macbeth charts from images
+# Locate and extract Macbeth charts from images
# (Copied from: ctt_macbeth_locator.py)
# \todo Add debugging
diff --git a/utils/tuning/libtuning/modules/agc/__init__.py b/utils/tuning/libtuning/modules/agc/__init__.py
new file mode 100644
index 00000000..4db9ca37
--- /dev/null
+++ b/utils/tuning/libtuning/modules/agc/__init__.py
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>
+
+from libtuning.modules.agc.agc import AGC
+from libtuning.modules.agc.rkisp1 import AGCRkISP1
diff --git a/utils/tuning/libtuning/modules/agc/agc.py b/utils/tuning/libtuning/modules/agc/agc.py
new file mode 100644
index 00000000..9c8899ba
--- /dev/null
+++ b/utils/tuning/libtuning/modules/agc/agc.py
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (C) 2019, Raspberry Pi Ltd
+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>
+
+from ..module import Module
+
+import libtuning as lt
+
+
+class AGC(Module):
+ type = 'agc'
+ hr_name = 'AGC (Base)'
+ out_name = 'GenericAGC'
+
+ # \todo Add sector shapes and stuff just like lsc
+ def __init__(self, *,
+ debug: list):
+ super().__init__()
+
+ self.debug = debug
diff --git a/utils/tuning/libtuning/modules/agc/rkisp1.py b/utils/tuning/libtuning/modules/agc/rkisp1.py
new file mode 100644
index 00000000..19a5555b
--- /dev/null
+++ b/utils/tuning/libtuning/modules/agc/rkisp1.py
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (C) 2019, Raspberry Pi Ltd
+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>
+#
+# rkisp1.py - AGC module for tuning rkisp1
+
+from .agc import AGC
+
+import libtuning as lt
+
+
+class AGCRkISP1(AGC):
+ hr_name = 'AGC (RkISP1)'
+ out_name = 'Agc'
+
+ def __init__(self, **kwargs):
+ super().__init__(**kwargs)
+
+ # We don't actually need anything from the config file
+ def validate_config(self, config: dict) -> bool:
+ return True
+
+ def _generate_metering_modes(self) -> dict:
+ centre_weighted = [
+ 0, 0, 0, 0, 0,
+ 0, 6, 8, 6, 0,
+ 0, 8, 16, 8, 0,
+ 0, 6, 8, 6, 0,
+ 0, 0, 0, 0, 0
+ ]
+
+ spot = [
+ 0, 0, 0, 0, 0,
+ 0, 2, 4, 2, 0,
+ 0, 4, 16, 4, 0,
+ 0, 2, 4, 2, 0,
+ 0, 0, 0, 0, 0
+ ]
+
+ matrix = [1 for i in range(0, 25)]
+
+ return {
+ 'MeteringCentreWeighted': centre_weighted,
+ 'MeteringSpot': spot,
+ 'MeteringMatrix': matrix
+ }
+
+ def _generate_exposure_modes(self) -> dict:
+ normal = {'shutter': [100, 10000, 30000, 60000, 120000],
+ 'gain': [2.0, 4.0, 6.0, 6.0, 6.0]}
+ short = {'shutter': [100, 5000, 10000, 20000, 120000],
+ 'gain': [2.0, 4.0, 6.0, 6.0, 6.0]}
+
+ return {'ExposureNormal': normal, 'ExposureShort': short}
+
+ def _generate_constraint_modes(self) -> dict:
+ normal = {'lower': {'qLo': 0.98, 'qHi': 1.0, 'yTarget': 0.5}}
+ highlight = {
+ 'lower': {'qLo': 0.98, 'qHi': 1.0, 'yTarget': 0.5},
+ 'upper': {'qLo': 0.98, 'qHi': 1.0, 'yTarget': 0.8}
+ }
+
+ return {'ConstraintNormal': normal, 'ConstraintHighlight': highlight}
+
+ def _generate_y_target(self) -> list:
+ return 0.16
+
+ def process(self, config: dict, images: list, outputs: dict) -> dict:
+ output = {}
+
+ output['AeMeteringMode'] = self._generate_metering_modes()
+ output['AeExposureMode'] = self._generate_exposure_modes()
+ output['AeConstraintMode'] = self._generate_constraint_modes()
+ output['relativeLuminanceTarget'] = self._generate_y_target()
+
+ # \todo Debug functionality
+
+ return output
diff --git a/utils/tuning/libtuning/modules/lsc/raspberrypi.py b/utils/tuning/libtuning/modules/lsc/raspberrypi.py
index 58f5000d..f19c7163 100644
--- a/utils/tuning/libtuning/modules/lsc/raspberrypi.py
+++ b/utils/tuning/libtuning/modules/lsc/raspberrypi.py
@@ -3,7 +3,7 @@
# Copyright (C) 2019, Raspberry Pi Ltd
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# raspberrypi.py - ALSC module for tuning Raspberry Pi
+# ALSC module for tuning Raspberry Pi
from .lsc import LSC
diff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py
index 5701ae0a..20406e43 100644
--- a/utils/tuning/libtuning/modules/lsc/rkisp1.py
+++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py
@@ -3,7 +3,7 @@
# Copyright (C) 2019, Raspberry Pi Ltd
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# rkisp1.py - LSC module for tuning rkisp1
+# LSC module for tuning rkisp1
from .lsc import LSC
diff --git a/utils/tuning/libtuning/modules/module.py b/utils/tuning/libtuning/modules/module.py
index 12e2fc7c..de624384 100644
--- a/utils/tuning/libtuning/modules/module.py
+++ b/utils/tuning/libtuning/modules/module.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# module.py - Base class for algorithm-specific tuning modules
+# Base class for algorithm-specific tuning modules
# @var type Type of the module. Defined in the base module.
diff --git a/utils/tuning/libtuning/parsers/parser.py b/utils/tuning/libtuning/parsers/parser.py
index a17d8d71..0c3944c7 100644
--- a/utils/tuning/libtuning/parsers/parser.py
+++ b/utils/tuning/libtuning/parsers/parser.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# parser.py - Base class for a parser for a specific format of config file
+# Base class for a parser for a specific format of config file
class Parser(object):
def __init__(self):
diff --git a/utils/tuning/libtuning/parsers/raspberrypi_parser.py b/utils/tuning/libtuning/parsers/raspberrypi_parser.py
index d26586ba..f1da4592 100644
--- a/utils/tuning/libtuning/parsers/raspberrypi_parser.py
+++ b/utils/tuning/libtuning/parsers/raspberrypi_parser.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# raspberrypi_parser.py - Parser for Raspberry Pi config file format
+# Parser for Raspberry Pi config file format
from .parser import Parser
diff --git a/utils/tuning/libtuning/parsers/yaml_parser.py b/utils/tuning/libtuning/parsers/yaml_parser.py
index 5c1673a5..244db24d 100644
--- a/utils/tuning/libtuning/parsers/yaml_parser.py
+++ b/utils/tuning/libtuning/parsers/yaml_parser.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# yaml_parser.py - Parser for YAML format config file
+# Parser for YAML format config file
from .parser import Parser
diff --git a/utils/tuning/libtuning/smoothing.py b/utils/tuning/libtuning/smoothing.py
index b8a5a242..de4d920c 100644
--- a/utils/tuning/libtuning/smoothing.py
+++ b/utils/tuning/libtuning/smoothing.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# smoothing.py - Wrapper for cv2 smoothing functions to enable duck-typing
+# Wrapper for cv2 smoothing functions to enable duck-typing
import cv2
diff --git a/utils/tuning/libtuning/utils.py b/utils/tuning/libtuning/utils.py
index b60f2c9b..1e8128ea 100644
--- a/utils/tuning/libtuning/utils.py
+++ b/utils/tuning/libtuning/utils.py
@@ -3,7 +3,7 @@
# Copyright (C) 2019, Raspberry Pi Ltd
# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
#
-# utils.py - Utilities for libtuning
+# Utilities for libtuning
import decimal
import math