22 #ifndef LANDMARKMAPPER_HPP_ 23 #define LANDMARKMAPPER_HPP_ 25 #include "boost/optional.hpp" 26 #include "boost/filesystem/path.hpp" 27 #include "boost/property_tree/ptree.hpp" 28 #include "boost/property_tree/info_parser.hpp" 74 using boost::property_tree::ptree;
77 boost::property_tree::info_parser::read_info(filename.string(), configtree);
79 catch (
const boost::property_tree::ptree_error& error) {
80 throw std::runtime_error(
string(
"LandmarkMapper: Error reading landmark-mappings file: ") + error.what());
84 ptree pt_landmark_mappings = configtree.get_child(
"landmarkMappings");
85 for (
auto&& mapping : pt_landmark_mappings) {
86 landmark_mappings.insert(make_pair(mapping.first, mapping.second.get_value<
string>()));
89 catch (
const boost::property_tree::ptree_error& error) {
90 throw std::runtime_error(
string(
"LandmarkMapper: Error while parsing the mappings file: ") + error.what());
92 catch (
const std::runtime_error& error) {
93 throw std::runtime_error(
string(
"LandmarkMapper: Error while parsing the mappings file: ") + error.what());
105 boost::optional<std::string>
convert(std::string landmark_name)
const 107 if (landmark_mappings.empty()) {
109 return landmark_name;
112 auto&& converted_landmark = landmark_mappings.find(landmark_name);
113 if (converted_landmark != std::end(landmark_mappings)) {
115 return converted_landmark->second;
130 return landmark_mappings.size();
134 std::map<std::string, std::string> landmark_mappings;
LandmarkMapper()=default
Constructs a new landmark mapper that performs an identity mapping, that is, its output is the same a...
auto size() const
Returns the number of loaded landmark mappings.
Definition: LandmarkMapper.hpp:128
Namespace containing all of eos's 3D model fitting functionality.
boost::optional< std::string > convert(std::string landmark_name) const
Converts the given landmark name to the mapped name.
Definition: LandmarkMapper.hpp:105
LandmarkMapper(boost::filesystem::path filename)
Constructs a new landmark mapper from a file containing mappings from one set of landmark identifiers...
Definition: LandmarkMapper.hpp:71
Represents a mapping from one kind of landmarks to a different format (e.g. model vertices)...
Definition: LandmarkMapper.hpp:52