Home OpenCV 3.4 / c++ CascadeClassifier use old xml file
Reply: 0

OpenCV 3.4 / c++ CascadeClassifier use old xml file

user2634
1#
user2634 Published in July 17, 2018, 7:54 am

I'v got OpenCV 3.4 and I'm using c++ for developement on a Linux computer.

I'm doing some face recognition stuff and wanted to use Haar-Cascadeclassifiers. I found pretrained mouth and nose Cascadeclassifier, but they are in the "old" .xml format which looks like this:

<opencv_storage>
    <Boca_17stages type_id="opencv-haar-classifier">
       <size>
        25 15</size>
       <stages>
       <_>
       <!-- stage 0 -->
          <trees>
       ...

The .xml files provided by OpenCV work well. Those files are the new version, which looks like this:

<opencv_storage>
<cascade type_id="opencv-cascade-classifier"> 
 <stageType>BOOST</stageType>
  <featureType>HAAR</featureType>
  <height>20</height>
  <width>20</width>
  <stageParams>
  ...

I read in different posts, that OpenCV still can handle those old .xml files and can even convert them. But when I call cv::CascadeClassifier::convert(const String& oldcascade, const String& newcascade) nothing happens and it returns false;

When I loaded an old .xml file and tried detectMultiScale(... I get an Assertion:

OpenCV Error: Assertion failed (!empty()) in detectMultiScale, file opencv-location/modules/objdetect/src/cascadedetect.cpp, line 1698
terminate called after throwing an instance of 'cv::Exception'
  what():  opencv-location/modules/objdetect/src/cascadedetect.cpp:1698: error: (-215) !empty() in function detectMultiScale

My code looks similar to this:

 //Greyscale image myGrayMat is given
 Vector<Rect> eyes;
 Vector<Rect> mouth;
 CasscadeClassifier eyes = CascadeClassifier ("haarcascade_frontalface_alt.xml")
 CasscadeClassifier mouthCas1 = CascadeClassifier("mouth.xml");
 CassCadeClassifier mouthCas2= CascadeClassifier();
 mouthCas1.load("mouth.xml");

 //nothing happens here, returns false, no file is created
 CascadeClassifier::convert("mouth.xml","mouth_new.xml");

 //works well:
 eyesCas.detectMultiScale(myGrayMat,eyes,1.1,2,0|CV_HAAR_FIND_BIGGEST_OBJECT,Size(20,20));
 //Assertion fail
 mouthCas.detectMultiScale(myGrayMat,mouths,1.1,2,0|CV_HAAR_FIND_BIGGEST_OBJECT,Size(15,25));
 //assertion fail
 mouthCas.detectMultiScale(myGrayMat,mouths,1.1,2,0|CV_HAAR_FIND_BIGGEST_OBJECT,Size(15,25));

Can anyone please help me? Or can anyone just please convert the .xml files? That would be great. Thanks a lot!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.430776 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO