Ask Your Question
1

Convert old haarcascade file to new cascade classifier format

asked 2013-06-12 13:40:02 -0600

kinect_dev gravatar image

updated 2013-06-12 13:40:22 -0600

I'd like to convert the sample haar cascade files that come with OpenCV into the new file format. (Note: I do not want to convert them into LBP cascades, just the new format.) The reason I want to do this is so I can pass them into the CascadeClassifier as strings in memory instead of having CascadeClassifier load them from disk. (The platform I'm working on does not give me access to the hard drive.) This is only supported with files in the new format. Any idea how I can do that? I thought about loading the old files into the classifier, then writing them out again but this appears to write them out in the old format again.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-07-10 03:39:11 -0600

ne'mi gravatar image

updated 2013-07-10 03:52:32 -0600

Hi, I came across a similar problem in my work yesterday. I've sketched up my solution below. I have to warn you though, it's not been tested yet, but it should compile and hopefully work :). Give it a try ;)

class MyCascadeClassifier : public cv::CascadeClassifier {
public:
    MyCascadeClassifier(const cv::FileNode &node) {
            oldCascade = cv::Ptr<CvHaarClassifierCascade>((CvHaarClassifierCascade*)node.readObj());
    }
};

Now you can use MyCascadeClassifier instead of CascadeClassifier. Node must contain the node that looks like this:

<haarcascade_frontalface_alt type_id="opencv-haar-classifier">
...
edit flag offensive delete link more

Comments

Hello - I am also trying to convert the old format into the new format, however, this answer still uses the oldCascade property. Is there any way to use the new featureEvalulator format? I have also asked a similar question on stack overflow: http://stackoverflow.com/questions/20692660/how-would-i-convert-old-format-haarcascades-into-the-new-format-xml

_Robert gravatar image_Robert ( 2013-12-19 16:12:34 -0600 )edit

Question Tools

Stats

Asked: 2013-06-12 13:40:02 -0600

Seen: 2,571 times

Last updated: Jul 10 '13