ipa: raspberrypi: Use the generic statistics structure in the algorithms
Repurpose the StatisticsPtr type from being a shared_ptr<bcm2835_isp_stats> to shared_ptr<RPiController::Statistics>. This removes any hardware specific header files and structures from the algorithms source code. Add a new function in the Raspberry Pi IPA to populate the generic statistics structure from the values provided by the hardware in the bcm2835_isp_stats structure. Update the Lux, AWB, AGC, ALSC, Contrast, and Focus algorithms to use the generic statistics structure appropriately in their calculations. Additionally, remove references to any hardware specific headers and defines in these source files. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Tested-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
e8dd0fdc83
commit
6d60f264d1
15 changed files with 121 additions and 87 deletions
|
@ -310,19 +310,21 @@ double getCt(Metadata *metadata, double defaultCt)
|
|||
return awbStatus.temperatureK;
|
||||
}
|
||||
|
||||
static void copyStats(bcm2835_isp_stats_region regions[XY], StatisticsPtr &stats,
|
||||
static void copyStats(RgbyRegions ®ions, StatisticsPtr &stats,
|
||||
AlscStatus const &status)
|
||||
{
|
||||
bcm2835_isp_stats_region *inputRegions = stats->awb_stats;
|
||||
if (!regions.numRegions())
|
||||
regions.init(stats->awbRegions.size());
|
||||
|
||||
double *rTable = (double *)status.r;
|
||||
double *gTable = (double *)status.g;
|
||||
double *bTable = (double *)status.b;
|
||||
for (int i = 0; i < XY; i++) {
|
||||
regions[i].r_sum = inputRegions[i].r_sum / rTable[i];
|
||||
regions[i].g_sum = inputRegions[i].g_sum / gTable[i];
|
||||
regions[i].b_sum = inputRegions[i].b_sum / bTable[i];
|
||||
regions[i].counted = inputRegions[i].counted;
|
||||
/* (don't care about the uncounted value) */
|
||||
for (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) {
|
||||
auto r = stats->awbRegions.get(i);
|
||||
r.val.rSum = static_cast<uint64_t>(r.val.rSum / rTable[i]);
|
||||
r.val.gSum = static_cast<uint64_t>(r.val.gSum / gTable[i]);
|
||||
r.val.bSum = static_cast<uint64_t>(r.val.bSum / bTable[i]);
|
||||
regions.set(i, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,19 +514,19 @@ void resampleCalTable(double const calTableIn[XY],
|
|||
}
|
||||
|
||||
/* Calculate chrominance statistics (R/G and B/G) for each region. */
|
||||
static_assert(XY == AWB_REGIONS, "ALSC/AWB statistics region mismatch");
|
||||
static void calculateCrCb(bcm2835_isp_stats_region *awbRegion, double cr[XY],
|
||||
static void calculateCrCb(const RgbyRegions &awbRegion, double cr[XY],
|
||||
double cb[XY], uint32_t minCount, uint16_t minG)
|
||||
{
|
||||
for (int i = 0; i < XY; i++) {
|
||||
bcm2835_isp_stats_region &zone = awbRegion[i];
|
||||
if (zone.counted <= minCount ||
|
||||
zone.g_sum / zone.counted <= minG) {
|
||||
auto s = awbRegion.get(i);
|
||||
|
||||
if (s.counted <= minCount || s.val.gSum / s.counted <= minG) {
|
||||
cr[i] = cb[i] = InsufficientData;
|
||||
continue;
|
||||
}
|
||||
cr[i] = zone.r_sum / (double)zone.g_sum;
|
||||
cb[i] = zone.b_sum / (double)zone.g_sum;
|
||||
|
||||
cr[i] = s.val.rSum / (double)s.val.gSum;
|
||||
cb[i] = s.val.bSum / (double)s.val.gSum;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue