mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-14 16:09:51 +03:00
This AWB module uses the awb function from Raspberry Pi to calculate the needed white balance gains per colour temperature. It stores these gains in the tuning file. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
36 lines
816 B
Python
36 lines
816 B
Python
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
#
|
|
# Copyright (C) 2024, Ideas On Board
|
|
|
|
import logging
|
|
|
|
from ..module import Module
|
|
|
|
from libtuning.ctt_awb import awb
|
|
import numpy as np
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class AWB(Module):
|
|
type = 'awb'
|
|
hr_name = 'AWB (Base)'
|
|
out_name = 'GenericAWB'
|
|
|
|
def __init__(self, *, debug: list):
|
|
super().__init__()
|
|
|
|
self.debug = debug
|
|
|
|
def do_calculation(self, images):
|
|
logger.info('Starting AWB calculation')
|
|
|
|
imgs = [img for img in images if img.macbeth is not None]
|
|
|
|
gains, _, _ = awb(imgs, None, None, False)
|
|
gains = np.reshape(gains, (-1, 3))
|
|
|
|
return [{
|
|
'ct': int(v[0]),
|
|
'gains': [float(1.0 / v[1]), float(1.0 / v[2])]
|
|
} for v in gains]
|