現在,boostを使用して,以下のxmlから座標値を取得して,4×4行列に値を格納したいのですが,その中身となる<Rotation><M_00>~<M_22>と<Center><x><y><z>を取得することができません.
たとえば,<ImagePath>や<FocalLength>は下記のプログラムで値を取得できますが,<Rotation>や<Center>のように子ノードに値が入っているとプログラムがうまく動きません(24~26行目の処理).色々調べているのですが,わからないため,解決策を教えていただけないでしょうか.
対象のXMLファイル
-<ATExport>
-<Photo>
<ImagePath>C:\Users\xxxx.JPG</ImagePath>
<FocalLength>4260.0611535683593</FocalLength>
<AspectRatio>1</AspectRatio>
-<Rotation>
<M_00>0.84296302804976242</M_00>
<M_01>0.53617827316920286</M_01>
<M_02>-0.043888412166162565</M_02>
<M_10>0.0057364743957685725</M_10>
<M_11>-0.090535342960440565</M_11>
<M_12>-0.99587672155570628</M_12>
<M_20>-0.53794091330059846</M_20>
<M_21>0.83923549201420622</M_21>
<M_22>-0.079393719783059272</M_22>
</Rotation>
-<Center>
<x>-1.6122401371584472</x>
<y>-3.0789121912094748</y>
<z>-0.11422715613536941</z>
</Center>
</Photo>
…
-<ATExport>
struct Photo{
string img_path; // ImagePath
float f_length; // FocalLength
Eigen::Matrix4f sensor_mat; // SensorMatrix(Rotation+Center)
};
bool MyFilesIO::LoadXmlFile()
{
using namespace boost::property_tree;
using namespace std;
std::vector<Photo> PhotoVector;
ptree pt;
read_xml( file_name, pt );
BOOST_FOREACH ( const auto &photo, pt.get_child("ATExport") ){
Photo *ph = new Photo();
ph->img_path = photo.second.get<string>("ImagePath");
ph->f_length = photo.second.get<float>("FocalLength");
BOOST_FOREACH (const auto &child, pt.get_child("ATExport.Photo.Rotation")){
ph->sensor_mat(0,0) = child.second.get<float>("M_00");
}
PhotoVector.push_back(*ph);
}
for(int i=0;i<PhotoVector.size();i++){
cout << "ImagePath[" << i << "]:" << PhotoVector[i].img_path << endl;
cout << "FocalLength[" <<i << "]:" << PhotoVector[i].f_length << endl;
cout << "Sensor_mat[" << i << "]:" << PhotoVector[i].sensor_mat << endl;
}
return true;
}