Using a different cascade classifer

Discussion related to "under the hood" OpenMV topics.
nikv96
Posts: 4
Joined: Tue Sep 06, 2016 11:56 pm

Using a different cascade classifer

Postby nikv96 » Wed Sep 07, 2016 12:12 am

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!
User avatar
kwagyeman
Posts: 1175
Joined: Sun May 24, 2015 2:10 pm

Re: Using a different cascade classifer

Postby kwagyeman » Wed Sep 07, 2016 9:32 am

Ibrahim will have to answer this. Most likely the loading code has a bug and a firmware fix will be needed.
Nyamekye,
User avatar
iabdalkader
Posts: 363
Joined: Sun May 24, 2015 3:53 pm

Re: Using a different cascade classifer

Postby iabdalkader » Wed Sep 07, 2016 12:32 pm

Copy the cascade file to usd and use this:

Code: Select all

image.HaarCascade("mycascade")
nikv96
Posts: 4
Joined: Tue Sep 06, 2016 11:56 pm

Re: Using a different cascade classifer

Postby nikv96 » Fri Sep 09, 2016 11:51 am

Tried that, didn't work. Any other suggestion?? :shock:
User avatar
iabdalkader
Posts: 363
Joined: Sun May 24, 2015 3:53 pm

Re: Using a different cascade classifer

Postby iabdalkader » Fri Sep 09, 2016 12:16 pm

nikv96 wrote:Tried that, didn't work. Any other suggestion?? :shock:
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
nikv96
Posts: 4
Joined: Tue Sep 06, 2016 11:56 pm

Re: Using a different cascade classifer

Postby nikv96 » Fri Sep 09, 2016 12:43 pm

Hey seems to be working now! Had to give

Code: Select all

image.HaarCascade("/mycascade")
. Took me a while to realize, haha! Thanks for your help! :D
pascati
Posts: 3
Joined: Thu Sep 28, 2017 8:40 am

Re: Using a different cascade classifer

Postby pascati » Thu Sep 28, 2017 9:04 am

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:

Code: Select all

>>> ['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

Code: Select all

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:

Code: Select all

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

Code: Select all

Screen /dev/ttyACM0 -L 115200
and

Code: Select all

Screen /dev/ttyACM0 -L 115200
The latter brings me in micropython emulation mode, but none shows me a print("...") output.
pascati
Posts: 3
Joined: Thu Sep 28, 2017 8:40 am

Re: Using a different cascade classifer

Postby pascati » Thu Sep 28, 2017 11:31 am

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

Code: Select all

face_cascade = image.HaarCascade("body.cascade", stages=25)
Regarding the terminal question, seems that the IDE was still connected...
User avatar
kwagyeman
Posts: 1175
Joined: Sun May 24, 2015 2:10 pm

Re: Using a different cascade classifer

Postby kwagyeman » Thu Sep 28, 2017 11:36 am

Other questions?
Nyamekye,
pascati
Posts: 3
Joined: Thu Sep 28, 2017 8:40 am

Re: Using a different cascade classifer

Postby pascati » Thu Sep 28, 2017 1:24 pm

:) 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?
User avatar
kwagyeman
Posts: 1175
Joined: Sun May 24, 2015 2:10 pm

Re: Using a different cascade classifer

Postby kwagyeman » Thu Sep 28, 2017 7:41 pm

It sounds like Linux just doesn't want to write to the device. Try chmod +w on the files.
Nyamekye,
User avatar
iabdalkader
Posts: 363
Joined: Sun May 24, 2015 3:53 pm

Re: Using a different cascade classifer

Postby iabdalkader » Sat Sep 30, 2017 7:21 pm

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

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest