unfortunately, it's not that easy, as c++ does not have multiple line strings, and you'd have to escape all "
a common way to handle this, is to make a "binary array" out of the xml string, and #include
in your c++ prog.
think of it like this:
const char xml[] = {
60, 63, 120, 109, 108, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49,
....
};
so, you'll have to write a little program, to convert the xml file to a c++ header:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char **argv) {
string fn = "eye.xml";
ifstream in(fn.c_str());
string all,line;
while (getline(in,line))
all += line + "\n";
ofstream out("eye.h");
out << "const char xml[] = {";
for (size_t i=0; i<all.length(); i++) {
if (i%16==0) out << "\n";
out << int(all[i]) << ", ";
}
out << "10};\n";
return 0;
}
then, you can just use that in your prog:
#include "eye.h"
int main(int argc, const char * argv[])
{
FileStorage fs(xml, FileStorage::READ | FileStorage::MEMORY);
CascadeClassifier c;
bool ok = c.read(fs.getFirstTopLevelNode()); // NOT root() !
cerr << c.empty() << " " << ok << endl;
return 0;
}