1 | initial version |
if you are using ClassifierCascade, you could save the xml as a string in some header file, and read it using FileStorage.
string xml_in_memory = "<xml> ..... </xml>";
CascadeClassifier casc;
FileStorage fs( xml_in_memory, FileStorage::READ|FileStorage::MEMORY);
FileNode fn = fs.getFirstTopLevelNode();
casc.read(fn);
unfortunately, this will only work with cascades in the new format, generated by opencv_traincascade, not with the old ones generated by opencv_haartraining.
2 | No.2 Revision |
if you are using ClassifierCascade, you could save the xml as a string in some header file, and read it using FileStorage.
string xml_in_memory = "<xml> "<?xml> ..... </xml>";
CascadeClassifier casc;
FileStorage fs( xml_in_memory, FileStorage::READ|FileStorage::MEMORY);
FileNode fn = fs.getFirstTopLevelNode();
casc.read(fn);
unfortunately, this will only work with cascades in the new format, generated by opencv_traincascade, not with the old ones generated by opencv_haartraining.
[edit] getting the xml-string right included some tricks.
string xml_in_memory =
"<?xml version=\"1.0\"?>\r\n" <-- escape the " (replace it by \")
"<!--\r\n"
" This is 20x34 detector of profile faces using LBP features.\r\n"
" It was created by Attila Novak during GSoC 2012.\r\n"
...
each line has to go into a single string, and you need to retain the linefeeds, so you will need a texteditor, that can handle backslash expressions like this:
\r\n -> \\r\\n"\r\n"
3 | No.3 Revision |
if you are using ClassifierCascade, you could save the xml as a string in some header file, and read it using FileStorage.
string xml_in_memory = "<?xml> ..... </xml>";
CascadeClassifier casc;
FileStorage fs( xml_in_memory, FileStorage::READ|FileStorage::MEMORY);
FileNode fn = fs.getFirstTopLevelNode();
casc.read(fn);
unfortunately, this will only work with cascades in the new format, generated by opencv_traincascade, not with the old ones generated by opencv_haartraining.
string xml_in_memory =
"<?xml version=\"1.0\"?>\r\n" <-- escape the " (replace it by \")
"<!--\r\n"
" This is 20x34 detector of profile faces using LBP features.\r\n"
" It was created by Attila Novak during GSoC 2012.\r\n"
...
each line has to go into a single string, and you need to retain the linefeeds, so you will need a texteditor, that can handle backslash expressions like this:
\r\n -> \\r\\n"\r\n"
4 | No.4 Revision |
if you are using ClassifierCascade, you could save the xml as a string in some header file, and read it from memory using FileStorage.
string xml_in_memory = "<?xml> ..... </xml>";
CascadeClassifier casc;
cascade;
FileStorage fs( xml_in_memory, FileStorage::READ|FileStorage::MEMORY);
FileNode fn = fs.getFirstTopLevelNode();
casc.read(fn);
bool ok = cascade.read(fn);
unfortunately, this will only work with cascades in the new format, generated by opencv_traincascade, not with the old ones generated by opencv_haartraining.
string xml_in_memory =
"<?xml version=\"1.0\"?>\r\n" <-- escape the " (replace it by \")
"<!--\r\n"
" This is 20x34 detector of profile faces using LBP features.\r\n"
" It was created by Attila Novak during GSoC 2012.\r\n"
...
each line has to go into a single string, and you need to retain the linefeeds, so you will need a texteditor, that can handle backslash expressions like this:
\r\n -> \\r\\n"\r\n"