Loading...
Searching...
No Matches
awb.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2021, Ideas On Board
*
* IPU3 AWB control algorithm
*/
#pragma once
#include <vector>
#include <linux/intel-ipu3.h>
#include <libcamera/geometry.h>
#include "libcamera/internal/vector.h"
#include "algorithm.h"
namespace libcamera {
namespace ipa::ipu3::algorithms {
/* Region size for the statistics generation algorithm */
static constexpr uint32_t kAwbStatsSizeX = 16;
static constexpr uint32_t kAwbStatsSizeY = 12;
struct Accumulator {
unsigned int counted;
struct {
uint64_t red;
uint64_t green;
uint64_t blue;
} sum;
};
class Awb : public Algorithm
{
public:
Awb();
~Awb();
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
void prepare(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
ipu3_uapi_params *params) override;
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats,
ControlList &metadata) override;
private:
struct AwbStatus {
double temperatureK;
double redGain;
double greenGain;
double blueGain;
};
private:
void calculateWBGains(const ipu3_uapi_stats_3a *stats);
void generateZones();
void generateAwbStats(const ipu3_uapi_stats_3a *stats);
void clearAwbStats();
void awbGreyWorld();
static constexpr uint16_t threshold(float value);
static constexpr uint16_t gainValue(double gain);
std::vector<RGB<double>> zones_;
Accumulator awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];
AwbStatus asyncResults_;
uint32_t stride_;
uint32_t cellsPerZoneX_;
uint32_t cellsPerZoneY_;
uint32_t cellsPerZoneThreshold_;
};
} /* namespace ipa::ipu3::algorithms */
} /* namespace libcamera*/
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
libcamera::ipa::ipu3::algorithms::Awb::configure
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override
Configure the Algorithm given an IPAConfigInfo.
Definition awb.cpp:203
libcamera::ipa::ipu3::algorithms::Awb::prepare
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:249
libcamera::ipa::ipu3::algorithms::Awb::process
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:450
geometry.h
Data structures related to geometric objects.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::ipa::ipu3::IPAContext
Global IPA context data shared between all algorithms.
Definition ipa_context.h:86
libcamera::ipa::ipu3::IPAFrameContext
IPU3-specific FrameContext.
Definition ipa_context.h:79
libcamera::ipa::ipu3::algorithms::Accumulator
RGB statistics for a given zone.
Definition awb.h:28
libcamera::ipa::ipu3::algorithms::Accumulator::sum
struct libcamera::ipa::ipu3::algorithms::Accumulator::@046015366141165261174332173113205110321337047250 sum
A structure containing the average red, green and blue sums.
libcamera::ipa::ipu3::algorithms::Accumulator::red
uint64_t red
Sum of the average red values of each unsaturated cell in the zone.
Definition awb.h:31
libcamera::ipa::ipu3::algorithms::Accumulator::blue
uint64_t blue
Sum of the average blue values of each unsaturated cell in the zone.
Definition awb.h:33
libcamera::ipa::ipu3::algorithms::Accumulator::counted
unsigned int counted
Number of unsaturated cells used to calculate the sums.
Definition awb.h:29
libcamera::ipa::ipu3::algorithms::Accumulator::green
uint64_t green
Sum of the average green values of each unsaturated cell in the zone.
Definition awb.h:32
vector.h
Vector class.