Python Forum
template matching: more than one template?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
template matching: more than one template?
#2
You are likely needed to write a generator that return templates, e.g.

import glob, os

def get_templates(path='./templates', template_mask='png'):
    for f in glob.glob(os.path.join(path, '**', '*.' + template_mask)):
        yield cv2.imread(f, 0)

# now you can iterate over all templates 

for template in get_templates():
    result = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
    # do some stuff... 
Reply


Messages In This Thread
template matching: more than one template? - by jtl - Mar-13-2019, 01:48 PM
RE: template matching: more than one template? - by scidam - Mar-14-2019, 12:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Aligning a image to a template image robrod26 1 1,255 May-21-2022, 06:48 AM
Last Post: malikhussain

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020