use of haar classifier for openmv

Dear all,

I try to do my own Haar classifier to use it on a M7 Openmv camera.

What i understood is :

  • to use image.HaarCascade(“haar_file_on_sdcard”) to load the cascade.xml specific for openmv.
  • then i use find_features to get the rectangle of my object in the image

To get this cascade.xml specific for openmv

  • i use with an cascade.xml got with opencv haar trainer

The detection is not very good, and i think i missed the understanding of some paramaters and i hope you could help me.

  • Why when i use stages=20 in opencv, i have got only 4 stages when i print the image.HaarCascade(“haar_file_on_sdcard”) ?

  • Can I use any of Haar, Lbp or Hog feature types to train my classifier ?

  • Can i use any of Basic, Core or All Haar feature type to train my classifier ?

  • can i use any of Gab, Dab, Rab or LB boost type to train my classifier ?

I tried first the default options, and i would like to know if all of them are compatible before using them to go further ?


Hi, not sure what the issue is with stages, but you should use the old format and we only support the most basic Haar cascade.


I am sorry there is not an issue with stages because you can choose to train your classifier with 20 stages and your training stops before because 8 stages is enough.

Therefore I do training with

  • base format save
  • Haar type
  • Basic Haar features
  • Gentle adaboost (GAB)

Ok, but what is the link between the threshold parameter of image.find_features() and the minNeighbors parameter of OpenCV detectMultiScale() ?


Multi scale is like the scale factor not threshold. In general, lower the scale factor to detect images at smaller scales (octaves), and increase the threshold for a higher detection rate (more false positives).


As you said, OpenCV detectMultiScale() has scale (>1: generally 1.15 to 1.35) and minNeighbors (>=0: generally 3) parameters.
Compare to it, image.find_features() has scale (>1) and threshold (0-1) parameters.

To test the classifier it is easier to do it with opencv, but i am not sure if i can have the same result with image.find_features().
I dont know :

  • if i can lost quality when i convert classifier.xml to classifier.classifier for openmv.

  • if i can have the same parameters for the same result.

My question is between use and process.
Thanks to clarify my light.

Yes, conversion process quantizes the values.

No I wouldn’t use the same values, you just have to start with the defaults and tune from there.

Dear Ibrahim,

Thanks for your help and time.

I believe to understand quantization is like rounding to pass 32bit float to 8bit fixed .
I tried to read converted file but it looks like binary (I dont know how to transform it to array in the program ?).

Do you have idea about detection percentage we can lost ?


Yes it’s a binary file and you don’t need to read it, see this example:

No I don’t have any benchmarks, but it must be converted to fit into memory.