簡潔に言えば、「形状コンテキスト」のマッチングによって異なる道路のマークを比較したいと思います。2つの異なる形状の距離を計算することによる形状コンテキストの誤差
私の最初の質問の下にあなたが見ることができます:
Matching shapes of road marking from OpenDataは私が私の最初の問題を解決したが、今では新しいエラーが表示されます。私はB(抽出されたターンの矢印)で(元ターン矢印) を比較すると
は、問題がない
import cv2
import numpy as np
# read data
datapath = "/Users/output/test/";
a = cv2.imread(datapath+"template_orig.png");
b = cv2.imread(datapath+"template.png");
imgray_a = cv2.cvtColor(a,cv2.COLOR_BGR2GRAY)
ret_a,thresh_a = cv2.threshold(imgray_a,127,255,0)
imgray_b = cv2.cvtColor(b,cv2.COLOR_BGR2GRAY)
ret_b,thresh_b = cv2.threshold(imgray_b,127,255,0)
# find contours
_, ca, _ = cv2.findContours(thresh_a, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
_, cb, _ = cv2.findContours(thresh_b, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
print(np.shape(ca[0]), np.shape(cb[0]))
# generate distance --> Hausdorff OR ShapeContext
hd = cv2.createHausdorffDistanceExtractor()
sd = cv2.createShapeContextDistanceExtractor()
d1 = hd.computeDistance(ca[0],cb[0])
d2 = sd.computeDistance(ca[0],cb[0])
print(d1, " ", d2)
私はを比較が、:ここに私のコードですc(「形状マッチング」アルゴリズムをテストするためのその他のもの)
OpenCV Error: Assertion failed (type == CV_64FC2) in gemmImpl, file /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/matmul.cpp, line 1218
Traceback (most recent call last): File "/test_shape.py", line 74, in d2 = sd.computeDistance(ca[0],cb[0])
cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/matmul.cpp:1218: error: (-215) type == CV_64FC2 in function gemmImpl
エラーのみ「ハウスドルフ」の距離を生成する機能を有する「形状コンテキスト」の生成の距離の関数で発生していない