I did my own haarcascade file and i want to include into program not to use SDCard.
Both main.py and haarcascade files work either from openIDE and SDCarrd, or only with SDCard.
I converted both main.py to ascii array and binary haardcascade file to hex array which are dynamically created in the program.
I compared both haarcascade files (original and created) without finding difference.
Unfortunately, image.HaarCaarcascade does not seem to work when the file is dynamically created…
Do i misunderstand something, or do i use wrong method ?
Thanks for help,
You mean you want to embed the cascade ? like the embedded face and eye cascades ? If so you’ll need to generate the C headers and rebuild the firmware. The image.HaarCaarcascade function can only load binary cascades from storage.
Yes, i embed the binary cascade.cascade by creating an hex array and create file with make_flash_fs().
I dont know how to gerenate the C headers.
But my problem is still the same when i debug the program during the flash mount, it is not ever well mounted (file permission ?)…
In this case, when i try to load the file with image.HaarCascade(), the program debugger reboots.
PS: I debug with gdb, baremetal and stlink device.
I did not solve this problem, but the method works, sorry.
I should open another post about this flash mount but i am not sure if it is not due to my configuration.
To embed the cascade you need to pass -c to cascade_convert.py
parser.add_argument("-c", "--header", action = "store_true", help = "generate a C header")
It will generate a header with C code, add it to cascade.h. And then you need to handle loading the new cascade from flash in imlib_load_cascade:
Finally rebuild the fw.
Note if your cascade is generic and useful I could add it to the built-in cascades, what does it detect ?
Thanks, it is very helpfull.
I try to detect “OK” like this http://thefanzine.com/wp-content/uploads/2012/04/2436.jpg
I think a CNN would be better to detect letters, but i dont have gpu in my computer right now to check it.
I used your method to create headers with different xml haarcascade files with success.
Except for the 64x64-20 stages file although i can convert to cascade.cascade.
The conversion to header stops to line 335
# read cascade size
size = (map(int, xmldoc.getElementsByTagName('size').childNodes.nodeValue.split()))
with indexError: list index out of range
I dont understand why the conversion works to binary and not to header…
Thanks for your light.
I can see the xml haar cascade file headers are different if i did haar cascade file with
- opencv under linux
cascade trainer gui soft under microsoft
The differences are about tag: [Opencv] , [cascade trainer gui] like
- size: [height, width] , [size]
stage threshold: [stageThreshold], [stage_threshold]
tree threshold: [internaltnode(3)] , [threshold]
Alpha1: [leafValue(0)] , [leftValue]
Alpha2: [leafValue(1)] , [rightValue]
I tried to correct it but the converted header file does not give me same result as converted cascade file.
Thanks for help
I don’t quite understand the issue, but note the cascade needs to be the old format and the most basic cascade.
Ok i removed the wrong files (new format) from this post, i will try to convert this new to old format and convert it again for openmv camera.