From patchwork Thu Jun 16 15:05:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16245 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 12632C3273 for ; Thu, 16 Jun 2022 15:05:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8B5165638; Thu, 16 Jun 2022 17:05:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655391951; bh=g9RCsvd/j89k9yRTVP8zmBiokpMe5cM4JFkmkynKt1M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Fp3/5xt4Fypob7lqKtjgcmlZ0MAvpIx8nHJ/3O0fPEy7ZKGFn83mpPGw8UokdmtlU gdiLD7Per3X2Y0LTU6FPSXGfZ6GwyvEomhkusNbCUg4rl/AXFgpsjX8jTR+i+tOxBs 8YFTr4TPBLp5cd5b7Cjl/BRypU3AXy07RIQNo8AhsPoTbvc/aejrbUNUfuX/lwIH7T lRWslRPvMeN1/8c6fh85YJwgV6AWzxxPnvyOLKj/6Igs1ZE2FOcOUR6njfFIPmesVt VWBQLwMw+//YJyUggsZTW4MreJ8IF4HzBSWZbWvjuHB8BtL7l3wLR69t0uq4FXFFvK jU26BVOHje4IQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B87F8600F0 for ; Thu, 16 Jun 2022 17:05:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KzbcyI0W"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C9B7898; Thu, 16 Jun 2022 17:05:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655391949; bh=g9RCsvd/j89k9yRTVP8zmBiokpMe5cM4JFkmkynKt1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KzbcyI0W5UrL157oUXUcKInHn1p764jOiYyD5i0rPTeMMWleJCUIU0uc47CMSIM26 8W6WKm5gsDJGDt+2XT8X2n7LJdjPLUzv6t3n5J8yYQE1NHwtSadEAtXPRMH0SujQP0 wqbbJY0C4otcF4X3jp3Pl26H8IZNKpPNZrnhNX/k= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 18:05:32 +0300 Message-Id: <20220616150535.21742-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> References: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 1/4] test: yaml-parser: Test dictionary items ordering X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" While YAML specifies that mappings are unordered, the Raspberry Pi IPA relies on elements being ordered as in the YAML data. To replace the dependency on boost with the YamlParser class, we thus need to guarantee that the order is preserved. Update the corresponding unit test to ensure this. The test currently fails at the YamlParser doesn't correctly preserve the order, this will be fixed by the next commit. This commit should be reverted when the Raspberry Pi IPA updates to a new tuning data format and drops support for the old format. Signed-off-by: Laurent Pinchart --- test/yaml-parser.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp index 38f848232fa6..157ecea256cd 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -32,8 +32,8 @@ static const string testYaml = " - Mary\n" "dictionary:\n" " a: 1\n" - " b: 2\n" " c: 3\n" + " b: 2\n" "level1:\n" " level2:\n" " - [1, 2]\n" @@ -449,10 +449,10 @@ protected: return TestFail; } - std::map dictValues{ { + static constexpr std::array, 3> dictValues{ { { "a", 1 }, - { "b", 2 }, { "c", 3 }, + { "b", 2 }, } }; size_t dictSize = dictValues.size(); @@ -470,8 +470,8 @@ protected: return TestFail; } - const auto item = dictValues.find(key); - if (item == dictValues.end()) { + const auto &item = dictValues[i]; + if (item.first != key) { std::cerr << "Dictionary key " << i << " has wrong value" << std::endl; return TestFail; @@ -483,17 +483,12 @@ protected: return TestFail; } - if (elem.get(0) != item->second) { + if (elem.get(0) != item.second) { std::cerr << "Dictionary element " << i << " has wrong value" << std::endl; return TestFail; } - /* - * Erase the item to make sure that each iteration - * produces a different value. - */ - dictValues.erase(item); i++; } From patchwork Thu Jun 16 15:05:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16246 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 66675C3274 for ; Thu, 16 Jun 2022 15:05:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC1E06563B; Thu, 16 Jun 2022 17:05:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655391954; bh=dBQXB41OzInljx0+jHsMKf4NLOImcVQk41QqHqkNrZk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=2B08Maw/ISUp/NYIJTTNid01yrMVSEMIgJts3tWcXuqkhEXuWflK8udqMcIbqtO1T ugEwvUlPmT6gAn+zpK1AHw/81/nNEpCp8Q9PMo7XemC1bHaRjU5HtRo9iim+IKdVZr Kkr2rf/CsyBq1dcp6nKu1LWhH62ttobLnesfGbezFoLxaB4kTGPdGmKAo+c79bSLE2 VYdzXfUxfVMImvDk7b2qmirLz7IULTcpLalyheRY250W/VKVOJerZx+soHE5aybZgY EqsdHHAOMNJxp/NH9tUvjFrwdtd/93LhcGp5541a2fhHAKhmR3RvIQWcD35EXEcVwN Mp+P46q+idinQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 52E40600F0 for ; Thu, 16 Jun 2022 17:05:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PpKqC3E6"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B69AA8AF; Thu, 16 Jun 2022 17:05:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655391950; bh=dBQXB41OzInljx0+jHsMKf4NLOImcVQk41QqHqkNrZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PpKqC3E6K80JgqWQkCNE/FnspqIxw4LenVGGO3FM6XetylwIT9/iyG1pl+DUI3rjh 0/QJ5LW9Mj6VzJORNDK2nF+JfOsliMt/dvoruBUdhbc+X9kRo7sjQ7FsgT/nIMi5pp 1TmJN04Nj7s0yxGFnkN5IBPDa2LUZFHbawrysRb8= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 18:05:33 +0300 Message-Id: <20220616150535.21742-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> References: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 2/4] libcamera: yaml_parser: Preserve order of items in dictionary X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The std::map container used to store dictionary items in YamlObject doesn't preserve the YAML data order, as maps are ordered by key, not by insertion order. While this is compliant with the YAML specification which doesn't guarantee ordering of mappings, the Raspberry Pi IPA relies on elements being ordered as in the YAML data. To replace the dependency on boost with the YamlParser class, we thus need to guarantee that the order is preserved. Preserve the order by storing items in list_ unconditionally. Turn the list_ vector from storing YamlObject unique pointers to storing key-value pairs, with the key being absent when the object is a list, not a dictionary. The YamlObject implementation is updated to preserve the existing API, with the only difference being that YamlObject::memberNames() now returns member names in the same order as in the YAML file. The ordering is an implementation detail, so changing it doesn't violate the YAML specification. The documentation is not updated to reflect this, as we don't want any new user to rely on a particular ordering. This commit could be reverted if desired when the Raspberry Pi IPA updates to a new tuning data format and drops support for the old format. Signed-off-by: Laurent Pinchart --- include/libcamera/internal/yaml_parser.h | 37 +++++++++++++++--------- src/libcamera/yaml_parser.cpp | 35 ++++++++++++++-------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h index 90d348eac74c..b0bda1fc103e 100644 --- a/include/libcamera/internal/yaml_parser.h +++ b/include/libcamera/internal/yaml_parser.h @@ -24,12 +24,21 @@ class YamlParserContext; class YamlObject { private: - using DictContainer = std::map>; + struct Value { + Value(std::string &&k, std::unique_ptr &&v) + : key(std::move(k)), value(std::move(v)) + { + } + std::string key; + std::unique_ptr value; + }; + + using Container = std::vector; using ListContainer = std::vector>; public: #ifndef __DOXYGEN__ - template + template class Iterator { public: @@ -65,10 +74,10 @@ public: } protected: - typename Container::const_iterator it_; + Container::const_iterator it_; }; - template + template class Adapter { public: @@ -91,7 +100,7 @@ public: const Container &container_; }; - class ListIterator : public Iterator + class ListIterator : public Iterator { public: using value_type = const YamlObject &; @@ -100,16 +109,16 @@ public: value_type operator*() const { - return *it_->get(); + return *it_->value.get(); } pointer operator->() const { - return it_->get(); + return it_->value.get(); } }; - class DictIterator : public Iterator + class DictIterator : public Iterator { public: using value_type = std::pair; @@ -118,17 +127,17 @@ public: value_type operator*() const { - return { it_->first, *it_->second.get() }; + return { it_->key, *it_->value.get() }; } }; - class DictAdapter : public Adapter + class DictAdapter : public Adapter { public: using key_type = std::string; }; - class ListAdapter : public Adapter + class ListAdapter : public Adapter { }; #endif /* __DOXYGEN__ */ @@ -167,7 +176,7 @@ public: #endif T get(const T &defaultValue, bool *ok = nullptr) const; - DictAdapter asDict() const { return DictAdapter{ dictionary_ }; } + DictAdapter asDict() const { return DictAdapter{ list_ }; } ListAdapter asList() const { return ListAdapter{ list_ }; } const YamlObject &operator[](std::size_t index) const; @@ -189,8 +198,8 @@ private: Type type_; std::string value_; - ListContainer list_; - DictContainer dictionary_; + Container list_; + std::map dictionary_; }; class YamlParser final diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp index 5c45e44e49c3..e30de050a0ea 100644 --- a/src/libcamera/yaml_parser.cpp +++ b/src/libcamera/yaml_parser.cpp @@ -91,7 +91,6 @@ std::size_t YamlObject::size() const { switch (type_) { case Type::Dictionary: - return dictionary_.size(); case Type::List: return list_.size(); default: @@ -311,11 +310,11 @@ Size YamlObject::get(const Size &defaultValue, bool *ok) const * that ok == nullptr. */ bool valid; - uint32_t width = list_[0]->get(0, &valid); + uint32_t width = list_[0].value->get(0, &valid); if (!valid) return defaultValue; - uint32_t height = list_[1]->get(0, &valid); + uint32_t height = list_[1].value->get(0, &valid); if (!valid) return defaultValue; @@ -379,7 +378,7 @@ const YamlObject &YamlObject::operator[](std::size_t index) const if (type_ != Type::List || index >= size()) return empty; - return *list_[index]; + return *list_[index].value; } /** @@ -395,7 +394,7 @@ const YamlObject &YamlObject::operator[](std::size_t index) const */ bool YamlObject::contains(const std::string &key) const { - if (dictionary_.find(key) == dictionary_.end()) + if (dictionary_.find(std::ref(key)) == dictionary_.end()) return false; return true; @@ -667,16 +666,16 @@ int YamlParserContext::parseNextYamlObject(YamlObject &yamlObject, EventPtr even yamlObject.type_ = YamlObject::Type::List; auto &list = yamlObject.list_; auto handler = [this, &list](EventPtr evt) { - list.emplace_back(new YamlObject()); - return parseNextYamlObject(*list.back(), std::move(evt)); + list.emplace_back(std::string{}, std::make_unique()); + return parseNextYamlObject(*list.back().value, std::move(evt)); }; return parseDictionaryOrList(YamlObject::Type::List, handler); } case YAML_MAPPING_START_EVENT: { yamlObject.type_ = YamlObject::Type::Dictionary; - auto &dictionary = yamlObject.dictionary_; - auto handler = [this, &dictionary](EventPtr evtKey) { + auto &list = yamlObject.list_; + auto handler = [this, &list](EventPtr evtKey) { /* Parse key */ if (evtKey->type != YAML_SCALAR_EVENT) { LOG(YamlParser, Error) << "Expect key at line: " @@ -694,10 +693,19 @@ int YamlParserContext::parseNextYamlObject(YamlObject &yamlObject, EventPtr even if (!evtValue) return -EINVAL; - auto elem = dictionary.emplace(key, std::make_unique()); - return parseNextYamlObject(*elem.first->second.get(), std::move(evtValue)); + auto &elem = list.emplace_back(std::move(key), + std::make_unique()); + return parseNextYamlObject(*elem.value, std::move(evtValue)); }; - return parseDictionaryOrList(YamlObject::Type::Dictionary, handler); + int ret = parseDictionaryOrList(YamlObject::Type::Dictionary, handler); + if (ret) + return ret; + + auto &dictionary = yamlObject.dictionary_; + for (const auto &elem : list) + dictionary.emplace(elem.key, elem.value.get()); + + return 0; } default: @@ -753,6 +761,9 @@ int YamlParserContext::parseNextYamlObject(YamlObject &yamlObject, EventPtr even * The YamlParser::parse() function takes an open FILE, parses its contents, and * returns a pointer to a YamlObject corresponding to the root node of the YAML * document. + * + * The parser preserves the order of items in the YAML file, for both lists and + * dictionaries. */ /** From patchwork Thu Jun 16 15:05:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16247 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 52035C3275 for ; Thu, 16 Jun 2022 15:05:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D398E65643; Thu, 16 Jun 2022 17:05:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655391955; bh=Glf9pjjGnzIfbfULE+Zq+A8HaL9XSI9VV/ERWec7nYo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=t1lr4ZIWvtogs7CWic7vG4Oihvvx4bpb05h6re1eqgQYu0sUAt2fAMeZZ4g6G9oEf rQm8rC/s1ZTxCKABy3ZsCnG+DjnqlkN6QLs64+1h6s7r7sNcAG1XMLk89uydYrNK/h DO8m0EMa73hheiPOTxIwT1cvjTotv/Ryv2DxQU++4uzA07PFToAXuU8wjz1spbDktH b3h47impBjeWXGS0JME5ihs07PCoxIHUNnPfp8nrO8GkqDho9CwXMyZO46MFZGVjO3 Bk0qUjpyW/CGwzAPbMRrS5rF9zA3WaZ79fHDsoiXGDsET+mrVmAcw4bg6PfDRGnJXi P2fe6i9FO5Asg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2277B6563B for ; Thu, 16 Jun 2022 17:05:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="njsggD+j"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F2EA415; Thu, 16 Jun 2022 17:05:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655391950; bh=Glf9pjjGnzIfbfULE+Zq+A8HaL9XSI9VV/ERWec7nYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=njsggD+jXUj2MMFZVsmoI171sL7GjwglObAU8Dj3qrYG/f2AUNReHaORgxCxU0hP5 SFf1yOcilsKa8jVsBulBMGGzpfQfsFBWar8IffkSImo+kOxhGpAygpnn2IshVthqya MDOLqT06pi3KcNYxvGTrQWyJANRhQOkBJucF9AYM= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 18:05:34 +0300 Message-Id: <20220616150535.21742-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> References: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 3/4] ipa: raspberrypi: Replace tabs with spaces in tuning data files X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Tuning data files mostly use spaces for indentation, with occasional stray tabs. Use spaces consistently. This allows parsing the tuning files with libyaml, preparing to replace the dependency on boost. Signed-off-by: Laurent Pinchart --- src/ipa/raspberrypi/data/imx219.json | 8 ++++---- src/ipa/raspberrypi/data/imx219_noir.json | 10 +++++----- src/ipa/raspberrypi/data/imx290.json | 18 +++++++++--------- src/ipa/raspberrypi/data/imx477.json | 8 ++++---- src/ipa/raspberrypi/data/imx477_noir.json | 10 +++++----- src/ipa/raspberrypi/data/ov5647.json | 10 +++++----- src/ipa/raspberrypi/data/ov5647_noir.json | 12 ++++++------ src/ipa/raspberrypi/data/se327m12.json | 6 +++--- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/ipa/raspberrypi/data/imx219.json b/src/ipa/raspberrypi/data/imx219.json index de59d9363be4..4e24c5d57da1 100644 --- a/src/ipa/raspberrypi/data/imx219.json +++ b/src/ipa/raspberrypi/data/imx219.json @@ -189,10 +189,10 @@ ] } ], - "shadows": - [ - { - "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": + "shadows": + [ + { + "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": [ 0, 0.17, 1000, 0.17 ] diff --git a/src/ipa/raspberrypi/data/imx219_noir.json b/src/ipa/raspberrypi/data/imx219_noir.json index 9a3f03ec86f4..1835ec3df63b 100644 --- a/src/ipa/raspberrypi/data/imx219_noir.json +++ b/src/ipa/raspberrypi/data/imx219_noir.json @@ -31,7 +31,7 @@ }, "rpi.awb": { - "bayes": 0 + "bayes": 0 }, "rpi.agc": { @@ -121,10 +121,10 @@ ] } ], - "shadows": - [ - { - "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": + "shadows": + [ + { + "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": [ 0, 0.17, 1000, 0.17 ] diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json index 20b45c1684c2..1363bab71340 100644 --- a/src/ipa/raspberrypi/data/imx290.json +++ b/src/ipa/raspberrypi/data/imx290.json @@ -29,11 +29,11 @@ }, "rpi.awb": { - "bayes": 0 + "bayes": 0 }, "rpi.agc": { - "speed": 0.2, + "speed": 0.2, "metering_modes": { "matrix": @@ -150,14 +150,14 @@ "rpi.ccm": { "ccms": - [ + [ { - "ct": 3900, "ccm": - [ - 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612 - ] - } - ] + "ct": 3900, "ccm": + [ + 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612 + ] + } + ] }, "rpi.focus": { diff --git a/src/ipa/raspberrypi/data/imx477.json b/src/ipa/raspberrypi/data/imx477.json index d07febd283ed..0f389661c246 100644 --- a/src/ipa/raspberrypi/data/imx477.json +++ b/src/ipa/raspberrypi/data/imx477.json @@ -189,10 +189,10 @@ ] } ], - "shadows": - [ - { - "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": + "shadows": + [ + { + "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": [ 0, 0.17, 1000, 0.17 ] diff --git a/src/ipa/raspberrypi/data/imx477_noir.json b/src/ipa/raspberrypi/data/imx477_noir.json index 7d4fc7dab9fd..a379d780d966 100644 --- a/src/ipa/raspberrypi/data/imx477_noir.json +++ b/src/ipa/raspberrypi/data/imx477_noir.json @@ -31,7 +31,7 @@ }, "rpi.awb": { - "bayes": 0 + "bayes": 0 }, "rpi.agc": { @@ -121,10 +121,10 @@ ] } ], - "shadows": - [ - { - "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": + "shadows": + [ + { + "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": [ 0, 0.17, 1000, 0.17 ] diff --git a/src/ipa/raspberrypi/data/ov5647.json b/src/ipa/raspberrypi/data/ov5647.json index 24bc06fb6114..e65f9385d970 100644 --- a/src/ipa/raspberrypi/data/ov5647.json +++ b/src/ipa/raspberrypi/data/ov5647.json @@ -189,10 +189,10 @@ ] } ], - "shadows": - [ - { - "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": + "shadows": + [ + { + "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": [ 0, 0.17, 1000, 0.17 ] @@ -203,7 +203,7 @@ [ 0, 0.16, 1000, 0.165, 10000, 0.17 ], - "base_ev": 1.25 + "base_ev": 1.25 }, "rpi.alsc": { diff --git a/src/ipa/raspberrypi/data/ov5647_noir.json b/src/ipa/raspberrypi/data/ov5647_noir.json index 1c628ed13f19..dad73a5e8cd9 100644 --- a/src/ipa/raspberrypi/data/ov5647_noir.json +++ b/src/ipa/raspberrypi/data/ov5647_noir.json @@ -31,7 +31,7 @@ }, "rpi.awb": { - "bayes": 0 + "bayes": 0 }, "rpi.agc": { @@ -121,10 +121,10 @@ ] } ], - "shadows": - [ - { - "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": + "shadows": + [ + { + "bound": "LOWER", "q_lo": 0.0, "q_hi": 0.5, "y_target": [ 0, 0.17, 1000, 0.17 ] @@ -135,7 +135,7 @@ [ 0, 0.16, 1000, 0.165, 10000, 0.17 ], - "base_ev": 1.25 + "base_ev": 1.25 }, "rpi.alsc": { diff --git a/src/ipa/raspberrypi/data/se327m12.json b/src/ipa/raspberrypi/data/se327m12.json index 94af2239f700..5b1ac2ce3bf8 100644 --- a/src/ipa/raspberrypi/data/se327m12.json +++ b/src/ipa/raspberrypi/data/se327m12.json @@ -334,8 +334,8 @@ }, "rpi.sharpen": { - "threshold": 2.0, - "strength": 0.5, - "limit": 0.5 + "threshold": 2.0, + "strength": 0.5, + "limit": 0.5 } } From patchwork Thu Jun 16 15:05:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16248 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 40940C3276 for ; Thu, 16 Jun 2022 15:05:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BC3065644; Thu, 16 Jun 2022 17:05:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655391956; bh=BXwVDLqZukHi73ClXR+i2KffARet0962NKFFXGZ6VxM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eVNc3S6ZuXEtu8qZYvACOfye0jQecnmmw0RLnpoyXCGQswr9vAOBAYlT7bzMqvVoh 0cxY2cXSW9YVm2HbqSPBdQCetEIeriwpt51cvEyLZ3/Pdeo6IhyqdbpnUM4e9xuweQ PhqKb/IS4i1Lt7Db+bRUKdLErfU++xqLD0nfxw61sAqvasgcqQdlvObfvfH5AP/Ob0 +9/e2smdQCOgq1+9ZXpnpRkKbhuwlmKYG2D9ahEGP+SDTkvHSgT2W6Sa9oLnHmoy8J J5U0uKzhaghTNt1U5mgvC8uxqYGGCrNK6dmAr3EZKxYROx30bOp0ODXaX2pbN4AMK3 Krr7k3DZTJVFQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B16B600F0 for ; Thu, 16 Jun 2022 17:05:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vKIPfvTr"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E993C898; Thu, 16 Jun 2022 17:05:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655391951; bh=BXwVDLqZukHi73ClXR+i2KffARet0962NKFFXGZ6VxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vKIPfvTrrIeAgoxKv0Q7KeDx5Kami29LnemKsf4Wgx/6BvxyxTfoY0NPLBZpSzazl GxleToIaPDTePrWHR/uAncHHl2YXtdb4PZl4krZ+XvBGTYpffBUztWizeT+x8T08wX d5eSbh55bGwS2t5ZrEZOulEv5ChttprnJeqSjjGQ= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 18:05:35 +0300 Message-Id: <20220616150535.21742-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> References: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 4/4] ipa: raspberrypi: Use YamlParser to replace dependency on boost X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- README.rst | 6 -- src/ipa/raspberrypi/controller/algorithm.cpp | 2 +- src/ipa/raspberrypi/controller/algorithm.hpp | 6 +- src/ipa/raspberrypi/controller/controller.cpp | 27 ++++-- src/ipa/raspberrypi/controller/pwl.cpp | 12 ++- src/ipa/raspberrypi/controller/pwl.hpp | 5 +- src/ipa/raspberrypi/controller/rpi/agc.cpp | 94 +++++++++---------- src/ipa/raspberrypi/controller/rpi/agc.hpp | 10 +- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 94 +++++++++---------- src/ipa/raspberrypi/controller/rpi/alsc.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/awb.cpp | 89 +++++++++--------- src/ipa/raspberrypi/controller/rpi/awb.hpp | 8 +- .../controller/rpi/black_level.cpp | 12 +-- .../controller/rpi/black_level.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 28 +++--- src/ipa/raspberrypi/controller/rpi/ccm.hpp | 4 +- .../raspberrypi/controller/rpi/contrast.cpp | 18 ++-- .../raspberrypi/controller/rpi/contrast.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 4 +- src/ipa/raspberrypi/controller/rpi/dpc.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/geq.cpp | 10 +- src/ipa/raspberrypi/controller/rpi/geq.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/lux.cpp | 12 +-- src/ipa/raspberrypi/controller/rpi/lux.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/noise.cpp | 6 +- src/ipa/raspberrypi/controller/rpi/noise.hpp | 2 +- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 6 +- src/ipa/raspberrypi/controller/rpi/sdn.hpp | 2 +- .../raspberrypi/controller/rpi/sharpen.cpp | 8 +- .../raspberrypi/controller/rpi/sharpen.hpp | 2 +- src/ipa/raspberrypi/meson.build | 1 - src/ipa/raspberrypi/raspberrypi.cpp | 1 + 32 files changed, 241 insertions(+), 240 deletions(-) diff --git a/README.rst b/README.rst index f81d6e2e7867..8d9145f58d64 100644 --- a/README.rst +++ b/README.rst @@ -71,12 +71,6 @@ for improved debugging: [optional] information, and libunwind is not needed if both libdw and the glibc backtrace() function are available. -for the Raspberry Pi IPA: [optional] - libboost-dev - - Support for Raspberry Pi can be disabled through the meson - 'pipelines' option to avoid this dependency. - for device hotplug enumeration: [optional] libudev-dev diff --git a/src/ipa/raspberrypi/controller/algorithm.cpp b/src/ipa/raspberrypi/controller/algorithm.cpp index 43ad0a2be222..4fd36fc1be5b 100644 --- a/src/ipa/raspberrypi/controller/algorithm.cpp +++ b/src/ipa/raspberrypi/controller/algorithm.cpp @@ -9,7 +9,7 @@ using namespace RPiController; -void Algorithm::Read([[maybe_unused]] boost::property_tree::ptree const ¶ms) +void Algorithm::Read([[maybe_unused]] const libcamera::YamlObject ¶ms) { } diff --git a/src/ipa/raspberrypi/controller/algorithm.hpp b/src/ipa/raspberrypi/controller/algorithm.hpp index 5123c87bab34..87bfca8d2045 100644 --- a/src/ipa/raspberrypi/controller/algorithm.hpp +++ b/src/ipa/raspberrypi/controller/algorithm.hpp @@ -13,10 +13,10 @@ #include #include +#include "libcamera/internal/yaml_parser.h" + #include "controller.hpp" -#include - namespace RPiController { // This defines the basic interface for all control algorithms. @@ -33,7 +33,7 @@ public: virtual bool IsPaused() const { return paused_; } virtual void Pause() { paused_ = true; } virtual void Resume() { paused_ = false; } - virtual void Read(boost::property_tree::ptree const ¶ms); + virtual void Read(const libcamera::YamlObject ¶ms); virtual void Initialise(); virtual void SwitchMode(CameraMode const &camera_mode, Metadata *metadata); virtual void Prepare(Metadata *image_metadata); diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index d3433ad2e7e8..67d650ef0c1b 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.hpp" #include "controller.hpp" -#include -#include - using namespace RPiController; using namespace libcamera; @@ -32,16 +34,23 @@ Controller::~Controller() {} void Controller::Read(char const *filename) { - boost::property_tree::ptree root; - boost::property_tree::read_json(filename, root); - for (auto const &key_and_value : root) { - Algorithm *algo = CreateAlgorithm(key_and_value.first.c_str()); + File file(filename); + if (!file.open(File::OpenModeFlag::ReadOnly)) { + LOG(RPiController, Warning) + << "Failed to open tuning file '" << filename << "'"; + return; + } + + std::unique_ptr root = YamlParser::parse(file); + + for (auto const &[key, value] : root->asDict()) { + Algorithm *algo = CreateAlgorithm(key.c_str()); if (algo) { - algo->Read(key_and_value.second); + algo->Read(value); algorithms_.push_back(AlgorithmPtr(algo)); } else LOG(RPiController, Warning) - << "No algorithm found for \"" << key_and_value.first << "\""; + << "No algorithm found for \"" << key << "\""; } } diff --git a/src/ipa/raspberrypi/controller/pwl.cpp b/src/ipa/raspberrypi/controller/pwl.cpp index 130c820b559f..9c7bc94dd484 100644 --- a/src/ipa/raspberrypi/controller/pwl.cpp +++ b/src/ipa/raspberrypi/controller/pwl.cpp @@ -12,13 +12,15 @@ using namespace RPiController; -void Pwl::Read(boost::property_tree::ptree const ¶ms) +void Pwl::Read(const libcamera::YamlObject ¶ms) { - for (auto it = params.begin(); it != params.end(); it++) { - double x = it->second.get_value(); - assert(it == params.begin() || x > points_.back().x); + const auto &list = params.asList(); + + for (auto it = list.begin(); it != list.end(); it++) { + double x = it->get(0.0); + assert(it == list.begin() || x > points_.back().x); it++; - double y = it->second.get_value(); + double y = it->get(0.0); points_.push_back(Point(x, y)); } assert(points_.size() >= 2); diff --git a/src/ipa/raspberrypi/controller/pwl.hpp b/src/ipa/raspberrypi/controller/pwl.hpp index 484672f64095..70df4ba0daea 100644 --- a/src/ipa/raspberrypi/controller/pwl.hpp +++ b/src/ipa/raspberrypi/controller/pwl.hpp @@ -6,10 +6,11 @@ */ #pragma once +#include #include #include -#include +#include "libcamera/internal/yaml_parser.h" namespace RPiController { @@ -55,7 +56,7 @@ public: }; Pwl() {} Pwl(std::vector const &points) : points_(points) {} - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); void Append(double x, double y, const double eps = 1e-6); void Prepend(double x, double y, const double eps = 1e-6); Interval Domain() const; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index f6a9cb0a2cd8..c82f29600be7 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -30,13 +30,13 @@ LOG_DEFINE_CATEGORY(RPiAgc) #define PIPELINE_BITS 13 // seems to be a 13-bit pipeline -void AgcMeteringMode::Read(boost::property_tree::ptree const ¶ms) +void AgcMeteringMode::Read(const libcamera::YamlObject ¶ms) { int num = 0; - for (auto &p : params.get_child("weights")) { + for (const auto &p : params["weights"].asList()) { if (num == AGC_STATS_SIZE) throw std::runtime_error("AgcConfig: too many weights"); - weights[num++] = p.second.get_value(); + weights[num++] = p.get(0.0); } if (num != AGC_STATS_SIZE) throw std::runtime_error("AgcConfig: insufficient weights"); @@ -44,39 +44,39 @@ void AgcMeteringMode::Read(boost::property_tree::ptree const ¶ms) static std::string read_metering_modes(std::map &metering_modes, - boost::property_tree::ptree const ¶ms) + const libcamera::YamlObject ¶ms) { std::string first; - for (auto &p : params) { + for (const auto &[key, value] : params.asDict()) { AgcMeteringMode metering_mode; - metering_mode.Read(p.second); - metering_modes[p.first] = std::move(metering_mode); + metering_mode.Read(value); + metering_modes[key] = std::move(metering_mode); if (first.empty()) - first = p.first; + first = key; } return first; } static int read_list(std::vector &list, - boost::property_tree::ptree const ¶ms) + const libcamera::YamlObject ¶ms) { - for (auto &p : params) - list.push_back(p.second.get_value()); + for (const auto &p : params.asList()) + list.push_back(p.get(0.0)); return list.size(); } static int read_list(std::vector &list, - boost::property_tree::ptree const ¶ms) + const libcamera::YamlObject ¶ms) { - for (auto &p : params) - list.push_back(p.second.get_value() * 1us); + for (const auto &p : params.asList()) + list.push_back(p.get(0.0) * 1us); return list.size(); } -void AgcExposureMode::Read(boost::property_tree::ptree const ¶ms) +void AgcExposureMode::Read(const libcamera::YamlObject ¶ms) { - int num_shutters = read_list(shutter, params.get_child("shutter")); - int num_ags = read_list(gain, params.get_child("gain")); + int num_shutters = read_list(shutter, params["shutter"]); + int num_ags = read_list(gain, params["gain"]); if (num_shutters < 2 || num_ags < 2) throw std::runtime_error( "AgcConfig: must have at least two entries in exposure profile"); @@ -87,40 +87,40 @@ void AgcExposureMode::Read(boost::property_tree::ptree const ¶ms) static std::string read_exposure_modes(std::map &exposure_modes, - boost::property_tree::ptree const ¶ms) + const libcamera::YamlObject ¶ms) { std::string first; - for (auto &p : params) { + for (const auto &[key, value] : params.asDict()) { AgcExposureMode exposure_mode; - exposure_mode.Read(p.second); - exposure_modes[p.first] = std::move(exposure_mode); + exposure_mode.Read(value); + exposure_modes[key] = std::move(exposure_mode); if (first.empty()) - first = p.first; + first = key; } return first; } -void AgcConstraint::Read(boost::property_tree::ptree const ¶ms) +void AgcConstraint::Read(const libcamera::YamlObject ¶ms) { - std::string bound_string = params.get("bound", ""); + std::string bound_string = params["bound"].get(""); transform(bound_string.begin(), bound_string.end(), bound_string.begin(), ::toupper); if (bound_string != "UPPER" && bound_string != "LOWER") throw std::runtime_error( "AGC constraint type should be UPPER or LOWER"); bound = bound_string == "UPPER" ? Bound::UPPER : Bound::LOWER; - q_lo = params.get("q_lo"); - q_hi = params.get("q_hi"); - Y_target.Read(params.get_child("y_target")); + q_lo = params["q_lo"].get(0.0); + q_hi = params["q_hi"].get(0.0); + Y_target.Read(params["y_target"]); } static AgcConstraintMode -read_constraint_mode(boost::property_tree::ptree const ¶ms) +read_constraint_mode(const libcamera::YamlObject ¶ms) { AgcConstraintMode mode; - for (auto &p : params) { + for (const auto &p : params.asList()) { AgcConstraint constraint; - constraint.Read(p.second); + constraint.Read(p); mode.push_back(std::move(constraint)); } return mode; @@ -128,36 +128,36 @@ read_constraint_mode(boost::property_tree::ptree const ¶ms) static std::string read_constraint_modes( std::map &constraint_modes, - boost::property_tree::ptree const ¶ms) + const libcamera::YamlObject ¶ms) { std::string first; - for (auto &p : params) { - constraint_modes[p.first] = read_constraint_mode(p.second); + for (const auto &[key, value] : params.asDict()) { + constraint_modes[key] = read_constraint_mode(value); if (first.empty()) - first = p.first; + first = key; } return first; } -void AgcConfig::Read(boost::property_tree::ptree const ¶ms) +void AgcConfig::Read(const libcamera::YamlObject ¶ms) { LOG(RPiAgc, Debug) << "AgcConfig"; default_metering_mode = read_metering_modes( - metering_modes, params.get_child("metering_modes")); + metering_modes, params["metering_modes"]); default_exposure_mode = read_exposure_modes( - exposure_modes, params.get_child("exposure_modes")); + exposure_modes, params["exposure_modes"]); default_constraint_mode = read_constraint_modes( - constraint_modes, params.get_child("constraint_modes")); - Y_target.Read(params.get_child("y_target")); - speed = params.get("speed", 0.2); - startup_frames = params.get("startup_frames", 10); - convergence_frames = params.get("convergence_frames", 6); + constraint_modes, params["constraint_modes"]); + Y_target.Read(params["y_target"]); + speed = params["speed"].get(0.2); + startup_frames = params["startup_frames"].get(10); + convergence_frames = params["convergence_frames"].get(6); fast_reduce_threshold = - params.get("fast_reduce_threshold", 0.4); - base_ev = params.get("base_ev", 1.0); + params["fast_reduce_threshold"].get(0.4); + base_ev = params["base_ev"].get(1.0); // Start with quite a low value as ramping up is easier than ramping down. - default_exposure_time = params.get("default_exposure_time", 1000) * 1us; - default_analogue_gain = params.get("default_analogue_gain", 1.0); + default_exposure_time = params["default_exposure_time"].get(1000) * 1us; + default_analogue_gain = params["default_analogue_gain"].get(1.0); } Agc::ExposureValues::ExposureValues() @@ -186,7 +186,7 @@ char const *Agc::Name() const return NAME; } -void Agc::Read(boost::property_tree::ptree const ¶ms) +void Agc::Read(const libcamera::YamlObject ¶ms) { LOG(RPiAgc, Debug) << "Agc"; config_.Read(params); diff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp index c100d3128c90..7794ba744efc 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp @@ -26,13 +26,13 @@ namespace RPiController { struct AgcMeteringMode { double weights[AGC_STATS_SIZE]; - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); }; struct AgcExposureMode { std::vector shutter; std::vector gain; - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); }; struct AgcConstraint { @@ -41,13 +41,13 @@ struct AgcConstraint { double q_lo; double q_hi; Pwl Y_target; - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); }; typedef std::vector AgcConstraintMode; struct AgcConfig { - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); std::map metering_modes; std::map exposure_modes; std::map constraint_modes; @@ -72,7 +72,7 @@ class Agc : public AgcAlgorithm public: Agc(Controller *controller); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; // AGC handles "pausing" for itself. bool IsPaused() const override; void Pause() override; diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index e575c14a92db..b38b037c7713 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -5,6 +5,7 @@ * alsc.cpp - ALSC (auto lens shading correction) control algorithm */ +#include #include #include @@ -50,12 +51,12 @@ char const *Alsc::Name() const return NAME; } -static void generate_lut(double *lut, boost::property_tree::ptree const ¶ms) +static void generate_lut(double *lut, const libcamera::YamlObject ¶ms) { - double cstrength = params.get("corner_strength", 2.0); + double cstrength = params["corner_strength"].get(2.0); if (cstrength <= 1.0) throw std::runtime_error("Alsc: corner_strength must be > 1.0"); - double asymmetry = params.get("asymmetry", 1.0); + double asymmetry = params["asymmetry"].get(1.0); if (asymmetry < 0) throw std::runtime_error("Alsc: asymmetry must be >= 0"); double f1 = cstrength - 1, f2 = 1 + sqrt(cstrength); @@ -73,50 +74,43 @@ static void generate_lut(double *lut, boost::property_tree::ptree const ¶ms) } } -static void read_lut(double *lut, boost::property_tree::ptree const ¶ms) +static void read_lut(double *lut, const libcamera::YamlObject ¶ms) { + if (params.size() != XY) + throw std::runtime_error( + "Alsc: invalid number of entries in LSC table"); + int num = 0; - const int max_num = XY; - for (auto &p : params) { - if (num == max_num) - throw std::runtime_error( - "Alsc: too many entries in LSC table"); - lut[num++] = p.second.get_value(); - } - if (num < max_num) - throw std::runtime_error("Alsc: too few entries in LSC table"); + for (const auto &p : params.asList()) + lut[num++] = p.get(0.0); } static void read_calibrations(std::vector &calibrations, - boost::property_tree::ptree const ¶ms, + const libcamera::YamlObject ¶ms, std::string const &name) { - if (params.get_child_optional(name)) { + if (params.contains(name)) { double last_ct = 0; - for (auto &p : params.get_child(name)) { - double ct = p.second.get("ct"); + for (const auto &p : params[name].asList()) { + double ct = p["ct"].get(0.0); if (ct <= last_ct) throw std::runtime_error( "Alsc: entries in " + name + " must be in increasing ct order"); AlscCalibration calibration; calibration.ct = last_ct = ct; - boost::property_tree::ptree const &table = - p.second.get_child("table"); + + const libcamera::YamlObject &table = p["table"]; + if (table.size() != XY) + throw std::runtime_error( + "Alsc: incorrect number of values for ct " + + std::to_string(ct) + " in " + + name); + int num = 0; - for (auto it = table.begin(); it != table.end(); it++) { - if (num == XY) - throw std::runtime_error( - "Alsc: too many values for ct " + - std::to_string(ct) + " in " + - name); - calibration.table[num++] = - it->second.get_value(); - } - if (num != XY) - throw std::runtime_error( - "Alsc: too few values for ct " + - std::to_string(ct) + " in " + name); + for (const auto &value : table.asList()) + calibration.table[num++] = value.get(0.0); + calibrations.push_back(calibration); LOG(RPiAlsc, Debug) << "Read " << name << " calibration for ct " << ct; @@ -124,35 +118,35 @@ static void read_calibrations(std::vector &calibrations, } } -void Alsc::Read(boost::property_tree::ptree const ¶ms) +void Alsc::Read(const libcamera::YamlObject ¶ms) { - config_.frame_period = params.get("frame_period", 12); - config_.startup_frames = params.get("startup_frames", 10); - config_.speed = params.get("speed", 0.05); - double sigma = params.get("sigma", 0.01); - config_.sigma_Cr = params.get("sigma_Cr", sigma); - config_.sigma_Cb = params.get("sigma_Cb", sigma); - config_.min_count = params.get("min_count", 10.0); - config_.min_G = params.get("min_G", 50); - config_.omega = params.get("omega", 1.3); - config_.n_iter = params.get("n_iter", X + Y); + config_.frame_period = params["frame_period"].get(12); + config_.startup_frames = params["startup_frames"].get(10); + config_.speed = params["speed"].get(0.05); + double sigma = params["sigma"].get(0.01); + config_.sigma_Cr = params["sigma_Cr"].get(sigma); + config_.sigma_Cb = params["sigma_Cb"].get(sigma); + config_.min_count = params["min_count"].get(10.0); + config_.min_G = params["min_G"].get(50); + config_.omega = params["omega"].get(1.3); + config_.n_iter = params["n_iter"].get(X + Y); config_.luminance_strength = - params.get("luminance_strength", 1.0); + params["luminance_strength"].get(1.0); for (int i = 0; i < XY; i++) config_.luminance_lut[i] = 1.0; - if (params.get_child_optional("corner_strength")) + if (params.contains("corner_strength")) generate_lut(config_.luminance_lut, params); - else if (params.get_child_optional("luminance_lut")) + else if (params.contains("luminance_lut")) read_lut(config_.luminance_lut, - params.get_child("luminance_lut")); + params["luminance_lut"]); else LOG(RPiAlsc, Warning) << "no luminance table - assume unity everywhere"; read_calibrations(config_.calibrations_Cr, params, "calibrations_Cr"); read_calibrations(config_.calibrations_Cb, params, "calibrations_Cb"); - config_.default_ct = params.get("default_ct", 4500.0); - config_.threshold = params.get("threshold", 1e-3); - config_.lambda_bound = params.get("lambda_bound", 0.05); + config_.default_ct = params["default_ct"].get(4500.0); + config_.threshold = params["threshold"].get(1e-3); + config_.lambda_bound = params["lambda_bound"].get(0.05); } static double get_ct(Metadata *metadata, double default_ct); diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.hpp b/src/ipa/raspberrypi/controller/rpi/alsc.hpp index d1dbe0d1d22d..9d28c1b49a6d 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.hpp @@ -52,7 +52,7 @@ public: char const *Name() const override; void Initialise() override; void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void Prepare(Metadata *image_metadata) override; void Process(StatisticsPtr &stats, Metadata *image_metadata) override; diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index d4c934473832..1c40bf878cd3 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -5,6 +5,8 @@ * awb.cpp - AWB control algorithm */ +#include + #include #include "../lux_status.h" @@ -24,33 +26,35 @@ LOG_DEFINE_CATEGORY(RPiAwb) // todo - the locking in this algorithm needs some tidying up as has been done // elsewhere (ALSC and AGC). -void AwbMode::Read(boost::property_tree::ptree const ¶ms) +void AwbMode::Read(const libcamera::YamlObject ¶ms) { - ct_lo = params.get("lo"); - ct_hi = params.get("hi"); + ct_lo = params["lo"].get(0.0); + ct_hi = params["hi"].get(0.0); } -void AwbPrior::Read(boost::property_tree::ptree const ¶ms) +void AwbPrior::Read(const libcamera::YamlObject ¶ms) { - lux = params.get("lux"); - prior.Read(params.get_child("prior")); + lux = params["lux"].get(0.0); + prior.Read(params["prior"]); } static void read_ct_curve(Pwl &ct_r, Pwl &ct_b, - boost::property_tree::ptree const ¶ms) + const libcamera::YamlObject ¶ms) { + const auto &list = params.asList(); int num = 0; - for (auto it = params.begin(); it != params.end(); it++) { - double ct = it->second.get_value(); - assert(it == params.begin() || ct != ct_r.Domain().end); - if (++it == params.end()) + + for (auto it = list.begin(); it != list.end(); it++) { + double ct = it->get(0.0); + assert(it == list.begin() || ct != ct_r.Domain().end); + if (++it == list.end()) throw std::runtime_error( "AwbConfig: incomplete CT curve entry"); - ct_r.Append(ct, it->second.get_value()); - if (++it == params.end()) + ct_r.Append(ct, it->get(0.0)); + if (++it == list.end()) throw std::runtime_error( "AwbConfig: incomplete CT curve entry"); - ct_b.Append(ct, it->second.get_value()); + ct_b.Append(ct, it->get(0.0)); num++; } if (num < 2) @@ -58,19 +62,19 @@ static void read_ct_curve(Pwl &ct_r, Pwl &ct_b, "AwbConfig: insufficient points in CT curve"); } -void AwbConfig::Read(boost::property_tree::ptree const ¶ms) +void AwbConfig::Read(const libcamera::YamlObject ¶ms) { - bayes = params.get("bayes", 1); - frame_period = params.get("frame_period", 10); - startup_frames = params.get("startup_frames", 10); - convergence_frames = params.get("convergence_frames", 3); - speed = params.get("speed", 0.05); - if (params.get_child_optional("ct_curve")) - read_ct_curve(ct_r, ct_b, params.get_child("ct_curve")); - if (params.get_child_optional("priors")) { - for (auto &p : params.get_child("priors")) { + bayes = params["bayes"].get(1); + frame_period = params["frame_period"].get(10); + startup_frames = params["startup_frames"].get(10); + convergence_frames = params["convergence_frames"].get(3); + speed = params["speed"].get(0.05); + if (params.contains("ct_curve")) + read_ct_curve(ct_r, ct_b, params["ct_curve"]); + if (params.contains("priors")) { + for (const auto &p : params["priors"].asList()) { AwbPrior prior; - prior.Read(p.second); + prior.Read(p); if (!priors.empty() && prior.lux <= priors.back().lux) throw std::runtime_error( "AwbConfig: Prior must be ordered in increasing lux value"); @@ -80,28 +84,28 @@ void AwbConfig::Read(boost::property_tree::ptree const ¶ms) throw std::runtime_error( "AwbConfig: no AWB priors configured"); } - if (params.get_child_optional("modes")) { - for (auto &p : params.get_child("modes")) { - modes[p.first].Read(p.second); + if (params.contains("modes")) { + for (const auto &[key, value] : params["modes"].asDict()) { + modes[key].Read(value); if (default_mode == nullptr) - default_mode = &modes[p.first]; + default_mode = &modes[key]; } if (default_mode == nullptr) throw std::runtime_error( "AwbConfig: no AWB modes configured"); } - min_pixels = params.get("min_pixels", 16.0); - min_G = params.get("min_G", 32); - min_regions = params.get("min_regions", 10); - delta_limit = params.get("delta_limit", 0.2); - coarse_step = params.get("coarse_step", 0.2); - transverse_pos = params.get("transverse_pos", 0.01); - transverse_neg = params.get("transverse_neg", 0.01); + min_pixels = params["min_pixels"].get(16.0); + min_G = params["min_G"].get(32); + min_regions = params["min_regions"].get(10); + delta_limit = params["delta_limit"].get(0.2); + coarse_step = params["coarse_step"].get(0.2); + transverse_pos = params["transverse_pos"].get(0.01); + transverse_neg = params["transverse_neg"].get(0.01); if (transverse_pos <= 0 || transverse_neg <= 0) throw std::runtime_error( "AwbConfig: transverse_pos/neg must be > 0"); - sensitivity_r = params.get("sensitivity_r", 1.0); - sensitivity_b = params.get("sensitivity_b", 1.0); + sensitivity_r = params["sensitivity_r"].get(1.0); + sensitivity_b = params["sensitivity_b"].get(1.0); if (bayes) { if (ct_r.Empty() || ct_b.Empty() || priors.empty() || default_mode == nullptr) { @@ -110,10 +114,9 @@ void AwbConfig::Read(boost::property_tree::ptree const ¶ms) bayes = false; } } - fast = params.get( - "fast", bayes); // default to fast for Bayesian, otherwise slow - whitepoint_r = params.get("whitepoint_r", 0.0); - whitepoint_b = params.get("whitepoint_b", 0.0); + fast = params[fast].get(bayes); // default to fast for Bayesian, otherwise slow + whitepoint_r = params["whitepoint_r"].get(0.0); + whitepoint_b = params["whitepoint_b"].get(0.0); if (bayes == false) sensitivity_r = sensitivity_b = 1.0; // nor do sensitivities make any sense @@ -144,7 +147,7 @@ char const *Awb::Name() const return NAME; } -void Awb::Read(boost::property_tree::ptree const ¶ms) +void Awb::Read(const libcamera::YamlObject ¶ms) { config_.Read(params); } diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp index ac3dca6f42fc..41334f798e2f 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp @@ -19,20 +19,20 @@ namespace RPiController { // Control algorithm to perform AWB calculations. struct AwbMode { - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); double ct_lo; // low CT value for search double ct_hi; // high CT value for search }; struct AwbPrior { - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); double lux; // lux level Pwl prior; // maps CT to prior log likelihood for this lux level }; struct AwbConfig { AwbConfig() : default_mode(nullptr) {} - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); // Only repeat the AWB calculation every "this many" frames uint16_t frame_period; // number of initial frames for which speed taken as 1.0 (maximum) @@ -82,7 +82,7 @@ public: ~Awb(); char const *Name() const override; void Initialise() override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; // AWB handles "pausing" for itself. bool IsPaused() const override; void Pause() override; diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp index 6b3497f13c19..de3a1e98ca1c 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp @@ -31,13 +31,13 @@ char const *BlackLevel::Name() const return NAME; } -void BlackLevel::Read(boost::property_tree::ptree const ¶ms) +void BlackLevel::Read(const libcamera::YamlObject ¶ms) { - uint16_t black_level = params.get( - "black_level", 4096); // 64 in 10 bits scaled to 16 bits - black_level_r_ = params.get("black_level_r", black_level); - black_level_g_ = params.get("black_level_g", black_level); - black_level_b_ = params.get("black_level_b", black_level); + // 64 in 10 bits scaled to 16 bits + uint16_t black_level = params["black_level"].get(4096); + black_level_r_ = params["black_level_r"].get(black_level); + black_level_g_ = params["black_level_g"].get(black_level); + black_level_b_ = params["black_level_b"].get(black_level); LOG(RPiBlackLevel, Debug) << " Read black levels red " << black_level_r_ << " green " << black_level_g_ diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.hpp b/src/ipa/raspberrypi/controller/rpi/black_level.hpp index 65ec4d0ed26c..5a63b5faef21 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.hpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.hpp @@ -18,7 +18,7 @@ class BlackLevel : public Algorithm public: BlackLevel(Controller *controller); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void Prepare(Metadata *image_metadata) override; private: diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index 821a4c7c98c5..0e02a524c68d 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -37,17 +37,15 @@ Matrix::Matrix(double m0, double m1, double m2, double m3, double m4, double m5, m[0][0] = m0, m[0][1] = m1, m[0][2] = m2, m[1][0] = m3, m[1][1] = m4, m[1][2] = m5, m[2][0] = m6, m[2][1] = m7, m[2][2] = m8; } -void Matrix::Read(boost::property_tree::ptree const ¶ms) +void Matrix::Read(const libcamera::YamlObject ¶ms) { double *ptr = (double *)m; - int n = 0; - for (auto it = params.begin(); it != params.end(); it++) { - if (n++ == 9) - throw std::runtime_error("Ccm: too many values in CCM"); - *ptr++ = it->second.get_value(); - } - if (n < 9) - throw std::runtime_error("Ccm: too few values in CCM"); + + if (params.size() != 9) + throw std::runtime_error("Ccm: wrong number of values in CCM"); + + for (const auto ¶m : params.asList()) + *ptr++ = param.get(0.0); } Ccm::Ccm(Controller *controller) @@ -58,14 +56,14 @@ char const *Ccm::Name() const return NAME; } -void Ccm::Read(boost::property_tree::ptree const ¶ms) +void Ccm::Read(const libcamera::YamlObject ¶ms) { - if (params.get_child_optional("saturation")) - config_.saturation.Read(params.get_child("saturation")); - for (auto &p : params.get_child("ccms")) { + if (params.contains("saturation")) + config_.saturation.Read(params["saturation"]); + for (auto &p : params["ccms"].asList()) { CtCcm ct_ccm; - ct_ccm.ct = p.second.get("ct"); - ct_ccm.ccm.Read(p.second.get_child("ccm")); + ct_ccm.ct = p["ct"].get(0.0); + ct_ccm.ccm.Read(p["ccm"]); if (!config_.ccms.empty() && ct_ccm.ct <= config_.ccms.back().ct) throw std::runtime_error( diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.hpp b/src/ipa/raspberrypi/controller/rpi/ccm.hpp index 330ed51fe398..073f02526850 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.hpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.hpp @@ -20,7 +20,7 @@ struct Matrix { double m6, double m7, double m8); Matrix(); double m[3][3]; - void Read(boost::property_tree::ptree const ¶ms); + void Read(const libcamera::YamlObject ¶ms); }; static inline Matrix operator*(double d, Matrix const &m) { @@ -62,7 +62,7 @@ class Ccm : public CcmAlgorithm public: Ccm(Controller *controller = NULL); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void SetSaturation(double saturation) override; void Initialise() override; void Prepare(Metadata *image_metadata) override; diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index ae55aad56739..534f8b48a59b 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -36,21 +36,21 @@ char const *Contrast::Name() const return NAME; } -void Contrast::Read(boost::property_tree::ptree const ¶ms) +void Contrast::Read(const libcamera::YamlObject ¶ms) { // enable adaptive enhancement by default - config_.ce_enable = params.get("ce_enable", 1); + config_.ce_enable = params["ce_enable"].get(1); // the point near the bottom of the histogram to move - config_.lo_histogram = params.get("lo_histogram", 0.01); + config_.lo_histogram = params["lo_histogram"].get(0.01); // where in the range to try and move it to - config_.lo_level = params.get("lo_level", 0.015); + config_.lo_level = params["lo_level"].get(0.015); // but don't move by more than this - config_.lo_max = params.get("lo_max", 500); + config_.lo_max = params["lo_max"].get(500); // equivalent values for the top of the histogram... - config_.hi_histogram = params.get("hi_histogram", 0.95); - config_.hi_level = params.get("hi_level", 0.95); - config_.hi_max = params.get("hi_max", 2000); - config_.gamma_curve.Read(params.get_child("gamma_curve")); + config_.hi_histogram = params["hi_histogram"].get(0.95); + config_.hi_level = params["hi_level"].get(0.95); + config_.hi_max = params["hi_max"].get(2000); + config_.gamma_curve.Read(params["gamma_curve"]); } void Contrast::SetBrightness(double brightness) diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.hpp b/src/ipa/raspberrypi/controller/rpi/contrast.hpp index 85624539a1da..6b1e41724f5b 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.hpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.hpp @@ -32,7 +32,7 @@ class Contrast : public ContrastAlgorithm public: Contrast(Controller *controller = NULL); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void SetBrightness(double brightness) override; void SetContrast(double contrast) override; void Initialise() override; diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index 110f50560e76..ac8aa78921c6 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -29,9 +29,9 @@ char const *Dpc::Name() const return NAME; } -void Dpc::Read(boost::property_tree::ptree const ¶ms) +void Dpc::Read(const libcamera::YamlObject ¶ms) { - config_.strength = params.get("strength", 1); + config_.strength = params["strength"].get(1); if (config_.strength < 0 || config_.strength > 2) throw std::runtime_error("Dpc: bad strength value"); } diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.hpp b/src/ipa/raspberrypi/controller/rpi/dpc.hpp index d90285c4eb56..382e20a6f1db 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.hpp @@ -22,7 +22,7 @@ class Dpc : public Algorithm public: Dpc(Controller *controller); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void Prepare(Metadata *image_metadata) override; private: diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index 4530cb75792c..cff3bfe01ed6 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -33,14 +33,14 @@ char const *Geq::Name() const return NAME; } -void Geq::Read(boost::property_tree::ptree const ¶ms) +void Geq::Read(const libcamera::YamlObject ¶ms) { - config_.offset = params.get("offset", 0); - config_.slope = params.get("slope", 0.0); + config_.offset = params["offset"].get(0); + config_.slope = params["slope"].get(0.0); if (config_.slope < 0.0 || config_.slope >= 1.0) throw std::runtime_error("Geq: bad slope value"); - if (params.get_child_optional("strength")) - config_.strength.Read(params.get_child("strength")); + if (params.contains("strength")) + config_.strength.Read(params["strength"]); } void Geq::Prepare(Metadata *image_metadata) diff --git a/src/ipa/raspberrypi/controller/rpi/geq.hpp b/src/ipa/raspberrypi/controller/rpi/geq.hpp index 8ba3046b2a2b..84104be40452 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.hpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.hpp @@ -24,7 +24,7 @@ class Geq : public Algorithm public: Geq(Controller *controller); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void Prepare(Metadata *image_metadata) override; private: diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index f77e9140ac10..cb93198d08a5 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -36,14 +36,14 @@ char const *Lux::Name() const return NAME; } -void Lux::Read(boost::property_tree::ptree const ¶ms) +void Lux::Read(const libcamera::YamlObject ¶ms) { reference_shutter_speed_ = - params.get("reference_shutter_speed") * 1.0us; - reference_gain_ = params.get("reference_gain"); - reference_aperture_ = params.get("reference_aperture", 1.0); - reference_Y_ = params.get("reference_Y"); - reference_lux_ = params.get("reference_lux"); + params["reference_shutter_speed"].get(0.0) * 1.0us; + reference_gain_ = params["reference_gain"].get(0.0); + reference_aperture_ = params["reference_aperture"].get(1.0); + reference_Y_ = params["reference_Y"].get(0.0); + reference_lux_ = params["reference_lux"].get(0.0); current_aperture_ = reference_aperture_; } diff --git a/src/ipa/raspberrypi/controller/rpi/lux.hpp b/src/ipa/raspberrypi/controller/rpi/lux.hpp index 3ebd35d1e382..7d85199f7def 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.hpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.hpp @@ -22,7 +22,7 @@ class Lux : public Algorithm public: Lux(Controller *controller); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void Prepare(Metadata *image_metadata) override; void Process(StatisticsPtr &stats, Metadata *image_metadata) override; void SetCurrentAperture(double aperture); diff --git a/src/ipa/raspberrypi/controller/rpi/noise.cpp b/src/ipa/raspberrypi/controller/rpi/noise.cpp index 63cad639f313..66a2a7f3486c 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.cpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.cpp @@ -39,10 +39,10 @@ void Noise::SwitchMode(CameraMode const &camera_mode, mode_factor_ = std::max(1.0, camera_mode.noise_factor); } -void Noise::Read(boost::property_tree::ptree const ¶ms) +void Noise::Read(const libcamera::YamlObject ¶ms) { - reference_constant_ = params.get("reference_constant"); - reference_slope_ = params.get("reference_slope"); + reference_constant_ = params["reference_constant"].get(0.0); + reference_slope_ = params["reference_slope"].get(0.0); } void Noise::Prepare(Metadata *image_metadata) diff --git a/src/ipa/raspberrypi/controller/rpi/noise.hpp b/src/ipa/raspberrypi/controller/rpi/noise.hpp index 1c9de5c87d08..353e79fa2a8c 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.hpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.hpp @@ -19,7 +19,7 @@ public: Noise(Controller *controller); char const *Name() const override; void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void Prepare(Metadata *image_metadata) override; private: diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index 9384550983e7..619a793cbdfb 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -32,10 +32,10 @@ char const *Sdn::Name() const return NAME; } -void Sdn::Read(boost::property_tree::ptree const ¶ms) +void Sdn::Read(const libcamera::YamlObject ¶ms) { - deviation_ = params.get("deviation", 3.2); - strength_ = params.get("strength", 0.75); + deviation_ = params["deviation"].get(3.2); + strength_ = params["strength"].get(0.75); } void Sdn::Initialise() {} diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.hpp b/src/ipa/raspberrypi/controller/rpi/sdn.hpp index 2371ce04163f..e69557908cea 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.hpp @@ -18,7 +18,7 @@ class Sdn : public DenoiseAlgorithm public: Sdn(Controller *controller = NULL); char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void Initialise() override; void Prepare(Metadata *image_metadata) override; void SetMode(DenoiseMode mode) override; diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp index 18825a43867b..491f88d06c79 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp @@ -37,11 +37,11 @@ void Sharpen::SwitchMode(CameraMode const &camera_mode, mode_factor_ = std::max(1.0, camera_mode.noise_factor); } -void Sharpen::Read(boost::property_tree::ptree const ¶ms) +void Sharpen::Read(const libcamera::YamlObject ¶ms) { - threshold_ = params.get("threshold", 1.0); - strength_ = params.get("strength", 1.0); - limit_ = params.get("limit", 1.0); + threshold_ = params["threshold"].get(1.0); + strength_ = params["strength"].get(1.0); + limit_ = params["limit"].get(1.0); LOG(RPiSharpen, Debug) << "Read threshold " << threshold_ << " strength " << strength_ diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp b/src/ipa/raspberrypi/controller/rpi/sharpen.hpp index 13a076a86895..6dfc79afb0ac 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.hpp @@ -19,7 +19,7 @@ public: Sharpen(Controller *controller); char const *Name() const override; void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; - void Read(boost::property_tree::ptree const ¶ms) override; + void Read(const libcamera::YamlObject ¶ms) override; void SetStrength(double strength) override; void Prepare(Metadata *image_metadata) override; diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build index 32897e07dad9..517d815bb98c 100644 --- a/src/ipa/raspberrypi/meson.build +++ b/src/ipa/raspberrypi/meson.build @@ -4,7 +4,6 @@ ipa_name = 'ipa_rpi' rpi_ipa_deps = [ libcamera_private, - dependency('boost'), libatomic, ] diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 3b126bb5175e..f0f568d12513 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include