implement own Haar-Cascade

I use my own haarcascade_eye.cascade to detect eye
Error: unaligned read buf:10004fd6 count3

best wishes

The link above seems not existed any longer. I get it from
but when I ran it with attached xml file on ubuntu, it printed below error message:

Converting new XML format…
Traceback (most recent call last):
File “”, line 422, in
File “”, line 419, in main
cascade_binary_universal(args.file, args.stages,
File “”, line 101, in cascade_binary_universal
cascade_binary(path, n_stages, name)
File “”, line 183, in cascade_binary
rects = feature[idx].getElementsByTagName(‘_’)
IndexError: list index out of range
haarcascade_frontalface_alt2.xml (528 KB)

Hi, support for the new Haar cascade format is somewhat limited, we only support 1 feature and 2 alpha per weak classifier. This cascade has 2 features and 3 alpha per weak classifier so it’s not going to work. See the haarcascade_frontalcatface.xml for an example of a supported new format cascade, or use the old format.

Does the cascade converter work on macos?I couldnt find the eye cascade binary in the Github directory, so had to generate it but it doesnt detect. I used the frontalface cascade binary provided and it works.

Hi, I’ll put some effort into updating the docs for all that in the future. Um, but, yest, it works on Mac if you have all the required libs.

Thanks for the reply. If the binary generated from the provided eye cascade xml doesn’t detect the eye, what could be the problem? i pass roi from the frontalface detect. I have attached my files. Could you please share me a working eye cascade binary, i am confused? (63.8 KB)

Haven’t tested it before on Mac.

The eye and face cascades are built-in the firmware because they are very common. To load a built-in cascade, just use its name without a path, ex:

c = load('eye.cascade')

. Also, you can re-generate any cascade from xml using the script.

Could you try the example first using the built-in cascades, and see if it works ?


Hi, looks fine but it doesnt work with the eye cascade generated by me. I have attached the cascade in my previous post, could you please regenerate and try?
Thanks for the support. Much appreciated!

The script should generate an identical cascade. Note I never tested the converted on Mac (and it doesn’t work on Windows) I can only confirm it works on Linux, you could try to run the script on Linux VM and compare the output.

Hi iabdalkader,

I tried to use your to convert haarcascade_frontalcatface.xml but always failed. and I don’t know why.
could you help me convert it?
Thanks a ton!

Hi iabdalkader,

I tried to use your to convert haarcascade_frontalcatface.xml but always failed. and I don’t know why.
could you help me convert it?
Thanks a ton!

Hi, please see the older replies to this thread. The script only works on Linux (for some reason) and it only supports the most basic Haar cascade (using the old format). If you’re having a different issue with the script please post the command you used and the error messages.

Hi iabdalkader,
thank you so much for your quick response and help!
Yes, I read and tried all the older replies but I can’t find any right solution. I used Python 2.7.5 and 2.7.13 to run to convert but both of them did not work. Can you help me convert it? Please find haarcascade_frontalcatface.xml attached. Thank you so much.
I am looking forward to hearing back from you. (241 KB)

Hi, as I already mentioned a few times, the script only works on Linux Not Windows.

Hi iabdalkader,
Thank you so much. Unfortunately I have no Linux so I hope you can help me convert it if you have time. Thanks a ton.

I tried to convert it but this file is a web page, seems you downloaded it from github, you need to download the raw xml file.

Hi iabdalkader,
Thank you so much for your help.
Now I downloaded the raw xml file from
haarcascade_frontalcatface-ok.xml (402 KB)
Looking forward to your converting for me. Thanks a ton.


In the future please use a Linux VM to convert cascades, I’ll get around to fixing the script on Windows. (11.5 KB)

Dear iabdalkader,
Thank you so much for your help and suggestion.
I will install Linux VM to convert cascades and also look forward to your fixing the script on Windows.

Thank you again.
Best regards.

The oemnv is great open vision library. Lately i apply it on some my research project.but i want to train my own cascade classfier.i train face_cascade.xml can detect face on opencv.
Howecer,i use convert to face.cascade can not detect face on openmv.May you help me .Thank you very much.
Hrer is my cascade.xml.
cascade.xml (39.9 KB)