88c69f8808
The Histogram constructor does not modify the data. Pass it a Span<const uint32_t> instead of a Span<uint32_t>. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
39 lines
821 B
C++
39 lines
821 B
C++
/* SPDX-License-Identifier: BSD-2-Clause */
|
|
/*
|
|
* Copyright (C) 2019, Raspberry Pi (Trading) Limited
|
|
*
|
|
* histogram.h - histogram calculation interface
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <assert.h>
|
|
#include <limits.h>
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <libcamera/base/span.h>
|
|
|
|
namespace libcamera {
|
|
|
|
namespace ipa {
|
|
|
|
class Histogram
|
|
{
|
|
public:
|
|
Histogram(Span<const uint32_t> data);
|
|
size_t bins() const { return cumulative_.size() - 1; }
|
|
uint64_t total() const { return cumulative_[cumulative_.size() - 1]; }
|
|
uint64_t cumulativeFrequency(double bin) const;
|
|
double quantile(double q, uint32_t first = 0, uint32_t last = UINT_MAX) const;
|
|
double interQuantileMean(double lowQuantile, double hiQuantile) const;
|
|
|
|
private:
|
|
std::vector<uint64_t> cumulative_;
|
|
};
|
|
|
|
} /* namespace ipa */
|
|
|
|
} /* namespace libcamera */
|