[libcamera-devel,v3,12/12] utils: tuning: Add tuning script for rkisp1
diff mbox series

Message ID 20221110173154.488445-13-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • utils: tuning: Add a new tuning infrastructure
Related show

Commit Message

Paul Elder Nov. 10, 2022, 5:31 p.m. UTC
Add a tuning script for rkisp1 that uses libtuning. So far it only
supports LSC.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v3:
- cosmetic changes / fix style
- add __main__ guard
- rename ALSC to LSC

Changes in v2:
- add SPDX and copyright
- s/average_functions/average/
- update the script to work with the new rkisp1 alsc module

v1:
This won't run as we're missing the necessary parser and generator for
yaml, parabolic gradient support, and multiple green support in the LSC
module, hence the DNI. As soon as those are added though, this *should*
work.
---
 utils/tuning/rkisp1.py | 43 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100755 utils/tuning/rkisp1.py

Comments

Laurent Pinchart Nov. 23, 2022, 12:35 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Fri, Nov 11, 2022 at 02:31:54AM +0900, Paul Elder via libcamera-devel wrote:
> Add a tuning script for rkisp1 that uses libtuning. So far it only
> supports LSC.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> Changes in v3:
> - cosmetic changes / fix style
> - add __main__ guard
> - rename ALSC to LSC
> 
> Changes in v2:
> - add SPDX and copyright
> - s/average_functions/average/
> - update the script to work with the new rkisp1 alsc module
> 
> v1:
> This won't run as we're missing the necessary parser and generator for
> yaml, parabolic gradient support, and multiple green support in the LSC
> module, hence the DNI. As soon as those are added though, this *should*
> work.
> ---
>  utils/tuning/rkisp1.py | 43 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
>  create mode 100755 utils/tuning/rkisp1.py
> 
> diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py
> new file mode 100755
> index 00000000..a8cb0c39
> --- /dev/null
> +++ b/utils/tuning/rkisp1.py
> @@ -0,0 +1,43 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +#
> +# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
> +#
> +# rkisp1.py - Tuning script for rkisp1
> +
> +import sys
> +
> +import libtuning as lt
> +from libtuning.parsers import YamlParser
> +from libtuning.generators import YamlOutput
> +from libtuning.modules.lsc import LSCRkISP1
> +
> +tuner = lt.Tuner('RkISP1')
> +tuner.add(LSCRkISP1(
> +          # This can support other debug options (I can't think of any right
> +          # now, but for future-proofing).
> +          debug=[lt.Debug.Plot],
> +
> +          # This is for the actual LSC tuning, and is part of the base ALSC

s/ALSC/LSC/. Same below.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +          # module. rkisp1's table sector sizes (16x16 programmed as mirrored
> +          # 8x8) are separate, and is hardcoded in its specific ALSC tuning
> +          # module.
> +          sector_shape=(17, 17),
> +
> +          sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),
> +          sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),
> +
> +          # This is the function that will be used to average the pixels in
> +          # each sector. This can also be a custom function.
> +          sector_average_function=lt.average.Mean(),
> +
> +          # This is the function that will be used to smooth the color ratio
> +          # values.  This can also be a custom function.
> +          smoothing_function=lt.smoothing.MedianBlur(3),
> +          ))
> +tuner.set_input_parser(YamlParser())
> +tuner.set_output_formatter(YamlOutput())
> +tuner.set_output_order([LSCRkISP1])
> +
> +if __name__ == '__main__':
> +    sys.exit(tuner.run(sys.argv))

Patch
diff mbox series

diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py
new file mode 100755
index 00000000..a8cb0c39
--- /dev/null
+++ b/utils/tuning/rkisp1.py
@@ -0,0 +1,43 @@ 
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>
+#
+# rkisp1.py - Tuning script for rkisp1
+
+import sys
+
+import libtuning as lt
+from libtuning.parsers import YamlParser
+from libtuning.generators import YamlOutput
+from libtuning.modules.lsc import LSCRkISP1
+
+tuner = lt.Tuner('RkISP1')
+tuner.add(LSCRkISP1(
+          # This can support other debug options (I can't think of any right
+          # now, but for future-proofing).
+          debug=[lt.Debug.Plot],
+
+          # This is for the actual LSC tuning, and is part of the base ALSC
+          # module. rkisp1's table sector sizes (16x16 programmed as mirrored
+          # 8x8) are separate, and is hardcoded in its specific ALSC tuning
+          # module.
+          sector_shape=(17, 17),
+
+          sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),
+          sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),
+
+          # This is the function that will be used to average the pixels in
+          # each sector. This can also be a custom function.
+          sector_average_function=lt.average.Mean(),
+
+          # This is the function that will be used to smooth the color ratio
+          # values.  This can also be a custom function.
+          smoothing_function=lt.smoothing.MedianBlur(3),
+          ))
+tuner.set_input_parser(YamlParser())
+tuner.set_output_formatter(YamlOutput())
+tuner.set_output_order([LSCRkISP1])
+
+if __name__ == '__main__':
+    sys.exit(tuner.run(sys.argv))