def find_matches_in_cluster(cluster_and_descriptor): cluster, input_descriptors = cluster_and_descriptor imgMatch = cluster[0] print 'Matching ', os.path.dirname(imgMatch), '...' cluster_dir = os.path.dirname(imgMatch) cluster_files = glob.glob(os.path.join(cluster_dir, '*.png')) cluster_files = [f for f in cluster_files if not f.endswith('template.png')] cluster_descriptors = match.load_images_descriptors(cluster_files, os.path.join(cluster_dir, 'images.db')) return match.find_match(input_descriptors, cluster_descriptors)
def load_clusters_template_descriptors(): template_dirs = glob.glob('./clusters/*/*/') template_files = map(get_template_image, template_dirs) template_files = [f for f in template_files if os.stat(f).st_size > 0] return match.load_images_descriptors(template_files, './templates.db')