示例#1
0
 def test_compare_color_diff(self):
     imgA = open_img("./testImage/TestOrig.jpg")
     imgB = open_img("./testImage/TestImage.png")
     imgA_avg = blockify(imgA)
     imgB_avg = blockify(imgB)
     result = diff(imgA_avg, imgB_avg)
     self.assertNotEqual(result, 1)
示例#2
0
 def test_compare_grey_similar(self):
     imgA = open_img(u"./testImage/[クール教信者] 小林さんちのメイドラゴン 01_pg4.jpg")
     imgB = open_img(u"./testImage/[クール教信者] 小林さんちのメイドラゴン 01_pg4_eng.jpg")
     imgA_avg = blockify(imgA)
     imgB_avg = blockify(imgB)
     result = diff(imgA_avg, imgB_avg)
     self.assertNotEqual(result, 1)
     self.assertGreater(result, .95)
示例#3
0
 def test_compare_color_similar(self):
     imgA = open_img("./testImage/TestOrig.jpg")
     imgB = open_img("./testImage/TestSimilar.jpg")
     imgA_avg = blockify(imgA)
     imgB_avg = blockify(imgB)
     result = diff(imgA_avg, imgB_avg)
     self.assertNotEqual(result, 1)
     self.assertGreater(result, .85)
示例#4
0
def __template_split(template, image_list, queue):
    template = cv2.imread(template, 0)
    match_list = []
    for image in image_list:
        img_rgb = open_img(image)
        img_grey = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
        width, height = template.shape[::-1]
        result = cv2.matchTemplate(img_grey, template, cv2.TM_CCOEFF_NORMED)
        # find if there is a match within the picture
        min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)

        if len(max_loc) > 0:
            # If the method is TM_SQDIFF or TM_SQDIFF_NORMED, take minimum
            top_left = max_loc
            bottom_right = (top_left[0] + width, top_left[1] + height)
            cv2.rectangle(img_rgb, top_left, bottom_right, 255, 2)

            # write matched file with rectangle indicating templated matches
            # write to cache folder
            img_name = path.basename(image)
            cache_path = CACHE + img_name
            cv2.imwrite(cache_path, img_rgb)
            match_list.append(cache_path)

    queue.put(match_list)