MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / from_json

Method from_json

src/PLPSLAM/data/camera_database.cc:78–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76 }
77
78 void camera_database::from_json(const nlohmann::json &json_cameras)
79 {
80 std::lock_guard<std::mutex> lock(mtx_database_);
81
82 spdlog::info("decoding {} camera(s) to load", json_cameras.size());
83 for (const auto &json_id_camera : json_cameras.items())
84 {
85 const auto &camera_name = json_id_camera.key();
86 const auto &json_camera = json_id_camera.value();
87
88 if (camera_name == curr_camera_->name_)
89 {
90 spdlog::info("load the tracking camera \"{}\" from JSON", camera_name);
91 continue;
92 }
93
94 spdlog::info("load a camera \"{}\" from JSON", camera_name);
95 camera::base *camera = nullptr;
96 const auto setup_type = camera::base::load_setup_type(json_camera.at("setup_type").get<std::string>());
97 const auto model_type = camera::base::load_model_type(json_camera.at("model_type").get<std::string>());
98 const auto color_order = camera::base::load_color_order(json_camera.at("color_order").get<std::string>());
99
100 switch (model_type)
101 {
102 case camera::model_type_t::Perspective:
103 {
104 camera = new camera::perspective(camera_name, setup_type, color_order,
105 json_camera.at("cols").get<unsigned int>(),
106 json_camera.at("rows").get<unsigned int>(),
107 json_camera.at("fps").get<double>(),
108 json_camera.at("fx").get<double>(),
109 json_camera.at("fy").get<double>(),
110 json_camera.at("cx").get<double>(),
111 json_camera.at("cy").get<double>(),
112 json_camera.at("k1").get<double>(),
113 json_camera.at("k2").get<double>(),
114 json_camera.at("p1").get<double>(),
115 json_camera.at("p2").get<double>(),
116 json_camera.at("k3").get<double>(),
117 json_camera.at("focal_x_baseline").get<double>());
118 break;
119 }
120 case camera::model_type_t::Fisheye:
121 {
122 camera = new camera::fisheye(camera_name, setup_type, color_order,
123 json_camera.at("cols").get<unsigned int>(),
124 json_camera.at("rows").get<unsigned int>(),
125 json_camera.at("fps").get<double>(),
126 json_camera.at("fx").get<double>(),
127 json_camera.at("fy").get<double>(),
128 json_camera.at("cx").get<double>(),
129 json_camera.at("cy").get<double>(),
130 json_camera.at("k1").get<double>(),
131 json_camera.at("k2").get<double>(),
132 json_camera.at("k3").get<double>(),
133 json_camera.at("k4").get<double>(),
134 json_camera.at("focal_x_baseline").get<double>());
135 break;

Callers

nothing calls this directly

Calls 5

infoFunction · 0.85
sizeMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected