Page 1 of 1

Img.find_template function

Posted: Wed Oct 17, 2018 6:06 am
by yocheng
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?

Re: Img.find_template function

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

Re: Img.find_template function

Posted: Thu Oct 18, 2018 12:59 am
by yocheng
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)

Re: Img.find_template function

Posted: Thu Oct 18, 2018 5:09 pm
by iabdalkader
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)