libtuning: module: awb: Add bayes AWB support

To support the bayesian AWB algorithm in libtuning, the necessary data
needs to be collected and written to the tuning file.

Extend libtuning to calculate and output that additional data.

Prior probabilities and AwbModes are manually specified and not
calculated in the tuning process. Add sample values from the RaspberryPi
tuning files to the example config file.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Stefan Klug 2025-01-23 12:40:58 +01:00
parent deb3f05137
commit 60d60c1367
3 changed files with 67 additions and 12 deletions

View file

@ -6,9 +6,6 @@
from .awb import AWB
import libtuning as lt
class AWBRkISP1(AWB):
hr_name = 'AWB (RkISP1)'
out_name = 'Awb'
@ -20,8 +17,20 @@ class AWBRkISP1(AWB):
return True
def process(self, config: dict, images: list, outputs: dict) -> dict:
output = {}
if not 'awb' in config['general']:
raise ValueError('AWB configuration missing')
awb_config = config['general']['awb']
algorithm = awb_config['algorithm']
output['colourGains'] = self.do_calculation(images)
output = {'algorithm': algorithm}
data = self.do_calculation(images)
if algorithm == 'grey':
output['colourGains'] = data['colourGains']
elif algorithm == 'bayes':
output['AwbMode'] = awb_config['AwbMode']
output['priors'] = awb_config['priors']
output.update(data)
else:
raise ValueError(f"Unknown AWB algorithm {output['algorithm']}")
return output