File: rkisp1.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 (36 lines) | stat: -rw-r--r-- 1,082 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
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2024, Ideas On Board
#
# AWB module for tuning rkisp1

from .awb import AWB

class AWBRkISP1(AWB):
    hr_name = 'AWB (RkISP1)'
    out_name = 'Awb'

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def validate_config(self, config: dict) -> bool:
        return True

    def process(self, config: dict, images: list, outputs: dict) -> dict:
        if not 'awb' in config['general']:
            raise ValueError('AWB configuration missing')
        awb_config = config['general']['awb']
        algorithm = awb_config['algorithm']

        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