File: awb.py

package info (click to toggle)
libcamera 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,488 kB
  • sloc: cpp: 85,656; python: 18,099; ansic: 12,763; sh: 1,309; makefile: 60
file content (40 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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]

        ct_curve, transverse_pos, transverse_neg = awb(imgs, None, None, False)
        ct_curve = np.reshape(ct_curve, (-1, 3))
        gains = [{
            'ct': int(v[0]),
            'gains': [float(1.0 / v[1]), float(1.0 / v[2])]
        } for v in ct_curve]

        return {'colourGains': gains,
                'transversePos': transverse_pos,
                'transverseNeg': transverse_neg}