Identifying the position of a moving animal

OpenMV related project discussion.
xian
Posts: 2
Joined: Tue Oct 09, 2018 11:35 am

Identifying the position of a moving animal

Postby xian » Tue Oct 09, 2018 11:45 am

Hi there,

I just got one OpenMV cam 7 but i'm totally new to machine vision.
I need to use openmv cam to identify the position of an animal in the box. The box has left and right chambers, and the animal can freely go to either left or right side.
Once the animal was detected in each side, a TTL trigger will send out through different pins. Is there an example can do this kind project?
Thanks so much!

Xian
User avatar
kwagyeman
Posts: 3335
Joined: Sun May 24, 2015 2:10 pm

Re: Identifying the position of a moving animal

Postby kwagyeman » Tue Oct 09, 2018 12:25 pm

Hi, the easiest ways to do this are to use color tracking on the inverse of the color of the box. This will detect the animal. Is the box well lit? If so, then checkout the Color-Tracking Example scripts under OpenMV IDE and then use the Tools->Machine Vision->Threshold Editor to get the color tracking settings. Note that you want to pass the inverse flag to the find_blob() method to find everything not the color of the box.
Nyamekye,
xian
Posts: 2
Joined: Tue Oct 09, 2018 11:35 am

Re: Identifying the position of a moving animal

Postby xian » Tue Oct 09, 2018 1:36 pm

Thanks for the useful reply, i just tried and it indeed can track the moving animal. My following question is how do i know the position (or coordinate) of the moving animal?
User avatar
kwagyeman
Posts: 3335
Joined: Sun May 24, 2015 2:10 pm

Re: Identifying the position of a moving animal

Postby kwagyeman » Tue Oct 09, 2018 9:13 pm

Blob.cx() and blob.cy()
Nyamekye,
curry-te
Posts: 3
Joined: Mon Mar 18, 2019 10:22 am

Re: Identifying the position of a moving animal

Postby curry-te » Mon Mar 18, 2019 11:42 am

I would also like to tell if there is an animal in a scene but it is outside with clutter. I am thinking I would just like to know if the two images are similar (using the similarity class). Do you have any advice ? I think gray images would work.

Could I get similarity (similarity = fb.get_similarity(previousImage)) to use thresholds that are different for the top rows than the bottom rows. This is because the the top rows would mean that the animal is farther. I want to filter out smaller animals.
User avatar
kwagyeman
Posts: 3335
Joined: Sun May 24, 2015 2:10 pm

Re: Identifying the position of a moving animal

Postby kwagyeman » Mon Mar 18, 2019 11:55 am

The get similarly method is for perfect image to image comparisons.

Um, can you state your problem domain here? We specifically built the new H7 camera with thermal imaging support for this type of application so it's easy to do well and it will work in both night and day.
Nyamekye,
curry-te
Posts: 3
Joined: Mon Mar 18, 2019 10:22 am

Re: Identifying the position of a moving animal

Postby curry-te » Mon Mar 18, 2019 2:44 pm

Perfect, I pre-ordered the H7 yesterday.

Do you recommend the blob with the H7? I could generate a list of the blobs and compare these blob positions to see if the animals are moving. This will also allow me to know the row that the blob started so I can estimate animal size.

When will the thermal documentation (H7) be out?
curry-te
Posts: 3
Joined: Mon Mar 18, 2019 10:22 am

Re: Identifying the position of a moving animal

Postby curry-te » Mon Mar 18, 2019 3:05 pm

My system I am building cannot cost too much. I need to see if I can recognize animal movement without the thermal sensor.

Do you recommend the blobs with gray image?
User avatar
kwagyeman
Posts: 3335
Joined: Sun May 24, 2015 2:10 pm

Re: Identifying the position of a moving animal

Postby kwagyeman » Tue Mar 19, 2019 12:21 am

Hi, with a grayscale image you can do frame differencing to see what's changing against the background. This works well assuming there are no shadows and changing lighting.
Nyamekye,
alexxai
Posts: 2
Joined: Thu Sep 12, 2019 11:28 pm

Re: Identifying the position of a moving animal

Postby alexxai » Thu Sep 12, 2019 11:53 pm

Hi all! We seem to be working on a very similar application! Check out our project here, based on the M7, it works super well for detecting animals!
https://hackaday.io/project/162481-rode ... racker-rat

We also would like it to trigger a TTL line when the animal is in one half of the box. However I'm having a weird issue with this at the moment. We are using the LCD shield, and are using P6 for an output to take advantage of the DAC and ADC for future applications (I guess for this application we could use any free pin). We also physically disconnected P6 from the LCD shield so our pulses on P6 wouldn't also do brightness control.

Long story short, when I hook P6 up to an oscilloscope I see output as expected, it goes high (3.3V) when the centroid[1] of the blob is <80 (see code below). However, when I hook P6 up to equipment (an LED driver) nothing happens. It doesn't seem to source enough current to trigger the LED driver. Any ideas on why P6 wouldn't be able to trigger an LED driver? Is there something special I need to do with P6 to enable it to work this way?

We're setting up the output on P6 in the code with:

Code: Select all

# Set up Analog Output
dac = pyb.DAC(pyb.Pin('P6'))
dac.init(bits=12)
dac.write(0)
And triggering the output during the loop with:

Code: Select all

if centroid[1] < 80:
    dac.write(4095)
else:
    dac.write(0)
Thanks!
User avatar
kwagyeman
Posts: 3335
Joined: Sun May 24, 2015 2:10 pm

Re: Identifying the position of a moving animal

Postby kwagyeman » Fri Sep 13, 2019 12:26 am

Hi, did you connect the two grounds between the two devices?

Note, you don't need to out the pin into DAC mode. You can use it as a regular GPIO. Try that instead of DAC mode. The pin might not be able to handle a large load in DAC mode and might expect a low impedance.
Nyamekye,
alexxai
Posts: 2
Joined: Thu Sep 12, 2019 11:28 pm

Re: Identifying the position of a moving animal

Postby alexxai » Fri Sep 13, 2019 12:45 pm

Thanks for the quick reply!

Turns out the problem was the DAC mode. I put P6 in normal GPIO mode with:

Code: Select all

out = pyb.Pin("P6", pyb.Pin.OUT_PP)
And it works now, thanks!

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest