I am trying to read the parameters of a trained Expectation Maximation model from an XML file for later use. In order to store the model I call
cv::FileStorage fs("model.xml",cv::FileStorage::WRITE);
classifier.write(fs); //classifier is of type cv::EM
this creates the file containing what looks like the data of the model. Here is what the files looks like (first few lines from the start):
StatModel.EM 1
<_ type_id="opencv-matrix"> 3 3 d
1.2159868951764311e+01 0. 0. 0. 1.9776824566023249e-01 0. 0. 0. .2204460492503131e-16
<_ type_id="opencv-matrix"> 3 3 d
3.2869203526862529e+00 0. 0. 0. 1.1631692248472096e+00 0. 0. 0. 2.2204460492503131e-16
<_ type_id="opencv-matrix"> 3 3 d
2.9815870012055705e+00 0. 0. 0. 6.5049770685681069e+03 0. 0. 0. 6.8510191786605528e+03
<_ type_id="opencv-matrix"> 3 3 d
4.6608996548002040e+00 0. 0. 0. 3.7558131457318683e+02 0. 0. 0. 2.2204460492503131e-16
Note, that the XML header is missing. Now in order to read the data I am using
cv::FileStorage fs("model.xml",cv::FileStorage::READ);
the cv::Algorithm::read() function has to be called with a filenode as parameter. I am not sure what node to use. Since I would expect there to be only one node in the file I tried
classifier.read(fs[0]);
But the algorithm is not trained afterwards. What do I need to do in order to restore the original parameters?