Using a different cascade classifer

I’ve been trying to use my own cascade classifier to detect humans (full body) but I’m not sure where to put the cascade file in my file structure. I’ve already converted it into a binary file.

Wherever I add it, I get the error message of “Path not found” or “File not found”. Any help would be appreciated! Thanks!

Ibrahim will have to answer this. Most likely the loading code has a bug and a firmware fix will be needed.

Copy the cascade file to usd and use this:

image.HaarCascade("mycascade")

Tried that, didn’t work. Any other suggestion?? :open_mouth:

Can you please send me the cascade and I’ll test it. Just attach it to the post here if that doesn’t work send it to openmv@openmv.io

Hey seems to be working now! Had to give

image.HaarCascade("/mycascade")

. Took me a while to realize, haha! Thanks for your help! :smiley:

Would it be possible to reference the cascade file stored on the flash instead of the usd (in case you don’t want to use external memory) ?
I stored the file body.cascade on the flash memory and ran the main.py to store some log.txt file to make sure the location is correct.
I tried with os.listdir() and it plots this in the terminal:

>>> ['log.txt', 'openmv.inf', 'README.txt', '.fseventsd', '.Trash-1000', 'body.cascade', 'main_backup.py', 'main.py']

So the body.cascade is there.

If i then call

face_cascade = image.HaarCascade("/body", stages=25)

it seems to halt there, meaning it can’t find the file path for the body.cascade? (Tried also without the forward slash)

This is the main.py which is stored on the flash:

import sensor, time, image, os

sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)

files = os.listdir()
f = open('log.txt', 'w')
f.write(str(files))
#If i would f.close() the file here, it would correctly print out the list of files.

face_cascade = image.HaarCascade("/body", stages=25)
#Seems to never get to the below line.
f.write("-------")
f.close()

PS. Is there a way to see the a print command in a terminal when it’s in standalone mode or do i need to use uart?
I tried with

Screen /dev/ttyACM0 -L 115200

and

Screen /dev/ttyACM0 -L 115200

The latter brings me in micropython emulation mode, but none shows me a print("…") output.

OK, i’ve found this far that you can use the cascade file stored on the flash by entering

face_cascade = image.HaarCascade("body.cascade", stages=25)

Regarding the terminal question, seems that the IDE was still connected…

Other questions?

:slight_smile: yes, actually…
Could my script be the reason the main.py on the flash drive got protected?
How can i remove the protection, in the OpenMV IDE choosing ‘tools / save open script to OpenMV Cam’ fails as well:
save script error message: “error: cannot overwrite file /media/pascal/F9FE-5CA0/main.py: Read-only file system!”
Do i need to write the bootloader to make the files writeable again?

It sounds like Linux just doesn’t want to write to the device. Try chmod +w on the files.

Hi,

The slash issue should be fixed in the next release, I will make sure to test the sd and flash… Re the write permissions, I’m using Arch and the IDE can write to flash, at some point it didn’t work, I can’t remember exactly how I fixed it. These are my groups now: root uucp audio vboxusers plugdev