summaryrefslogtreecommitdiff
path: root/utils/tuning
AgeCommit message (Collapse)Author
2024-07-05libtuning: lsc: rkisp1: Clip lsc values to valid rangeStefan Klug
Based on the input images, the lsc values could exceed the range allowed by the rkisp1. As we are now clipping the values, we can simplify the value mapping. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-07-05libtuning: Be a bit more verboseStefan Klug
Print a info on every image that gets processed and a warning on every image that gets ignored. 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>
2024-07-05libtuning: Reactivate macbeth locatorStefan Klug
Add the missing pieces and store the result inside the image object. This solution is not very nice, and should be refactored soon. For that we need a concept to collect temperature and/or image specific results in a central place. For now it serves the purpose. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-07-05libtuning: Implement a minimal yaml parserStefan Klug
At the moment this just reads the yaml file and returns it verbatim. This needs to evolve further in the near future. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-07-05libtuning: Improve filename parsingStefan Klug
In the tuning datasets, the files had names like 'imx335_1600l_3000k_1.dng'. That failed on the old filename parsing function. As there is no need to dictate the order of the tags, split the big regex into chunks and parse them one by one. This also makes the code easier to digest. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-07-05libtuning: Fix visualize_macbeth_chart()Stefan Klug
The old function uses PIL to save the image, which is not in the requirements file. As we are already requiring opencv, use that to save images instead of an additional dependency Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-07-05libtuning: Migrate prints to python logging frameworkStefan Klug
In ctt_ccm.py the logging functionality of the Cam object was used. As we don't want to port over that class, it needs to be replaced anyways. While at it, also replace the eprint function as it doesn't add any value over the logging framework and misses the ability for easy log formatting. For nice output formatting add the coloredlogs library. 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>
2024-07-05libtuning: Fix importsStefan Klug
Fix imports to match new structure in the files copied from Raspberry Pi. Add missing imports in macbeth.py. Add missing dependencies to requirements.txt. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-07-05utils: tuning: Add requirements file and update readmeStefan Klug
Add a requirements file to ease the installation and use of the tuning scripts. Document that in the readme. No debian packages are provided as rawpy is not packaged as deb. So pip has to be used anyways. Also add pyyaml which was missing in the dependencies. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-07-05libtuning: Copy visualize_macbeth_chart from raspberry piStefan Klug
Copy visualize_macbeth_chart from raspberry pi. It is copied verbatim and does not work in this state. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Paul Elder <paul.elder@ideasonboard.com>
2024-07-05libtuning: Copy files from raspberrypiStefan Klug
Copy ctt_{awb,ccm,colors,ransac} from the raspberrypi tuning scripts as basis for the libcamera implementation. color.py was renamed to ctt_colors.py to better express the origin. The files were taken from commit 66479605baca ("utils: raspberrypi: ctt: Improve the Macbeth Chart search reliability"). Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Acked-by: Paul Elder <paul.elder@ideasonboard.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-07-05libtuning: Fix reference imageStefan Klug
Opencv fails to load the image. The added license destroys the magic number. Fix, by moving the licence below the magic number. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul ELder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-07-05libtuning: Backport improvements in MacBeth search reliabilityStefan Klug
Port commit 66479605baca ("utils: raspberrypi: ctt: Improve the Macbeth Chart search reliability") into libtuning. Previously the code would brighten up images in case the Macbeth Chart is slightly dark, and also zoom in on sections of it to look for charts occupying less of the field of view. But it would not do both together. This change makes the search for smaller charts also repeat that search for the brightened up images that it made earlier, thereby increasing the chances of success for non-optimal tuning images. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-06-29utils: libtuning: Correct GBRG Image parsingDaniel Scally
The Image class incorrectly parses data in GBRG bayer formats as the indices to the channels are set incorrectly - fix it. Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-06-14utils: tuning: rkisp1: Add skeletal AGC to the rkisp1 tuning scriptPaul Elder
Add the skeletal AGC module to the rkisp1 tuning script. For now it just spits out hardcoded values. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-06-14utils: libtuning: modules: Add skeletal AGC modulePaul Elder
Add a skeletal AGC module just so that we can have some AGC tuning values that we can use to test during development of AGC in the IPAs. As rkisp1 is the main target, we only add support for rkisp1 for now. The parameters are mostly copied from the hardcoded values in ctt, except for the metering modes. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-05-08libcamera: Drop file name from header comment blocksLaurent Pinchart
Source files in libcamera start by a comment block header, which includes the file name and a one-line description of the file contents. While the latter is useful to get a quick overview of the file contents at a glance, the former is mostly a source of inconvenience. The name in the comments can easily get out of sync with the file name when files are renamed, and copy & paste during development have often lead to incorrect names being used to start with. Readers of the source code are expected to know which file they're looking it. Drop the file name from the header comment block. The change was generated with the following script: ---------------------------------------- dirs="include/libcamera src test utils" declare -rA patterns=( ['c']=' \* ' ['cpp']=' \* ' ['h']=' \* ' ['py']='# ' ['sh']='# ' ) for ext in ${!patterns[@]} ; do files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done) pattern=${patterns[${ext}]} for file in $files ; do name=$(basename ${file}) sed -i "s/^\(${pattern}\)${name} - /\1/" "$file" done done ---------------------------------------- This misses several files that are out of sync with the comment block header. Those will be addressed separately and manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-03-19utils: tuning: readme: Improve names of dependency packagesPaul Elder
Change the names of python packages in the list of dependencies to the exact names that should be used in the pip install command. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2022-11-25utils: tuning: Add tuning script for rkisp1Paul Elder
Add a tuning script for rkisp1 that uses libtuning. So far it only supports LSC. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: tuning: Add alsc-only libtuning raspberrypi tuning scriptPaul Elder
Add a tuning script for raspberrypi for alsc only, that uses libtuning. Since there will also be a tuning script for raspberrypi that has more modules, put the libtuning alsc module definition in a separate file so that it can be reused later. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: libtuning: generators: Add yaml outputPaul Elder
Add a generator to libtuning for writing tuning output to a yaml file. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: libtuning: parsers: Add yaml parserPaul Elder
Add a parser to libtuning for parsing configuration files in yaml format. At the moment it doesn't parse anything and simply returns an empty config. This is fine for the time being, as the only user of it is the rkisp1 tuning script, which only has an LSC module which doesn't consume anything from the configuration file. When a module comes around that requires the yaml parser, it can be implemented then. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: libtuning: generators: Add raspberrypi outputPaul Elder
Add a generator to libtuning for writing tuning output to a json file formatted the same way that raspberrypi's ctt formats them. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: libtuning: parsers: Add raspberrypi parserPaul Elder
Add a parser to libtuning for parsing configuration files that are the same format as raspberrypi's ctt's configuration files. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: libtuning: modules: alsc: Add rkisp1 LSC modulePaul Elder
Add an LSC module for RkISP1. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: libtuning: modules: alsc: Add raspberrypi ALSC modulePaul Elder
Add an ALSC module for Raspberry Pi. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: libtuning: modules: Add base LSC modulePaul Elder
Add a base LSC module to libtuning's collection of modules. It is based on raspberrypi's ctt's ALSC, but customizable for different lens shading table sizes, among other things. It alone is insufficient as a module, but it provides utilities that are useful for and which will simplify implementing LSC modules. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: tuning: libtuning: Implement extensible components of libtuningPaul Elder
Implement the extensible components of libtuning. This includes: - Parsers, for supporting different types of input config file formats - Generators, for supporting different types of output tuning file formats - Modules, for supporting different tuning modules for different algorithms and platforms No parsers, generators, or modules are actually implemented. Only the base classes are implemented. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: tuning: libtuning: Implement math helpersPaul Elder
Implement math helpers for libtuning. This includes: - Average, a wrapper class for numpy averaging functions - Gradient, a class that represents gradients, for distributing and mapping - Smoothing, a wrapper class for cv2 smoothing functions Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-25utils: tuning: libtuning: Implement the core of libtuningPaul Elder
Implement the core of libtuning, our new tuning tool infrastructure. It leverages components from raspberrypi's ctt that could be reused for tuning tools for other platforms. The core components include: - The Image class - libtuning (entry point and other core functions) - macbeth-related tools, including the macbeth reference image - utils Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>