Ask Your Question
0

Memory dump of CVHaarClassifierCascade

asked 2014-07-21 04:12:16 -0600

JaviUM gravatar image

Hello

I am using a DSP and I need to do this:

My system cannot read .XML, and I need to use an eyes CvHaarClassifier. I am using C.

I want to do a memory dump of the CvHaardCLassifierCascade and I need to save the data in a buffer.

The buffer will be an hexadecimal array and I want to save it in a .h file.

How can I do this??

Thank you very much.

Best Regards.

edit retag flag offensive close merge delete

Comments

in general, avoid all c-api functionality, it's no more developed.

so, just don't use the CvHaarClassifier, but the newer ClassifierCascade instead. it will allow you to read a lbp,hog or haarcascade from memory, you don't have to hack it.

berak gravatar imageberak ( 2014-07-21 05:19:40 -0600 )edit

Ok, thank you for your answer.

I will use ClassifierCascade but I need to parse the .xml classifier and I have to save the data in a file.h

Can I do this?? Someone know how to do this.

Kind Regards

JaviUM gravatar imageJaviUM ( 2014-07-22 02:12:41 -0600 )edit

maybe someone will need something like that. it is changed version of OpenCV 2.4.11 functions

sturkmen gravatar imagesturkmen ( 2015-08-25 16:16:28 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-07-22 02:23:11 -0600

berak gravatar image

updated 2014-07-22 02:46:33 -0600

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 cascade;
FileStorage fs( xml_in_memory, FileStorage::READ|FileStorage::MEMORY);
FileNode fn = fs.getFirstTopLevelNode();
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.

[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"
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-07-21 04:12:16 -0600

Seen: 346 times

Last updated: Jul 22 '14