私は通常のORBアプリケーションを持っています。私のホモグラフィの正確さを知る方法がないので、私はマッチの正確さを知ろうとしています。これは正しい方法です。私のコードでは、外れ値を取り除いた後のマッチはraw_matchesにあるようです。比率テストをした後、良いマッチを得て、その正確さを見いだしたい。一致の登録の精度を得る
コード:(エラーが両方の画像内に存在するという仮定の下で)ホモグラフィの品質
detector = cv2.ORB_create(FEATURESCOUNT)
kp1, desc1 = detector.detectAndCompute(img1, None)
kp2, desc2 = detector.detectAndCompute(img2, None)
flann_params= dict(algorithm = FLANN_INDEX_LSH, table_number = 6, key_size = 12, bmulti_probe_level = 1)
matcher = cv2.FlannBasedMatcher(flann_params, {})
raw_matches = matcher.knnMatch(desc1, trainDescriptors = desc2, k = 2)
ratio = 0.9
mkp1, mkp2 = [], []
for m in raw_matches:
if len(m) == 2 and m[0].distance < m[1].distance * ratio:
m = m[0]
mkp1.append(kp1[m.queryIdx])
mkp2.append(kp2[m.trainIdx])
print max(distmax)
distall = sum(i for i in distmax)
print distall/len(distmax)
p1 = np.float32([kp.pt for kp in mkp1])
p2 = np.float32([kp.pt for kp in mkp2])
comps =[]
res = []
kp_pairs = zip(mkp1, mkp2)
if len(p1) >= 4:
H, status = cv2.findHomography(p1, p2, cv2.RANSAC, 5.0)
comps = getComponents(H)
print (comps)
print('%d/%d inliers/matched' % (np.sum(status), len(status)))
else:
H, status = None, None
print('%d matches found, not enough for homography estimation' % len(p1))