[v1,1/2] utils: tuning: rkisp1: Clean up tuner construction
diff mbox series

Message ID 20240805070644.1536232-2-stefan.klug@ideasonboard.com
State Accepted
Headers show
Series
  • Two small tuning script cleanups
Related show

Commit Message

Stefan Klug Aug. 5, 2024, 7:06 a.m. UTC
The instances of the static modules need to be passed to
tuner.set_output_order() instead of the class.  This is the reason for
the intermediate variables. To keep the code tidy, apply the same
pattern to the other modules.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 utils/tuning/rkisp1.py | 47 +++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

Comments

Kieran Bingham Aug. 5, 2024, 7:34 a.m. UTC | #1
Quoting Stefan Klug (2024-08-05 08:06:32)
> The instances of the static modules need to be passed to
> tuner.set_output_order() instead of the class.  This is the reason for
> the intermediate variables. To keep the code tidy, apply the same
> pattern to the other modules.
> 

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

> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  utils/tuning/rkisp1.py | 47 +++++++++++++++++++++---------------------
>  1 file changed, 24 insertions(+), 23 deletions(-)
> 
> diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py
> index 0d279a39ab1b..5d7a69fc4a13 100755
> --- a/utils/tuning/rkisp1.py
> +++ b/utils/tuning/rkisp1.py
> @@ -19,44 +19,45 @@ from libtuning.modules.static import StaticModule
>  
>  coloredlogs.install(level=logging.INFO, fmt='%(name)s %(levelname)s %(message)s')
>  
> +agc = AGCRkISP1(debug=[lt.Debug.Plot])
>  awb = StaticModule('Awb')
>  blc = StaticModule('BlackLevelCorrection')
> +ccm = CCMRkISP1(debug=[lt.Debug.Plot])
>  color_processing = StaticModule('ColorProcessing')
>  filter = StaticModule('Filter')
>  gamma_out = StaticModule('GammaOutCorrection', {'gamma': 2.2})
> +lsc = LSCRkISP1(debug=[lt.Debug.Plot],
> +                # This is for the actual LSC tuning, and is part of the base LSC
> +                # module. rkisp1's table sector sizes (16x16 programmed as mirrored
> +                # 8x8) are separate, and is hardcoded in its specific LSC 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 = lt.Tuner('RkISP1')
> -tuner.add(AGCRkISP1(debug=[lt.Debug.Plot]))
> +tuner.add(agc)
>  tuner.add(awb)
>  tuner.add(blc)
> -tuner.add(CCMRkISP1(debug=[lt.Debug.Plot]))
> +tuner.add(ccm)
>  tuner.add(color_processing)
>  tuner.add(filter)
>  tuner.add(gamma_out)
> -tuner.add(LSCRkISP1(
> -          debug=[lt.Debug.Plot],
> -          # This is for the actual LSC tuning, and is part of the base LSC
> -          # module. rkisp1's table sector sizes (16x16 programmed as mirrored
> -          # 8x8) are separate, and is hardcoded in its specific LSC 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.add(lsc)
>  
>  tuner.set_input_parser(YamlParser())
>  tuner.set_output_formatter(YamlOutput())
> -tuner.set_output_order([AGCRkISP1, awb, blc, CCMRkISP1, color_processing,
> -                        filter, gamma_out, LSCRkISP1])
> +tuner.set_output_order([agc, awb, blc, ccm, color_processing,
> +                        filter, gamma_out, lsc])
>  
>  if __name__ == '__main__':
>      sys.exit(tuner.run(sys.argv))
> -- 
> 2.43.0
>
Paul Elder Aug. 14, 2024, 7:54 a.m. UTC | #2
On Mon, Aug 05, 2024 at 09:06:32AM +0200, Stefan Klug wrote:
> The instances of the static modules need to be passed to

Strictly speaking the matching is done via the class variable 'type', so
you only need the pass the class. StaticModule is special in that the
class variable 'type' is dependent on the instance...

> tuner.set_output_order() instead of the class.  This is the reason for
> the intermediate variables. To keep the code tidy, apply the same
> pattern to the other modules.

But still this makes it cleaner so

> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>

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

> ---
>  utils/tuning/rkisp1.py | 47 +++++++++++++++++++++---------------------
>  1 file changed, 24 insertions(+), 23 deletions(-)
> 
> diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py
> index 0d279a39ab1b..5d7a69fc4a13 100755
> --- a/utils/tuning/rkisp1.py
> +++ b/utils/tuning/rkisp1.py
> @@ -19,44 +19,45 @@ from libtuning.modules.static import StaticModule
>  
>  coloredlogs.install(level=logging.INFO, fmt='%(name)s %(levelname)s %(message)s')
>  
> +agc = AGCRkISP1(debug=[lt.Debug.Plot])
>  awb = StaticModule('Awb')
>  blc = StaticModule('BlackLevelCorrection')
> +ccm = CCMRkISP1(debug=[lt.Debug.Plot])
>  color_processing = StaticModule('ColorProcessing')
>  filter = StaticModule('Filter')
>  gamma_out = StaticModule('GammaOutCorrection', {'gamma': 2.2})
> +lsc = LSCRkISP1(debug=[lt.Debug.Plot],
> +                # This is for the actual LSC tuning, and is part of the base LSC
> +                # module. rkisp1's table sector sizes (16x16 programmed as mirrored
> +                # 8x8) are separate, and is hardcoded in its specific LSC 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 = lt.Tuner('RkISP1')
> -tuner.add(AGCRkISP1(debug=[lt.Debug.Plot]))
> +tuner.add(agc)
>  tuner.add(awb)
>  tuner.add(blc)
> -tuner.add(CCMRkISP1(debug=[lt.Debug.Plot]))
> +tuner.add(ccm)
>  tuner.add(color_processing)
>  tuner.add(filter)
>  tuner.add(gamma_out)
> -tuner.add(LSCRkISP1(
> -          debug=[lt.Debug.Plot],
> -          # This is for the actual LSC tuning, and is part of the base LSC
> -          # module. rkisp1's table sector sizes (16x16 programmed as mirrored
> -          # 8x8) are separate, and is hardcoded in its specific LSC 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.add(lsc)
>  
>  tuner.set_input_parser(YamlParser())
>  tuner.set_output_formatter(YamlOutput())
> -tuner.set_output_order([AGCRkISP1, awb, blc, CCMRkISP1, color_processing,
> -                        filter, gamma_out, LSCRkISP1])
> +tuner.set_output_order([agc, awb, blc, ccm, color_processing,
> +                        filter, gamma_out, lsc])
>  
>  if __name__ == '__main__':
>      sys.exit(tuner.run(sys.argv))
> -- 
> 2.43.0
>

Patch
diff mbox series

diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py
index 0d279a39ab1b..5d7a69fc4a13 100755
--- a/utils/tuning/rkisp1.py
+++ b/utils/tuning/rkisp1.py
@@ -19,44 +19,45 @@  from libtuning.modules.static import StaticModule
 
 coloredlogs.install(level=logging.INFO, fmt='%(name)s %(levelname)s %(message)s')
 
+agc = AGCRkISP1(debug=[lt.Debug.Plot])
 awb = StaticModule('Awb')
 blc = StaticModule('BlackLevelCorrection')
+ccm = CCMRkISP1(debug=[lt.Debug.Plot])
 color_processing = StaticModule('ColorProcessing')
 filter = StaticModule('Filter')
 gamma_out = StaticModule('GammaOutCorrection', {'gamma': 2.2})
+lsc = LSCRkISP1(debug=[lt.Debug.Plot],
+                # This is for the actual LSC tuning, and is part of the base LSC
+                # module. rkisp1's table sector sizes (16x16 programmed as mirrored
+                # 8x8) are separate, and is hardcoded in its specific LSC 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 = lt.Tuner('RkISP1')
-tuner.add(AGCRkISP1(debug=[lt.Debug.Plot]))
+tuner.add(agc)
 tuner.add(awb)
 tuner.add(blc)
-tuner.add(CCMRkISP1(debug=[lt.Debug.Plot]))
+tuner.add(ccm)
 tuner.add(color_processing)
 tuner.add(filter)
 tuner.add(gamma_out)
-tuner.add(LSCRkISP1(
-          debug=[lt.Debug.Plot],
-          # This is for the actual LSC tuning, and is part of the base LSC
-          # module. rkisp1's table sector sizes (16x16 programmed as mirrored
-          # 8x8) are separate, and is hardcoded in its specific LSC 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.add(lsc)
 
 tuner.set_input_parser(YamlParser())
 tuner.set_output_formatter(YamlOutput())
-tuner.set_output_order([AGCRkISP1, awb, blc, CCMRkISP1, color_processing,
-                        filter, gamma_out, LSCRkISP1])
+tuner.set_output_order([agc, awb, blc, ccm, color_processing,
+                        filter, gamma_out, lsc])
 
 if __name__ == '__main__':
     sys.exit(tuner.run(sys.argv))