libcamera v0.7.2+rpt20261009
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
awb.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2021, Ideas On Board
4 *
5 * IPU3 AWB control algorithm
6 */
7
8#pragma once
9
10#include <vector>
11
12#include <linux/intel-ipu3.h>
13
14#include <libcamera/geometry.h>
15
16#include "libipa/awb.h"
17#include "libipa/fixedpoint.h"
18
19#include "algorithm.h"
20
21namespace libcamera {
22
23namespace ipa::ipu3::algorithms {
24
25class Ipu3AwbStats;
26
27/* Region size for the statistics generation algorithm */
28static constexpr uint32_t kAwbStatsSizeX = 16;
29static constexpr uint32_t kAwbStatsSizeY = 12;
30
32 unsigned int counted;
33 struct {
34 uint64_t red;
35 uint64_t green;
36 uint64_t blue;
37 } sum;
38};
39
40class Awb : public Algorithm
41{
42public:
43 Awb();
44
45 int init(IPAContext &context, const ValueNode &tuningData) override;
46 int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
47 void queueRequest(IPAContext &context, const uint32_t frame,
48 IPAFrameContext &frameContext,
49 const ControlList &controls) override;
50 void prepare(IPAContext &context, const uint32_t frame,
51 IPAFrameContext &frameContext,
52 ipu3_uapi_params *params) override;
53 void process(IPAContext &context, const uint32_t frame,
54 IPAFrameContext &frameContext,
55 const ipu3_uapi_stats_3a *stats,
56 ControlList &metadata) override;
57
58private:
59 Ipu3AwbStats calculateRgbMeans(const ipu3_uapi_stats_3a *stats);
60 void generateZones();
61 void generateAwbStats(const ipu3_uapi_stats_3a *stats);
62 void clearAwbStats();
63 void awbGreyWorld();
64 static constexpr uint16_t threshold(float value);
65 static constexpr uint16_t gainValue(double gain);
66
67 std::vector<RGB<double>> zones_;
68 Accumulator awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];
69 AwbAlgorithm<UQ<3, 13>> awbAlgo_;
70
71 uint32_t stride_;
72 uint32_t cellsPerZoneX_;
73 uint32_t cellsPerZoneY_;
74 uint32_t cellsPerZoneThreshold_;
75};
76
77} /* namespace ipa::ipu3::algorithms */
78
79} /* namespace libcamera*/
Associate a list of ControlId with their values for an object.
Definition controls.h:453
A class representing a tree structure of values.
Definition value_node.h:27
The base class for all IPA algorithms.
Definition algorithm.h:23
The libipa AWB algorithm.
Definition awb.h:114
The IPU3 white balance correction algorithm implementation.
Definition awb.h:41
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override
Configure the Algorithm given an IPAConfigInfo.
Definition awb.cpp:234
int init(IPAContext &context, const ValueNode &tuningData) override
Initialize the Algorithm with tuning data.
Definition awb.cpp:226
void prepare(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, ipu3_uapi_params *params) override
Fill the params buffer with ISP processing parameters for a frame.
Definition awb.cpp:293
void process(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, const ipu3_uapi_stats_3a *stats, ControlList &metadata) override
Process ISP statistics, and run algorithm operations.
Definition awb.cpp:468
void queueRequest(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, const ControlList &controls) override
Provide control values to the algorithm.
Definition awb.cpp:259
The IPU3 specific implementation of AwbStats.
Definition awb.cpp:35
Data structures related to geometric objects.
Algorithm common interface.
libipa AWB implementation
Top-level libcamera namespace.
Definition backtrace.h:17
Global IPA context data shared between all algorithms.
Definition ipa_context.h:73
IPU3-specific FrameContext.
Definition ipa_context.h:60
RGB statistics for a given zone.
Definition awb.h:31
unsigned int counted
Number of unsaturated cells used to calculate the sums.
Definition awb.h:32
uint64_t red
Sum of the average red values of each unsaturated cell in the zone.
Definition awb.h:34
struct libcamera::ipa::ipu3::algorithms::Accumulator::@4 sum
A structure containing the average red, green and blue sums.
uint64_t blue
Sum of the average blue values of each unsaturated cell in the zone.
Definition awb.h:36
uint64_t green
Sum of the average green values of each unsaturated cell in the zone.
Definition awb.h:35