Is there a way to render a cascading haar file?

Assuming I have a haar cascade XML file. Is there a way to turn a file into an image to create a “perfect pattern”?

So, if xml is for face detection, will it show the face image that will get the best result?

If this is not possible, is there a way to portray the “core components”?

btw, I am using the openCV version in Python.

+4
source share
1 answer

As far as I know, it will be difficult. The classification scheme is complex, and I don’t think there is a simple way to “invert” it, to get a “perfect sample” or even something like the main components. (More on the main components below.) Let me try to quickly explain how classification is done so that it is clearer why these things are difficult; then Ill mention a few other approaches that you could try.

How the cascade works (approximately)

The idea of ​​the cascade is to make the classification faster by rejecting as many non-individuals as possible. (This is important since most of the things in the image will be illiterate.) You do this by having a cascade of classifiers. The first classifier is trained in such a way that it rejects, say, 90% of things that are not persons, but contain at least 99.99% of persons. This is still poor performance - you will get a lot of false positives if you just use this classifier. However, you can perform this classification quite quickly, so that you can quickly get rid of a large number of faces without a face.

OK, so what's in one of these classifiers? Well, each classifier is an extended set of weak classifiers. This means that for each image that you pass to the classifier, it passes it to each of N very simple classifiers, and each of the simple classifiers votes “true” or “false”. Each of the simple (weak) classifiers is weighted, so a weighted vote provides an answer for a strong classifier.

OK - so what is a weak classifier? I think that in OpenCV weak classifiers are decision trees with a height of 2 (see OpenCV docs , start page ~ 368). Therefore, each weak classifier compares the input image with a simple template; if the image is sufficiently similar to the template, it is transferred for comparison with another template; and if it is heterogeneous enough, it will be transferred for comparison with the third sample.

Why does this complicate the situation, and some things you might try

So, as you probably see, it is really impossible to make it an “ideal model”, since there are many non-linearities in the decision-making process - an “ideal model” for one of the weak classifiers can be a terrible model for most others, which means that in general it would not create a good face. The same problem with displaying important components, but you could find somewhere by selecting the most important (i.e. the highest) weak classifiers at the first (or final) stage, and then constructing the filters that are used by these stages.

Another approach that you could try is the one that I saw in the art project, but, unfortunately, I can not find the link. The artist generated random combinations of shapes and saw how much they triggered a face detector. He arbitrarily added more shapes and saved configurations of shapes that worked better with the launch of face detection. Thanks to this hill climbing strategy, he was able to generate face-like images using an algorithm. A finer version of this approach - finding a space of incentives for things that are classified as faces - can help find a “perfect pattern,” so to speak.

Hope this helps ... good luck!

+6
source

All Articles