c++で画像の類似度計算がしたいと考えています。
pythonでの類似度計算の方法は調べると出てくるのですが、c++のものが見つからなくて困っています。
c++の類似度計算について詳しく書かれてあるホームページがあれば教えてほしいです。
下記が私がc++でしたいと思っているもののpythonのコードです。
もしpythonからc++にコードを書き換えることができる方がいましたら是非教えてほしいです。
python
1#!/usr/bin/env python 2# -*- coding: UTF-8 -*- 3 4"""feature detection.""" 5 6import cv2 7import os 8 9TARGET_FILE = '05.png' 10IMG_DIR = os.path.abspath(os.path.dirname(__file__)) + '/images/' 11IMG_SIZE = (200, 200) 12 13target_img_path = IMG_DIR + TARGET_FILE 14target_img = cv2.imread(target_img_path, cv2.IMREAD_GRAYSCALE) 15target_img = cv2.resize(target_img, IMG_SIZE) 16 17bf = cv2.BFMatcher(cv2.NORM_HAMMING) 18# detector = cv2.ORB_create() 19detector = cv2.AKAZE_create() 20(target_kp, target_des) = detector.detectAndCompute(target_img, None) 21 22print('TARGET_FILE: %s' % (TARGET_FILE)) 23 24files = os.listdir(IMG_DIR) 25for file in files: 26 if file == '.DS_Store' or file == TARGET_FILE: 27 continue 28 29 comparing_img_path = IMG_DIR + file 30 try: 31 comparing_img = cv2.imread(comparing_img_path, cv2.IMREAD_GRAYSCALE) 32 comparing_img = cv2.resize(comparing_img, IMG_SIZE) 33 (comparing_kp, comparing_des) = detector.detectAndCompute(comparing_img, None) 34 matches = bf.match(target_des, comparing_des) 35 dist = [m.distance for m in matches] 36 ret = sum(dist) / len(dist) 37 except cv2.error: 38 ret = 100000 39 40 print(file, ret)