From c1597f989654618f782012104f547b367082fa3e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 18 Jul 2022 09:15:58 +0100 Subject: ipa: raspberrypi: Use YamlParser to replace dependency on boost The Raspberry Pi IPA module depends on boost only to parse the JSON tuning data files. As libcamera depends on libyaml, use the YamlParser class to parse those files and drop the dependency on boost. Signed-off-by: Laurent Pinchart Tested-by: Naushir Patuck Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/controller/controller.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/ipa/raspberrypi/controller/controller.cpp') diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index d91ac907..bceb6254 100644 --- a/src/ipa/raspberrypi/controller/controller.cpp +++ b/src/ipa/raspberrypi/controller/controller.cpp @@ -5,14 +5,16 @@ * controller.cpp - ISP controller */ +#include + +#include #include +#include "libcamera/internal/yaml_parser.h" + #include "algorithm.h" #include "controller.h" -#include -#include - using namespace RPiController; using namespace libcamera; @@ -34,18 +36,25 @@ Controller::~Controller() {} int Controller::read(char const *filename) { - boost::property_tree::ptree root; - boost::property_tree::read_json(filename, root); - for (auto const &keyAndValue : root) { - Algorithm *algo = createAlgorithm(keyAndValue.first.c_str()); + File file(filename); + if (!file.open(File::OpenModeFlag::ReadOnly)) { + LOG(RPiController, Warning) + << "Failed to open tuning file '" << filename << "'"; + return -EINVAL; + } + + std::unique_ptr root = YamlParser::parse(file); + + for (auto const &[key, value] : root->asDict()) { + Algorithm *algo = createAlgorithm(key.c_str()); if (algo) { - int ret = algo->read(keyAndValue.second); + int ret = algo->read(value); if (ret) return ret; algorithms_.push_back(AlgorithmPtr(algo)); } else LOG(RPiController, Warning) - << "No algorithm found for \"" << keyAndValue.first << "\""; + << "No algorithm found for \"" << key << "\""; } return 0; -- cgit v1.2.1