WIP: AUTOFOCUS
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
51d6ca752d
commit
8eae1f8dda
2 changed files with 16 additions and 2 deletions
|
@ -44,6 +44,10 @@ struct SwIspStats {
|
|||
* \brief A histogram of luminance values
|
||||
*/
|
||||
Histogram yHistogram;
|
||||
/**
|
||||
* \brief Holds the sharpness of an image
|
||||
*/
|
||||
uint64_t sharpness;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
|
@ -147,7 +147,8 @@ static constexpr unsigned int kBlueYMul = 29; /* 0.114 * 256 */
|
|||
\
|
||||
uint64_t sumR = 0; \
|
||||
uint64_t sumG = 0; \
|
||||
uint64_t sumB = 0;
|
||||
uint64_t sumB = 0; \
|
||||
uint64_t sharpness = 0;
|
||||
|
||||
#define SWSTATS_ACCUMULATE_LINE_STATS(div) \
|
||||
sumR += r; \
|
||||
|
@ -162,7 +163,8 @@ static constexpr unsigned int kBlueYMul = 29; /* 0.114 * 256 */
|
|||
#define SWSTATS_FINISH_LINE_STATS() \
|
||||
stats_.sumR_ += sumR; \
|
||||
stats_.sumG_ += sumG; \
|
||||
stats_.sumB_ += sumB;
|
||||
stats_.sumB_ += sumB; \
|
||||
stats_.sharpness += sharpness;
|
||||
|
||||
void SwStatsCpu::statsBGGR8Line0(const uint8_t *src[])
|
||||
{
|
||||
|
@ -174,6 +176,13 @@ void SwStatsCpu::statsBGGR8Line0(const uint8_t *src[])
|
|||
if (swapLines_)
|
||||
std::swap(src0, src1);
|
||||
|
||||
for(int x = 0; x < (int)window_.width; x+=2){
|
||||
int sum = 0;
|
||||
sum += src0[x-2];
|
||||
sum += src0[x+2];
|
||||
sum -= 2*src0[x];
|
||||
sharpness += sum*sum;
|
||||
}
|
||||
/* x += 4 sample every other 2x2 block */
|
||||
for (int x = 0; x < (int)window_.width; x += 4) {
|
||||
b = src0[x];
|
||||
|
@ -320,6 +329,7 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)
|
|||
{
|
||||
*sharedStats_ = stats_;
|
||||
statsReady.emit(frame, bufferId);
|
||||
LOG(SwStatsCpu, Error) << "Sharpness" << stats_.sharpness;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue