Reputation: 4996
I'm training a haar cascade using opencv_trainscascade. Its running fine, but I'd like to combine the various xml files generated from each stage into a usable output. Using the ./convert_cascade --size="XxX" output.xml is giving me an error. I know that that worked with opencv_haartraining fine to generate an intermediate result, but is there a way to do the same for the newer version?
OpenCV Error: Parsing error (classifier(0): Valid XML should start with '<?xml ...?>') in icvXMLParse, file /tmp/opencv-qGZ4sE/opencv-2.4.9/modules/core/src/persistence.cpp, line 2252
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv-qGZ4sE/opencv-2.4.9/modules/core/src/persistence.cpp:2252: error: (-212) classifier(0): Valid XML should start with '<?xml ...?>' in function icvXMLParse
Abort trap: 6
All the xml files in the directory seem fine.
Upvotes: 0
Views: 2297
Reputation: 329
The only way I was able to fix this was to change the character encoding from UTF-8 to ANSI with Notepad++. It worked fine after that.
Upvotes: 1
Reputation: 4996
Some digging around yielded this:
convert_cascade is for cascades trained by haartraining application and it does not support a format of cascades trained by traincascade application.
To do this with traincascade, just run opencv_traincascade again with the same "-data" but set "-numStages" to the point you want to generate up to. The application will load the trained stages, realize that there is required number of stages, write the result cascade in xml and finish a work. Interrupting the process during a stage could result in corrupt data, so if you're best off deleting the stage in completion.
Upvotes: 0