Img.find_template function

General discussion about topics related to OpenMV.
yocheng
Posts: 10
Joined: Tue Apr 24, 2018 11:58 pm

Img.find_template function

Postby yocheng » Wed Oct 17, 2018 6:06 am

I use the img.find_template function to find the template, but when looking for multiple templates, the speed will drop, is there any way to improve the efficiency of multiple templates?
User avatar
iabdalkader
Posts: 595
Joined: Sun May 24, 2015 3:53 pm

Re: Img.find_template function

Postby iabdalkader » Wed Oct 17, 2018 1:36 pm

Have you tried diamond search ?
yocheng
Posts: 10
Joined: Tue Apr 24, 2018 11:58 pm

Re: Img.find_template function

Postby yocheng » Thu Oct 18, 2018 12:59 am

iabdalkader wrote:
Wed Oct 17, 2018 1:36 pm
Have you tried diamond search ?

Yes, I use the box to find, the code is as follows, I want to know how to improve the efficiency and speed of the search under multiple templates.

r1 = img.find_template(template1, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
r2 = img.find_template(template2, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
r3 = img.find_template(template3, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
r4 = img.find_template(template4, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
r5 = img.find_template(template5, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
r6 = img.find_template(template6, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
r7 = img.find_template(template7, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))


if r1:
img.draw_rectangle(r1)
elif r2:
img.draw_rectangle(r2)
elif r3:
img.draw_rectangle(r3)
elif r4:
img.draw_rectangle(r4)
elif r5:
img.draw_rectangle(r5)
elif r6:
img.draw_rectangle(r6)
elif r7:
img.draw_rectangle(r7)
User avatar
iabdalkader
Posts: 595
Joined: Sun May 24, 2015 3:53 pm

Re: Img.find_template function

Postby iabdalkader » Thu Oct 18, 2018 5:09 pm

yocheng wrote:
Thu Oct 18, 2018 12:59 am
Yes, I use the box to find, the code is as follows, I want to know how to improve the efficiency and speed of the search under multiple templates.
r1 = img.find_template(template1, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
That's the exhaustive search, try:

Code: Select all

r1 = img.find_template(template1, search=SEARCH_DS)

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest