Configuring find_template function

General discussion about topics related to OpenMV.
drdrbidc
Posts: 3
Joined: Mon Mar 19, 2018 11:37 am

Configuring find_template function

Postby drdrbidc » Mon Mar 19, 2018 1:01 pm

Hello, so I'm trying to use the find_template function to detect if a clear water droplet is on a surface. I have good lighting, so the droplet is quite visible and distinct from the background. I'm having trouble with getting the function's sensitivity down. If I set it too low (lets say 0.6), I get too many false positives, but bumping it up by 0.1 does not detect it at all.
User avatar
iabdalkader
Posts: 446
Joined: Sun May 24, 2015 3:53 pm

Re: Configuring find_template function

Postby iabdalkader » Mon Mar 19, 2018 8:10 pm

Hi, can you attach an image of the surface with and without the droplet ?
drdrbidc
Posts: 3
Joined: Mon Mar 19, 2018 11:37 am

Re: Configuring find_template function

Postby drdrbidc » Tue Mar 20, 2018 2:50 pm

Here are the photos. I can't dye the droplets so find_blobs using color is out of the question.
Attachments
nodroplet.png
nodroplet.png (11.45 KiB) Viewed 395 times
droplet.png
droplet.png (11.07 KiB) Viewed 395 times
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Configuring find_template function

Postby kwagyeman » Tue Mar 20, 2018 3:24 pm

Hi, you need to do some image preprocessing to increase the obvious of the droplets. Is the camera in a fixed position in relation to what you are looking at? If so, then see the frame differencing example scripts for how to subtract the background. This will give you a blob then you can use find_blobs() on quite easily.
Nyamekye,
drdrbidc
Posts: 3
Joined: Mon Mar 19, 2018 11:37 am

Re: Configuring find_template function

Postby drdrbidc » Wed Mar 21, 2018 10:33 am

Thanks, I'm getting better results. The rectangles appear to surround the droplet (i.e. boxes on the reflected portions rather than the entire droplet). Is there any way to get the whole droplet to show up? It's probably difficult since they aren't distinct colors.

Also, how does get.similarity compare to blobs and templates? I might look into using that as well. My end goal is to make sure that all 3 droplets are there and give a warning if one of them isn't
Attachments
blob tracking.png
blob tracking.png (127.21 KiB) Viewed 331 times
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Configuring find_template function

Postby kwagyeman » Wed Mar 21, 2018 12:10 pm

Hi, use the merge=True feature of find_blobs() and set the margin=5 or higher. This will merge all the rects nearby into one. This should do what you want.
Nyamekye,
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Configuring find_template function

Postby kwagyeman » Wed Mar 21, 2018 12:12 pm

Once you've reduced the list of blobs to 3ish... Then filter out blobs which don't have a squarish shape. I.e make sure the width() and height () are similar. The easiest way to do this is to take the max() of both... square that, and then compare to the width() * height (). The larger the difference the less square.

Anyway, once you have the blob locations detected well then use get_stats() on each blobs ROI to get color details. You can use this info to verify that you don't see random stuff.
Nyamekye,
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Configuring find_template function

Postby kwagyeman » Wed Mar 21, 2018 12:17 pm

Get similarlity compares images to images... Um, you can just use template matching after you find the blob location on the next image from snapshot().

Anyway, I think you are almost there.
Nyamekye,

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 2 guests