licornea_tools
feature_point.cc
Go to the documentation of this file.
1 #include "feature_point.h"
2 
3 namespace tlz {
4 
6  feature_point pt;
7  pt.position[0] = j_pt["x"];
8  pt.position[1] = j_pt["y"];
9  pt.depth = get_or(j_pt, "depth", 0.0);
10  pt.weight = get_or(j_pt, "weight", 1.0);
11  return pt;
12 }
13 
14 
16  json j_pt = json::object();
17  j_pt["x"] = pt.position[0];
18  j_pt["y"] = pt.position[1];
19  if(pt.depth != 0.0) j_pt["depth"] = pt.depth;
20  if(pt.weight != 1.0) j_pt["weight"] = pt.weight;
21  return j_pt;
22 }
23 
24 }
feature_point decode_feature_point(const json &j_pt)
Definition: feature_point.cc:5
json encode_feature_point(const feature_point &pt)
nlohmann::json json
Definition: json.h:11
T get_or(const json &j, const std::string &key, const T &default_value)
Definition: json.h:28