forked from noether/visionloc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.cc
34 lines (27 loc) · 1.25 KB
/
parser.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <string>
#include <vector>
#include <tinyxml2.h>
#include <cstdlib>
#include "misc.hh"
#include "camera.hh"
void parser_xml_to_cameras(std::vector<Camera> *cameras)
{
tinyxml2::XMLDocument doc;
doc.LoadFile("camerasInfo.xml");
tinyxml2::XMLElement* xml_camera = doc.FirstChildElement("Camera");
while (xml_camera != NULL)
{
std::string id(xml_camera->FirstChildElement("ID")->GetText());
std::string width(xml_camera->FirstChildElement("Width")->GetText());
std::string height(xml_camera->FirstChildElement("Height")->GetText());
std::string wc_height(xml_camera->FirstChildElement("WCHeight")->GetText());
std::string wc_offset_x(xml_camera->FirstChildElement("WCOffX")->GetText());
std::string wc_offset_y(xml_camera->FirstChildElement("WCOffY")->GetText());
std::string wc_offset_angle(xml_camera->FirstChildElement("WCOffAngle")->GetText());
Camera camera(atoi(id.c_str()), atoi(width.c_str()),
atoi(height.c_str()), atof(wc_height.c_str()), atof(wc_offset_x.c_str()),
atof(wc_offset_y.c_str()), atof(wc_offset_angle.c_str()));
cameras->push_back(camera);
xml_camera = xml_camera->NextSiblingElement("Camera");
}
}