0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ステーキ定食の画像から物体を選別できないかやってみた - ⑤類似画像特徴点検出編

Last updated at Posted at 2017-06-15

はじめに

ステーキ定食の画像から物体を選別できないかやってみた - ③類似画像ヒートマップ検出編において、ヒートマップによる類似画像の検出を行いましたが、他の方法として特徴点の検出ではどのような結果になるか試してみました。

参考元

  • [Python + OpenCVで画像の類似度を求める](Python + OpenCVで画像の類似度を求める)

ソースコード

grouping_image2
#!/usr/local/bin/python
# -*- coding: utf-8 -*-

import cv2
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import selectivesearch
import os
import sys

def main():
    # loading lena image
    img = cv2.imread("{画像パス}")

    # perform selective search
    img_lbl, regions = selectivesearch.selective_search(
        img,
        scale=500,
        sigma=0.9,
        min_size=10
    )

    candidates = set()

    for r in regions:
        # excluding same rectangle (with different segments)
        if r['rect'] in candidates:
            continue

        # excluding regions smaller than 2000 pixels
        if r['size'] < 2000:
            continue

        # distorted rects
        x, y, w, h = r['rect']

        if w / h > 1.2 or h / w > 1.2:
            continue

        candidates.add(r['rect'])

    # draw rectangles on the original image
    fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
    ax.imshow(img)

    overlaps = {}

    # オーバーラップの数をカウントして配列に代入します。
    for x, y, w, h in candidates:
        group = '%s_%s_%s_%s' % (x, y, w, h)

        for x2, y2, w2, h2 in candidates:
            if x2 - w < x < x2 + w2 and y2 - h < y < y2 + h2:

                if not group in overlaps:
                    overlaps[group] = 0

                overlaps[group] = overlaps[group] + 1

    # オーバーラップの数が30以上のファイルを出力します(30は勝手に閾値を敷いています)。
    for key, overlap in enumerate(overlaps):
        if overlap > 30:
            for x, y, w, h in candidates:
                group = '%s_%s_%s_%s' % (x, y, w, h)

                if group in overlaps:
                    cv2.imwrite("{ディレクトリパス}" + str(group) + '.jpg', img[y:y + h, x:x + w])

    image_dir = "{ディレクトリパス}"
    target_files = os.listdir(image_dir)
    files = os.listdir(image_dir)

    group_images = {}

    for target_file in target_files:
        if target_file == '.DS_Store':
            continue

        # 画像ファイルを読み込みます。
        target_image_path = image_dir + target_file
        target_image = cv2.imread(target_image_path)

        # 特徴点データを生成します。
        bf = cv2.BFMatcher(cv2.NORM_HAMMING)
        # detector = cv2.AKAZE_create()
        detector = cv2.ORB_create()
        (target_kp, target_des) = detector.detectAndCompute(target_image, None)

        similarity_images = {}

        for file in files:
            if file == '.DS_Store' or file == target_file:
                continue
            try:
                # 画像ファイルを読み込みます。
                comparing_image_path = image_dir + file
                comparing_image = cv2.imread(comparing_image_path)

                # 特徴点データを生成します。
                (comparing_kp, comparing_des) = detector.detectAndCompute(comparing_image, None)

                # 特徴点の距離算出して画像の類似度を算出します。
                matches = bf.match(target_des, comparing_des)

                # 結果を確率表記に変換します。
                dist = [m.distance for m in matches]
                probability = sum(dist) / len(dist)
            except cv2.error:
                probability = 100000

            # 類似度を出力します。
            print("target file: " + target_file, "file: " + file, "similarity: " + str(probability))

if __name__ == "__main__":
    main()

結果

ORBの場合

('target file: 0_0_553_419.jpg', 'file: 0_0_599_419.jpg', 'similarity: 10.066')
('target file: 0_0_553_419.jpg', 'file: 137_146_120_74.jpg', 'similarity: 114.752')
('target file: 0_0_553_419.jpg', 'file: 137_45_404_229.jpg', 'similarity: 57.85')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 178_121_226_133.jpg', 'similarity: 72.288')
('target file: 0_0_553_419.jpg', 'file: 178_45_363_220.jpg', 'similarity: 60.832')
('target file: 0_0_553_419.jpg', 'file: 178_45_363_229.jpg', 'similarity: 60.274')
('target file: 0_0_553_419.jpg', 'file: 227_285_134_108.jpg', 'similarity: 74.564')
('target file: 0_0_553_419.jpg', 'file: 227_285_135_111.jpg', 'similarity: 73.186')
('target file: 0_0_553_419.jpg', 'file: 229_45_312_220.jpg', 'similarity: 63.454')
('target file: 0_0_553_419.jpg', 'file: 229_49_156_125.jpg', 'similarity: 66.79')
('target file: 0_0_553_419.jpg', 'file: 238_49_147_113.jpg', 'similarity: 69.928')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 273_0_326_365.jpg', 'similarity: 59.974')
('target file: 0_0_553_419.jpg', 'file: 273_174_119_91.jpg', 'similarity: 107.31')
('target file: 0_0_553_419.jpg', 'file: 273_8_227_127.jpg', 'similarity: 72.85')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 297_49_88_88.jpg', 'similarity: 89.28')
('target file: 0_0_553_419.jpg', 'file: 301_0_298_268.jpg', 'similarity: 66.55')
('target file: 0_0_553_419.jpg', 'file: 301_0_298_365.jpg', 'similarity: 62.89')
('target file: 0_0_553_419.jpg', 'file: 31_0_100_119.jpg', 'similarity: 84.416')
('target file: 0_0_553_419.jpg', 'file: 31_0_258_143.jpg', 'similarity: 79.114')
('target file: 0_0_553_419.jpg', 'file: 31_0_258_191.jpg', 'similarity: 71.458')
('target file: 0_0_553_419.jpg', 'file: 31_0_529_414.jpg', 'similarity: 18.948')
('target file: 0_0_553_419.jpg', 'file: 31_0_533_416.jpg', 'similarity: 20.062')
('target file: 0_0_553_419.jpg', 'file: 329_45_212_220.jpg', 'similarity: 71.26')
('target file: 0_0_553_419.jpg', 'file: 336_45_205_220.jpg', 'similarity: 71.14')
('target file: 0_0_553_419.jpg', 'file: 379_259_161_122.jpg', 'similarity: 77.456')
('target file: 0_0_553_419.jpg', 'file: 39_112_521_302.jpg', 'similarity: 32.126')
('target file: 0_0_553_419.jpg', 'file: 39_115_521_299.jpg', 'similarity: 32.158')
('target file: 0_0_553_419.jpg', 'file: 405_174_126_94.jpg', 'similarity: 82.138')
('target file: 0_0_553_419.jpg', 'file: 408_303_156_113.jpg', 'similarity: 75.892')
('target file: 0_0_553_419.jpg', 'file: 408_305_156_111.jpg', 'similarity: 75.468')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 52_184_224_199.jpg', 'similarity: 57.48')
('target file: 0_0_553_419.jpg', 'file: 52_184_311_211.jpg', 'similarity: 48.768')
('target file: 0_0_553_419.jpg', 'file: 52_230_194_153.jpg', 'similarity: 63.69')
('target file: 0_0_553_419.jpg', 'file: 52_230_224_153.jpg', 'similarity: 62.202')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 56_0_200_113.jpg', 'similarity: 83.034')
('target file: 0_0_553_419.jpg', 'file: 56_0_217_116.jpg', 'similarity: 82.33')
('target file: 0_0_553_419.jpg', 'file: 57_245_167_106.jpg', 'similarity: 73.444')
('target file: 0_0_553_419.jpg', 'file: 57_245_167_112.jpg', 'similarity: 71.926')
('target file: 0_0_553_419.jpg', 'file: 57_245_167_134.jpg', 'similarity: 69.264')
('target file: 0_0_553_419.jpg', 'file: 57_45_484_334.jpg', 'similarity: 31.454')
('target file: 0_0_553_419.jpg', 'file: 57_45_496_334.jpg', 'similarity: 30.714')
('target file: 0_0_553_419.jpg', 'file: 59_0_197_113.jpg', 'similarity: 82.358')
('target file: 0_0_553_419.jpg', 'file: 70_268_146_110.jpg', 'similarity: 78.664')
('target file: 0_0_599_419.jpg', 'file: 0_0_553_419.jpg', 'similarity: 10.04')
('target file: 0_0_599_419.jpg', 'file: 137_146_120_74.jpg', 'similarity: 114.648')
('target file: 0_0_599_419.jpg', 'file: 137_45_404_229.jpg', 'similarity: 57.818')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 178_121_226_133.jpg', 'similarity: 72.058')
('target file: 0_0_599_419.jpg', 'file: 178_45_363_220.jpg', 'similarity: 60.514')
('target file: 0_0_599_419.jpg', 'file: 178_45_363_229.jpg', 'similarity: 59.968')
('target file: 0_0_599_419.jpg', 'file: 227_285_134_108.jpg', 'similarity: 73.962')
('target file: 0_0_599_419.jpg', 'file: 227_285_135_111.jpg', 'similarity: 72.458')
('target file: 0_0_599_419.jpg', 'file: 229_45_312_220.jpg', 'similarity: 62.952')
('target file: 0_0_599_419.jpg', 'file: 229_49_156_125.jpg', 'similarity: 66.496')
('target file: 0_0_599_419.jpg', 'file: 238_49_147_113.jpg', 'similarity: 69.24')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 273_0_326_365.jpg', 'similarity: 57.856')
('target file: 0_0_599_419.jpg', 'file: 273_174_119_91.jpg', 'similarity: 107.078')
('target file: 0_0_599_419.jpg', 'file: 273_8_227_127.jpg', 'similarity: 72.558')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 297_49_88_88.jpg', 'similarity: 88.796')
('target file: 0_0_599_419.jpg', 'file: 301_0_298_268.jpg', 'similarity: 64.96')
('target file: 0_0_599_419.jpg', 'file: 301_0_298_365.jpg', 'similarity: 60.608')
('target file: 0_0_599_419.jpg', 'file: 31_0_100_119.jpg', 'similarity: 84.626')
('target file: 0_0_599_419.jpg', 'file: 31_0_258_143.jpg', 'similarity: 78.84')
('target file: 0_0_599_419.jpg', 'file: 31_0_258_191.jpg', 'similarity: 71.386')
('target file: 0_0_599_419.jpg', 'file: 31_0_529_414.jpg', 'similarity: 20.542')
('target file: 0_0_599_419.jpg', 'file: 31_0_533_416.jpg', 'similarity: 21.168')
('target file: 0_0_599_419.jpg', 'file: 329_45_212_220.jpg', 'similarity: 70.852')
('target file: 0_0_599_419.jpg', 'file: 336_45_205_220.jpg', 'similarity: 70.748')
('target file: 0_0_599_419.jpg', 'file: 379_259_161_122.jpg', 'similarity: 77.396')
('target file: 0_0_599_419.jpg', 'file: 39_112_521_302.jpg', 'similarity: 32.466')
('target file: 0_0_599_419.jpg', 'file: 39_115_521_299.jpg', 'similarity: 32.054')
('target file: 0_0_599_419.jpg', 'file: 405_174_126_94.jpg', 'similarity: 82.374')
('target file: 0_0_599_419.jpg', 'file: 408_303_156_113.jpg', 'similarity: 75.978')
('target file: 0_0_599_419.jpg', 'file: 408_305_156_111.jpg', 'similarity: 75.418')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 52_184_224_199.jpg', 'similarity: 57.374')
('target file: 0_0_599_419.jpg', 'file: 52_184_311_211.jpg', 'similarity: 49.128')
('target file: 0_0_599_419.jpg', 'file: 52_230_194_153.jpg', 'similarity: 63.664')
('target file: 0_0_599_419.jpg', 'file: 52_230_224_153.jpg', 'similarity: 62.094')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 56_0_200_113.jpg', 'similarity: 82.618')
('target file: 0_0_599_419.jpg', 'file: 56_0_217_116.jpg', 'similarity: 82.058')
('target file: 0_0_599_419.jpg', 'file: 57_245_167_106.jpg', 'similarity: 73.52')
('target file: 0_0_599_419.jpg', 'file: 57_245_167_112.jpg', 'similarity: 71.722')
('target file: 0_0_599_419.jpg', 'file: 57_245_167_134.jpg', 'similarity: 69.116')
('target file: 0_0_599_419.jpg', 'file: 57_45_484_334.jpg', 'similarity: 32.522')
('target file: 0_0_599_419.jpg', 'file: 57_45_496_334.jpg', 'similarity: 31.93')
('target file: 0_0_599_419.jpg', 'file: 59_0_197_113.jpg', 'similarity: 82.124')
('target file: 0_0_599_419.jpg', 'file: 70_268_146_110.jpg', 'similarity: 78.432')
('target file: 137_146_120_74.jpg', 'file: 0_0_553_419.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 0_0_599_419.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 137_45_404_229.jpg', 'similarity: 0.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 178_121_226_133.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 178_45_363_220.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 178_45_363_229.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 227_285_134_108.jpg', 'similarity: 59.0')
('target file: 137_146_120_74.jpg', 'file: 227_285_135_111.jpg', 'similarity: 54.0')
('target file: 137_146_120_74.jpg', 'file: 229_45_312_220.jpg', 'similarity: 60.0')
('target file: 137_146_120_74.jpg', 'file: 229_49_156_125.jpg', 'similarity: 57.0')
('target file: 137_146_120_74.jpg', 'file: 238_49_147_113.jpg', 'similarity: 72.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 273_0_326_365.jpg', 'similarity: 65.0')
('target file: 137_146_120_74.jpg', 'file: 273_174_119_91.jpg', 'similarity: 89.0')
('target file: 137_146_120_74.jpg', 'file: 273_8_227_127.jpg', 'similarity: 82.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 297_49_88_88.jpg', 'similarity: 72.0')
('target file: 137_146_120_74.jpg', 'file: 301_0_298_268.jpg', 'similarity: 66.0')
('target file: 137_146_120_74.jpg', 'file: 301_0_298_365.jpg', 'similarity: 67.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_100_119.jpg', 'similarity: 71.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_258_143.jpg', 'similarity: 73.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_258_191.jpg', 'similarity: 71.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_529_414.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_533_416.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 329_45_212_220.jpg', 'similarity: 62.0')
('target file: 137_146_120_74.jpg', 'file: 336_45_205_220.jpg', 'similarity: 62.0')
('target file: 137_146_120_74.jpg', 'file: 379_259_161_122.jpg', 'similarity: 71.0')
('target file: 137_146_120_74.jpg', 'file: 39_112_521_302.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 39_115_521_299.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 405_174_126_94.jpg', 'similarity: 77.0')
('target file: 137_146_120_74.jpg', 'file: 408_303_156_113.jpg', 'similarity: 86.0')
('target file: 137_146_120_74.jpg', 'file: 408_305_156_111.jpg', 'similarity: 85.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 52_184_224_199.jpg', 'similarity: 65.0')
('target file: 137_146_120_74.jpg', 'file: 52_184_311_211.jpg', 'similarity: 60.0')
('target file: 137_146_120_74.jpg', 'file: 52_230_194_153.jpg', 'similarity: 70.0')
('target file: 137_146_120_74.jpg', 'file: 52_230_224_153.jpg', 'similarity: 70.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 56_0_200_113.jpg', 'similarity: 68.0')
('target file: 137_146_120_74.jpg', 'file: 56_0_217_116.jpg', 'similarity: 69.0')
('target file: 137_146_120_74.jpg', 'file: 57_245_167_106.jpg', 'similarity: 71.0')
('target file: 137_146_120_74.jpg', 'file: 57_245_167_112.jpg', 'similarity: 71.0')
('target file: 137_146_120_74.jpg', 'file: 57_245_167_134.jpg', 'similarity: 61.0')
('target file: 137_146_120_74.jpg', 'file: 57_45_484_334.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 57_45_496_334.jpg', 'similarity: 0.0')
('target file: 137_146_120_74.jpg', 'file: 59_0_197_113.jpg', 'similarity: 78.0')
('target file: 137_146_120_74.jpg', 'file: 70_268_146_110.jpg', 'similarity: 65.0')
('target file: 137_45_404_229.jpg', 'file: 0_0_553_419.jpg', 'similarity: 56.2456140351')
('target file: 137_45_404_229.jpg', 'file: 0_0_599_419.jpg', 'similarity: 56.298245614')
('target file: 137_45_404_229.jpg', 'file: 137_146_120_74.jpg', 'similarity: 116.833333333')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 178_121_226_133.jpg', 'similarity: 70.6513157895')
('target file: 137_45_404_229.jpg', 'file: 178_45_363_220.jpg', 'similarity: 28.8004385965')
('target file: 137_45_404_229.jpg', 'file: 178_45_363_229.jpg', 'similarity: 21.9671052632')
('target file: 137_45_404_229.jpg', 'file: 227_285_134_108.jpg', 'similarity: 80.0021929825')
('target file: 137_45_404_229.jpg', 'file: 227_285_135_111.jpg', 'similarity: 78.4978070175')
('target file: 137_45_404_229.jpg', 'file: 229_45_312_220.jpg', 'similarity: 33.4649122807')
('target file: 137_45_404_229.jpg', 'file: 229_49_156_125.jpg', 'similarity: 65.6907894737')
('target file: 137_45_404_229.jpg', 'file: 238_49_147_113.jpg', 'similarity: 69.0723684211')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 273_0_326_365.jpg', 'similarity: 44.8815789474')
('target file: 137_45_404_229.jpg', 'file: 273_174_119_91.jpg', 'similarity: 105.296052632')
('target file: 137_45_404_229.jpg', 'file: 273_8_227_127.jpg', 'similarity: 70.4934210526')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 297_49_88_88.jpg', 'similarity: 90.1622807018')
('target file: 137_45_404_229.jpg', 'file: 301_0_298_268.jpg', 'similarity: 43.5')
('target file: 137_45_404_229.jpg', 'file: 301_0_298_365.jpg', 'similarity: 45.3552631579')
('target file: 137_45_404_229.jpg', 'file: 31_0_100_119.jpg', 'similarity: 84.8530701754')
('target file: 137_45_404_229.jpg', 'file: 31_0_258_143.jpg', 'similarity: 77.9013157895')
('target file: 137_45_404_229.jpg', 'file: 31_0_258_191.jpg', 'similarity: 73.4780701754')
('target file: 137_45_404_229.jpg', 'file: 31_0_529_414.jpg', 'similarity: 54.4583333333')
('target file: 137_45_404_229.jpg', 'file: 31_0_533_416.jpg', 'similarity: 54.9934210526')
('target file: 137_45_404_229.jpg', 'file: 329_45_212_220.jpg', 'similarity: 47.9254385965')
('target file: 137_45_404_229.jpg', 'file: 336_45_205_220.jpg', 'similarity: 49.2609649123')
('target file: 137_45_404_229.jpg', 'file: 379_259_161_122.jpg', 'similarity: 76.2324561404')
('target file: 137_45_404_229.jpg', 'file: 39_112_521_302.jpg', 'similarity: 58.1184210526')
('target file: 137_45_404_229.jpg', 'file: 39_115_521_299.jpg', 'similarity: 58.7565789474')
('target file: 137_45_404_229.jpg', 'file: 405_174_126_94.jpg', 'similarity: 76.0131578947')
('target file: 137_45_404_229.jpg', 'file: 408_303_156_113.jpg', 'similarity: 76.5416666667')
('target file: 137_45_404_229.jpg', 'file: 408_305_156_111.jpg', 'similarity: 76.0592105263')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 52_184_224_199.jpg', 'similarity: 69.0285087719')
('target file: 137_45_404_229.jpg', 'file: 52_184_311_211.jpg', 'similarity: 66.6228070175')
('target file: 137_45_404_229.jpg', 'file: 52_230_194_153.jpg', 'similarity: 71.7236842105')
('target file: 137_45_404_229.jpg', 'file: 52_230_224_153.jpg', 'similarity: 70.125')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 56_0_200_113.jpg', 'similarity: 82.5307017544')
('target file: 137_45_404_229.jpg', 'file: 56_0_217_116.jpg', 'similarity: 81.9385964912')
('target file: 137_45_404_229.jpg', 'file: 57_245_167_106.jpg', 'similarity: 74.4868421053')
('target file: 137_45_404_229.jpg', 'file: 57_245_167_112.jpg', 'similarity: 73.6162280702')
('target file: 137_45_404_229.jpg', 'file: 57_245_167_134.jpg', 'similarity: 72.1184210526')
('target file: 137_45_404_229.jpg', 'file: 57_45_484_334.jpg', 'similarity: 47.2412280702')
('target file: 137_45_404_229.jpg', 'file: 57_45_496_334.jpg', 'similarity: 47.7478070175')
('target file: 137_45_404_229.jpg', 'file: 59_0_197_113.jpg', 'similarity: 81.8706140351')
('target file: 137_45_404_229.jpg', 'file: 70_268_146_110.jpg', 'similarity: 80.7171052632')
Traceback (most recent call last):
  File "grouping_image2.py", line 159, in <module>
    main()
  File "grouping_image2.py", line 107, in main
    probability = sum(dist) / len(dist)
ZeroDivisionError: integer division or modulo by zero

AKAZEの場合

('target file: 0_0_553_419.jpg', 'file: 0_0_599_419.jpg', 'similarity: 2.26003824092')
('target file: 0_0_553_419.jpg', 'file: 137_146_120_74.jpg', 'similarity: 206.339388145')
('target file: 0_0_553_419.jpg', 'file: 137_45_404_229.jpg', 'similarity: 82.6625239006')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 178_121_226_133.jpg', 'similarity: 147.791586998')
('target file: 0_0_553_419.jpg', 'file: 178_45_363_220.jpg', 'similarity: 89.1338432122')
('target file: 0_0_553_419.jpg', 'file: 178_45_363_229.jpg', 'similarity: 86.3718929254')
('target file: 0_0_553_419.jpg', 'file: 227_285_134_108.jpg', 'similarity: 158.248565966')
('target file: 0_0_553_419.jpg', 'file: 227_285_135_111.jpg', 'similarity: 157.455066922')
('target file: 0_0_553_419.jpg', 'file: 229_45_312_220.jpg', 'similarity: 95.9445506692')
('target file: 0_0_553_419.jpg', 'file: 229_49_156_125.jpg', 'similarity: 142.497131931')
('target file: 0_0_553_419.jpg', 'file: 238_49_147_113.jpg', 'similarity: 145.26959847')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 273_0_326_365.jpg', 'similarity: 78.7543021033')
('target file: 0_0_553_419.jpg', 'file: 273_174_119_91.jpg', 'similarity: 195.347036329')
('target file: 0_0_553_419.jpg', 'file: 273_8_227_127.jpg', 'similarity: 132.97418738')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 297_49_88_88.jpg', 'similarity: 175.680688337')
('target file: 0_0_553_419.jpg', 'file: 301_0_298_268.jpg', 'similarity: 95.2007648184')
('target file: 0_0_553_419.jpg', 'file: 301_0_298_365.jpg', 'similarity: 83.5803059273')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 31_0_100_119.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 31_0_258_143.jpg', 'similarity: 175.152963671')
('target file: 0_0_553_419.jpg', 'file: 31_0_258_191.jpg', 'similarity: 135.792543021')
('target file: 0_0_553_419.jpg', 'file: 31_0_529_414.jpg', 'similarity: 13.2705544933')
('target file: 0_0_553_419.jpg', 'file: 31_0_533_416.jpg', 'similarity: 12.9101338432')
('target file: 0_0_553_419.jpg', 'file: 329_45_212_220.jpg', 'similarity: 109.604206501')
('target file: 0_0_553_419.jpg', 'file: 336_45_205_220.jpg', 'similarity: 111.541108987')
('target file: 0_0_553_419.jpg', 'file: 379_259_161_122.jpg', 'similarity: 153.310707457')
('target file: 0_0_553_419.jpg', 'file: 39_112_521_302.jpg', 'similarity: 54.6357552581')
('target file: 0_0_553_419.jpg', 'file: 39_115_521_299.jpg', 'similarity: 55.6969407266')
('target file: 0_0_553_419.jpg', 'file: 405_174_126_94.jpg', 'similarity: 150.287762906')
('target file: 0_0_553_419.jpg', 'file: 408_303_156_113.jpg', 'similarity: 158.07456979')
('target file: 0_0_553_419.jpg', 'file: 408_305_156_111.jpg', 'similarity: 159.051625239')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 52_184_224_199.jpg', 'similarity: 111.787762906')
('target file: 0_0_553_419.jpg', 'file: 52_184_311_211.jpg', 'similarity: 99.9521988528')
('target file: 0_0_553_419.jpg', 'file: 52_230_194_153.jpg', 'similarity: 133.29541109')
('target file: 0_0_553_419.jpg', 'file: 52_230_224_153.jpg', 'similarity: 126.92543021')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 56_0_200_113.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 56_0_217_116.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 57_245_167_106.jpg', 'similarity: 165.387189293')
('target file: 0_0_553_419.jpg', 'file: 57_245_167_112.jpg', 'similarity: 165.023900574')
('target file: 0_0_553_419.jpg', 'file: 57_245_167_134.jpg', 'similarity: 157.085086042')
('target file: 0_0_553_419.jpg', 'file: 57_45_484_334.jpg', 'similarity: 44.0621414914')
('target file: 0_0_553_419.jpg', 'file: 57_45_496_334.jpg', 'similarity: 42.3288718929')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_553_419.jpg', 'file: 59_0_197_113.jpg', 'similarity: 100000')
('target file: 0_0_553_419.jpg', 'file: 70_268_146_110.jpg', 'similarity: 189.63001912')
('target file: 0_0_599_419.jpg', 'file: 0_0_553_419.jpg', 'similarity: 7.48818181818')
('target file: 0_0_599_419.jpg', 'file: 137_146_120_74.jpg', 'similarity: 206.030909091')
('target file: 0_0_599_419.jpg', 'file: 137_45_404_229.jpg', 'similarity: 85.08')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 178_121_226_133.jpg', 'similarity: 147.759090909')
('target file: 0_0_599_419.jpg', 'file: 178_45_363_220.jpg', 'similarity: 91.2090909091')
('target file: 0_0_599_419.jpg', 'file: 178_45_363_229.jpg', 'similarity: 88.5509090909')
('target file: 0_0_599_419.jpg', 'file: 227_285_134_108.jpg', 'similarity: 157.846363636')
('target file: 0_0_599_419.jpg', 'file: 227_285_135_111.jpg', 'similarity: 157.061818182')
('target file: 0_0_599_419.jpg', 'file: 229_45_312_220.jpg', 'similarity: 97.7390909091')
('target file: 0_0_599_419.jpg', 'file: 229_49_156_125.jpg', 'similarity: 142.54')
('target file: 0_0_599_419.jpg', 'file: 238_49_147_113.jpg', 'similarity: 145.282727273')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 273_0_326_365.jpg', 'similarity: 75.7681818182')
('target file: 0_0_599_419.jpg', 'file: 273_174_119_91.jpg', 'similarity: 195.445454545')
('target file: 0_0_599_419.jpg', 'file: 273_8_227_127.jpg', 'similarity: 133.553636364')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 297_49_88_88.jpg', 'similarity: 175.394545455')
('target file: 0_0_599_419.jpg', 'file: 301_0_298_268.jpg', 'similarity: 93.8972727273')
('target file: 0_0_599_419.jpg', 'file: 301_0_298_365.jpg', 'similarity: 80.3890909091')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 31_0_100_119.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 31_0_258_143.jpg', 'similarity: 175.000909091')
('target file: 0_0_599_419.jpg', 'file: 31_0_258_191.jpg', 'similarity: 136.562727273')
('target file: 0_0_599_419.jpg', 'file: 31_0_529_414.jpg', 'similarity: 16.6936363636')
('target file: 0_0_599_419.jpg', 'file: 31_0_533_416.jpg', 'similarity: 16.3009090909')
('target file: 0_0_599_419.jpg', 'file: 329_45_212_220.jpg', 'similarity: 110.949090909')
('target file: 0_0_599_419.jpg', 'file: 336_45_205_220.jpg', 'similarity: 112.898181818')
('target file: 0_0_599_419.jpg', 'file: 379_259_161_122.jpg', 'similarity: 154.425454545')
('target file: 0_0_599_419.jpg', 'file: 39_112_521_302.jpg', 'similarity: 57.2363636364')
('target file: 0_0_599_419.jpg', 'file: 39_115_521_299.jpg', 'similarity: 58.1736363636')
('target file: 0_0_599_419.jpg', 'file: 405_174_126_94.jpg', 'similarity: 151.476363636')
('target file: 0_0_599_419.jpg', 'file: 408_303_156_113.jpg', 'similarity: 158.858181818')
('target file: 0_0_599_419.jpg', 'file: 408_305_156_111.jpg', 'similarity: 159.827272727')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 52_184_224_199.jpg', 'similarity: 112.74')
('target file: 0_0_599_419.jpg', 'file: 52_184_311_211.jpg', 'similarity: 101.282727273')
('target file: 0_0_599_419.jpg', 'file: 52_230_194_153.jpg', 'similarity: 133.879090909')
('target file: 0_0_599_419.jpg', 'file: 52_230_224_153.jpg', 'similarity: 127.479090909')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 56_0_200_113.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 56_0_217_116.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 57_245_167_106.jpg', 'similarity: 165.609090909')
('target file: 0_0_599_419.jpg', 'file: 57_245_167_112.jpg', 'similarity: 165.373636364')
('target file: 0_0_599_419.jpg', 'file: 57_245_167_134.jpg', 'similarity: 157.214545455')
('target file: 0_0_599_419.jpg', 'file: 57_45_484_334.jpg', 'similarity: 48.1954545455')
('target file: 0_0_599_419.jpg', 'file: 57_45_496_334.jpg', 'similarity: 46.5245454545')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 0_0_599_419.jpg', 'file: 59_0_197_113.jpg', 'similarity: 100000')
('target file: 0_0_599_419.jpg', 'file: 70_268_146_110.jpg', 'similarity: 189.44')
('target file: 137_146_120_74.jpg', 'file: 0_0_553_419.jpg', 'similarity: 76.0')
('target file: 137_146_120_74.jpg', 'file: 0_0_599_419.jpg', 'similarity: 76.0')
('target file: 137_146_120_74.jpg', 'file: 137_45_404_229.jpg', 'similarity: 74.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 178_121_226_133.jpg', 'similarity: 4.0')
('target file: 137_146_120_74.jpg', 'file: 178_45_363_220.jpg', 'similarity: 2.0')
('target file: 137_146_120_74.jpg', 'file: 178_45_363_229.jpg', 'similarity: 2.0')
('target file: 137_146_120_74.jpg', 'file: 227_285_134_108.jpg', 'similarity: 99.0')
('target file: 137_146_120_74.jpg', 'file: 227_285_135_111.jpg', 'similarity: 99.0')
('target file: 137_146_120_74.jpg', 'file: 229_45_312_220.jpg', 'similarity: 113.0')
('target file: 137_146_120_74.jpg', 'file: 229_49_156_125.jpg', 'similarity: 117.0')
('target file: 137_146_120_74.jpg', 'file: 238_49_147_113.jpg', 'similarity: 141.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 273_0_326_365.jpg', 'similarity: 98.0')
('target file: 137_146_120_74.jpg', 'file: 273_174_119_91.jpg', 'similarity: 190.0')
('target file: 137_146_120_74.jpg', 'file: 273_8_227_127.jpg', 'similarity: 119.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 297_49_88_88.jpg', 'similarity: 144.0')
('target file: 137_146_120_74.jpg', 'file: 301_0_298_268.jpg', 'similarity: 113.0')
('target file: 137_146_120_74.jpg', 'file: 301_0_298_365.jpg', 'similarity: 113.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 31_0_100_119.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 31_0_258_143.jpg', 'similarity: 180.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_258_191.jpg', 'similarity: 134.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_529_414.jpg', 'similarity: 75.0')
('target file: 137_146_120_74.jpg', 'file: 31_0_533_416.jpg', 'similarity: 75.0')
('target file: 137_146_120_74.jpg', 'file: 329_45_212_220.jpg', 'similarity: 104.0')
('target file: 137_146_120_74.jpg', 'file: 336_45_205_220.jpg', 'similarity: 111.0')
('target file: 137_146_120_74.jpg', 'file: 379_259_161_122.jpg', 'similarity: 158.0')
('target file: 137_146_120_74.jpg', 'file: 39_112_521_302.jpg', 'similarity: 75.0')
('target file: 137_146_120_74.jpg', 'file: 39_115_521_299.jpg', 'similarity: 76.0')
('target file: 137_146_120_74.jpg', 'file: 405_174_126_94.jpg', 'similarity: 162.0')
('target file: 137_146_120_74.jpg', 'file: 408_303_156_113.jpg', 'similarity: 168.0')
('target file: 137_146_120_74.jpg', 'file: 408_305_156_111.jpg', 'similarity: 169.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 52_184_224_199.jpg', 'similarity: 134.0')
('target file: 137_146_120_74.jpg', 'file: 52_184_311_211.jpg', 'similarity: 98.0')
('target file: 137_146_120_74.jpg', 'file: 52_230_194_153.jpg', 'similarity: 149.0')
('target file: 137_146_120_74.jpg', 'file: 52_230_224_153.jpg', 'similarity: 149.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 56_0_200_113.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 56_0_217_116.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 57_245_167_106.jpg', 'similarity: 156.0')
('target file: 137_146_120_74.jpg', 'file: 57_245_167_112.jpg', 'similarity: 156.0')
('target file: 137_146_120_74.jpg', 'file: 57_245_167_134.jpg', 'similarity: 156.0')
('target file: 137_146_120_74.jpg', 'file: 57_45_484_334.jpg', 'similarity: 74.0')
('target file: 137_146_120_74.jpg', 'file: 57_45_496_334.jpg', 'similarity: 74.0')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_146_120_74.jpg', 'file: 59_0_197_113.jpg', 'similarity: 100000')
('target file: 137_146_120_74.jpg', 'file: 70_268_146_110.jpg', 'similarity: 191.0')
('target file: 137_45_404_229.jpg', 'file: 0_0_553_419.jpg', 'similarity: 13.8429003021')
('target file: 137_45_404_229.jpg', 'file: 0_0_599_419.jpg', 'similarity: 14.3716012085')
('target file: 137_45_404_229.jpg', 'file: 137_146_120_74.jpg', 'similarity: 204.468277946')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 161_184_89_58.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 178_121_226_133.jpg', 'similarity: 141.978851964')
('target file: 137_45_404_229.jpg', 'file: 178_45_363_220.jpg', 'similarity: 25.5438066465')
('target file: 137_45_404_229.jpg', 'file: 178_45_363_229.jpg', 'similarity: 19.8972809668')
('target file: 137_45_404_229.jpg', 'file: 227_285_134_108.jpg', 'similarity: 159.196374622')
('target file: 137_45_404_229.jpg', 'file: 227_285_135_111.jpg', 'similarity: 158.528700906')
('target file: 137_45_404_229.jpg', 'file: 229_45_312_220.jpg', 'similarity: 41.6314199396')
('target file: 137_45_404_229.jpg', 'file: 229_49_156_125.jpg', 'similarity: 134.432024169')
('target file: 137_45_404_229.jpg', 'file: 238_49_147_113.jpg', 'similarity: 139.870090634')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 238_96_63_66.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 273_0_326_365.jpg', 'similarity: 53.2719033233')
('target file: 137_45_404_229.jpg', 'file: 273_174_119_91.jpg', 'similarity: 198.299093656')
('target file: 137_45_404_229.jpg', 'file: 273_8_227_127.jpg', 'similarity: 129.939577039')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 286_208_84_54.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 286_208_85_55.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 289_210_81_52.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 297_49_88_88.jpg', 'similarity: 175.598187311')
('target file: 137_45_404_229.jpg', 'file: 301_0_298_268.jpg', 'similarity: 63.3867069486')
('target file: 137_45_404_229.jpg', 'file: 301_0_298_365.jpg', 'similarity: 60.3141993958')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 31_0_100_119.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 31_0_258_143.jpg', 'similarity: 175.425981873')
('target file: 137_45_404_229.jpg', 'file: 31_0_258_191.jpg', 'similarity: 140.504531722')
('target file: 137_45_404_229.jpg', 'file: 31_0_529_414.jpg', 'similarity: 12.9818731118')
('target file: 137_45_404_229.jpg', 'file: 31_0_533_416.jpg', 'similarity: 12.9093655589')
('target file: 137_45_404_229.jpg', 'file: 329_45_212_220.jpg', 'similarity: 71.9063444109')
('target file: 137_45_404_229.jpg', 'file: 336_45_205_220.jpg', 'similarity: 78.6616314199')
('target file: 137_45_404_229.jpg', 'file: 379_259_161_122.jpg', 'similarity: 159.262839879')
('target file: 137_45_404_229.jpg', 'file: 39_112_521_302.jpg', 'similarity: 81.9637462236')
('target file: 137_45_404_229.jpg', 'file: 39_115_521_299.jpg', 'similarity: 83.8851963746')
('target file: 137_45_404_229.jpg', 'file: 405_174_126_94.jpg', 'similarity: 155.719033233')
('target file: 137_45_404_229.jpg', 'file: 408_303_156_113.jpg', 'similarity: 164.120845921')
('target file: 137_45_404_229.jpg', 'file: 408_305_156_111.jpg', 'similarity: 165.49244713')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 525_366_74_53.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 52_184_224_199.jpg', 'similarity: 126.374622356')
('target file: 137_45_404_229.jpg', 'file: 52_184_311_211.jpg', 'similarity: 120.47734139')
('target file: 137_45_404_229.jpg', 'file: 52_230_194_153.jpg', 'similarity: 140.625377644')
('target file: 137_45_404_229.jpg', 'file: 52_230_224_153.jpg', 'similarity: 137.474320242')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 545_258_54_107.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 56_0_200_113.jpg', 'similarity: 100000')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 56_0_217_116.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 57_245_167_106.jpg', 'similarity: 168.785498489')
('target file: 137_45_404_229.jpg', 'file: 57_245_167_112.jpg', 'similarity: 168.054380665')
('target file: 137_45_404_229.jpg', 'file: 57_245_167_134.jpg', 'similarity: 159.80060423')
('target file: 137_45_404_229.jpg', 'file: 57_45_484_334.jpg', 'similarity: 5.14501510574')
('target file: 137_45_404_229.jpg', 'file: 57_45_496_334.jpg', 'similarity: 5.58006042296')
OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in batchDistance, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/stat.cpp, line 3934
('target file: 137_45_404_229.jpg', 'file: 59_0_197_113.jpg', 'similarity: 100000')
('target file: 137_45_404_229.jpg', 'file: 70_268_146_110.jpg', 'similarity: 189.975830816')
Traceback (most recent call last):
  File "grouping_image2.py", line 159, in <module>
    main()
  File "grouping_image2.py", line 107, in main
    probability = sum(dist) / len(dist)
ZeroDivisionError: integer division or modulo by zero

まとめ

  • 0に近いほど類似度が高いらしです。
  • ヒストグラムとくらべて結果が芳しくないです。
  • ちょいちょい画像読み込みにエラーが発生します。
  • こちらの検出は特徴点の距離の類似度らしいので画像サイズをリサイズしましたが駄目でした。

全ページリンク

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?