use of haar classifier for openmv

Discussion related to "under the hood" OpenMV topics.
User avatar
chrisPyres66
Posts: 51
Joined: Mon Jul 16, 2018 9:22 am
Location: France

use of haar classifier for openmv

Postby chrisPyres66 » Mon Sep 10, 2018 9:19 am

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 cascade_convert.py 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 ?

Thanks,
User avatar
iabdalkader
Posts: 629
Joined: Sun May 24, 2015 3:53 pm

Re: use of haar classifier for openmv

Postby iabdalkader » Mon Sep 10, 2018 5:12 pm

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.
User avatar
chrisPyres66
Posts: 51
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: use of haar classifier for openmv

Postby chrisPyres66 » Thu Sep 13, 2018 8:20 am

Dear,

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() ?

Thanks,
User avatar
iabdalkader
Posts: 629
Joined: Sun May 24, 2015 3:53 pm

Re: use of haar classifier for openmv

Postby iabdalkader » Fri Sep 14, 2018 8:37 pm

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).
User avatar
chrisPyres66
Posts: 51
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: use of haar classifier for openmv

Postby chrisPyres66 » Mon Sep 17, 2018 4:56 am

Dear,

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.
User avatar
iabdalkader
Posts: 629
Joined: Sun May 24, 2015 3:53 pm

Re: use of haar classifier for openmv

Postby iabdalkader » Tue Sep 18, 2018 3:17 pm

chrisPyres66 wrote:
Mon Sep 17, 2018 4:56 am
if i can lost quality when i convert classifier.xml to classifier.classifier for openmv.
Yes, conversion process quantizes the values.
chrisPyres66 wrote:
Mon Sep 17, 2018 4:56 am
if i can have the same parameters for the same result.
No I wouldn't use the same values, you just have to start with the defaults and tune from there.
User avatar
chrisPyres66
Posts: 51
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: use of haar classifier for openmv

Postby chrisPyres66 » Fri Sep 21, 2018 4:24 am

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 ?

Thanks,
User avatar
iabdalkader
Posts: 629
Joined: Sun May 24, 2015 3:53 pm

Re: use of haar classifier for openmv

Postby iabdalkader » Sat Sep 22, 2018 7:36 am

chrisPyres66 wrote:
Fri Sep 21, 2018 4:24 am
I tried to read converted file but it looks like binary (I dont know how to transform it to array in the program ?).
Yes it's a binary file and you don't need to read it, see this example:

https://github.com/openmv/openmv/blob/m ... tection.py
chrisPyres66 wrote:
Fri Sep 21, 2018 4:24 am
Do you have idea about detection percentage we can lost ?
No I don't have any benchmarks, but it must be converted to fit into memory.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests