Ask Your Question
1

CascadeClassifier::Load from Memory

asked 2014-02-07 11:37:28 -0600

dondan1976 gravatar image

updated 2014-02-07 11:54:35 -0600

berak gravatar image

Hey there,

I have the XML file compiled into the project and during run time i get the contents of the XML in a std::string.

Now i want to pass this into the CascadeClassifier::Load function. I am doing this so that there are no XML running around in the installation folder of my app.

Is it possible to do? Can i pass the string contents to Load function?

Or is there any other function i can use? Any other work around?

I am doing this to have the face detection feature.

Thanks

edit retag flag offensive close merge delete

Comments

I have a similar question. Why can't I copy a CascadeClassifier that's been loaded?

xaffeine gravatar imagexaffeine ( 2014-02-07 16:16:34 -0600 )edit

xaffeine, that is probably worth asking a seperate question ?

berak gravatar imageberak ( 2014-02-07 16:29:35 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-02-07 11:49:07 -0600

berak gravatar image

updated 2014-02-07 15:18:54 -0600

yes that's possible, but only for cascades generated by the newer cascade_training tool.

CascadeClassifier cc;
FileStorage fs( the_whole_cascade_in_a_string, FileStorage::READ | FileStorage::MEMORY);
cc.read(fs.getFirstTopLevelNode());

(with 3.0, you can convert old cascades to the new format with CascadeClassifier::convert() )

edit flag offensive delete link more

Comments

I don't see a Convert function in CascadeClassifier class.

How can i convert from old to new?

I am using OpenCV 2.4.8

dondan1976 gravatar imagedondan1976 ( 2014-02-07 12:07:32 -0600 )edit

hmm, not documented, but it should be :

bool ok = CascadeClassifier::convert(old_cascadefile_name, new_cascadefile_name);

berak gravatar imageberak ( 2014-02-07 12:20:26 -0600 )edit

nothing like convert in opencv libraries

dondan1976 gravatar imagedondan1976 ( 2014-02-07 14:57:35 -0600 )edit

awww, my bad, seems to be a 3.0 feature only

berak gravatar imageberak ( 2014-02-07 15:14:56 -0600 )edit

so how to do the old to new conversion?

is there any websites from where i can get the new xml's?

dondan1976 gravatar imagedondan1976 ( 2014-02-07 16:17:52 -0600 )edit

hmm, not really sure about the haar cascades, but anything here seems to be in the new format (save the softcascades, that's a total different story)

berak gravatar imageberak ( 2014-02-07 16:23:53 -0600 )edit

My app is crashing at this line,

cc.read(fs.getFirstTopLevelNode());

I got the new xml's and added. Everything before that line works fine. And i also have a proper xml data at that point.

dondan1976 gravatar imagedondan1976 ( 2014-02-07 16:29:28 -0600 )edit
1

hmm, it crashes in 3.0, in cc.read(); due to a uninitialized Ptr<CascadeClassifierImpl> ccimpl; well, that seems to be a bug.

but it works in 2.4.2 ( haven't got 2.4.8, sorry)

berak gravatar imageberak ( 2014-02-08 03:54:09 -0600 )edit

the_whole_cascade_in_a_string

hi, how we can convert xml content to in string form??? we have :

<?xml version="1.0"?>
<opencv_storage>
<haarcascade_frontalface_alt type_id="opencv-haar-classifier">
  <size>20 20</size>
  <stages>
    <_>
      <!-- stage 0 -->
      <trees>
        <_>
          <!-- tree 0 -->
          <_>
            <!-- root node -->
            <feature>

......

these are about 2500 lines!!!!

sabra gravatar imagesabra ( 2017-03-05 03:11:07 -0600 )edit

Question Tools

Stats

Asked: 2014-02-07 11:37:28 -0600

Seen: 2,262 times

Last updated: Feb 07 '14