Ask Your Question

Revision history [back]

Thank you, berak. For info, in the simple case of writing and reading, this works: cv::FileStorage fs; fs.open("mlp.xml", cv::FileStorage::WRITE); mlp->write(fs); fs.release();

mlp2 = ANN_MLP::create();
fs.open("mlp.xml", cv::FileStorage::READ);
mlp2->read(fs.root());
fs.release();

If the network is to be saved as a node in a larger hierarchy, write with: fs << "StructureAndWeights" << "{"; mlp->write(fs); fs << "}"; and read with: cv::FileNode node0 = fs.root(); cv::FileNode node1 = node0["StructureAndWeights"]; mlp2->read(node1);

click to hide/show revision 2
No.2 Revision

updated 2017-10-06 06:18:33 -0600

berak gravatar image

Thank you, berak. For info, in the simple case of writing and reading, this works: cv::FileStorage fs; fs.open("mlp.xml", cv::FileStorage::WRITE); mlp->write(fs); fs.release();works:

cv::FileStorage fs;
fs.open("mlp.xml", cv::FileStorage::WRITE);
mlp->write(fs);
fs.release();

mlp2 = ANN_MLP::create();
fs.open("mlp.xml", cv::FileStorage::READ);
mlp2->read(fs.root());
fs.release();

If the network is to be saved as a node in a larger hierarchy, write with: with:

  fs << "StructureAndWeights" << "{";
   mlp->write(fs);
   fs << "}";

and read with: with:

 cv::FileNode node0 = fs.root();
  cv::FileNode node1 = node0["StructureAndWeights"];
    mlp2->read(node1);

mlp2->read(node1);