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

OpenCV 3.4 / c++ CascadeClassifier use old xml file

user2634 Published in March 22, 2018, 11:26 pm

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:

    <Boca_17stages type_id="opencv-haar-classifier">
        25 15</size>
       <!-- stage 0 -->

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

<cascade type_id="opencv-cascade-classifier"> 

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();

 //nothing happens here, returns false, no file is created

 //works well:
 //Assertion fail
 //assertion fail

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.29415 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO