summaryrefslogtreecommitdiff
path: root/src/ipa/libipa/awb_bayes.cpp
AgeCommit message (Collapse)Author
4 dayslibcamera: Drop spurious colon after doxygen \todo directiveLaurent Pinchart
The doxygen \todo directive doesn't need to be followed by a colon. Drop it. While at it, turn one 'todo:' into '\todo'. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
4 dayslibipa: awb: Tidy up includesLaurent Pinchart
Drop unneeded headers and add missing ones. The yaml_parser.h header is dropped from awb_grey.h as the classes it provides are only used in virtual functions defined by the base class, so any required definitions are guaranteed to be available already. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
4 dayslibipa: awb: Pass lux value to calculateAwb() as unsigned intLaurent Pinchart
The lux value can never be negative. Pass it as an unsigned int. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
7 dayslibipa: awb_bayes: Change the probabilities from log space to linear spaceStefan Klug
The original code used to specify the probabilities in log space and scaled for the RaspberryPi hardware with 192 AWB measurement points. This is reasonable as the whole algorithm makes use of unitless numbers to prefer some colour temperatures based on a lux level. These numbers are then hand tuned with the specific device in mind. This has two shortcomings: 1. The linear interpolation of PWLs in log space is mathematically incorrect. The outcome might still be ok, as both spaces (log and linear) are monotonic, but it is still not "right". 2. Having unitless numbers gets more error prone when we try to harmonize the behavior over multiple platforms. Change the algorithm to interpret the numbers as being in linear space. This makes the interpolation mathematically correct at the expense of a few log operations. To account for that change, update the numbers in the tuning example file with the linear counterparts scaled to one AWB zone measurement. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
7 dayslibipa: awb_bayes: Remove overly verbose log messagesStefan Klug
Logging every search step is too verbose even with debug messages enabled and it hides the more important messages (min max values of errors and likelihoods). Remove the debug messages in a separate commit, so that it can easily be reverted if needed. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
7 dayslibipa: awb_bayes: Add logging of value limitsStefan Klug
When tuning the AWB algorithm it is more helpful to get a feeling for the value ranges than to get verbose output of every single step. Add a small utility class to track the limits and log them. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
7 dayslibipa: Add bayesian AWB algorithmStefan Klug
The bayesian AWB algorithm is an AWB algorithm that takes prior probabilities for a given light source dependent on the current lux level into account. The biggest improvement compared to the grey world model comes from the search of the ideal white point on the CT curve. The algorithm walks the CT curve to minimize the colour error for a given statistics. After the minimium is found it additionally tries to search the area around that spot and also off the curve. So even without defined prior probabilities this algorithm provides much better results than the grey world algorithm. The logic for this code was taken from the RaspberryPi implementation. The logic was only minimally adjusted for usage with the rkisp1 and a few things were left out (see doxygen doc for the AwbBayes class). The code is refactored to better fit the libcamera code style and to make use of the syntactic sugar provided by the Interpolator and Vector classes. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>