PythonのOpenCVでインターネットのサイトから、
下記のような、特徴量マッチングのプログラム実行しました。
そしたら、
error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\core\src\batch_distance.cpp:303: error: (-215:Assertion failed) K == 1 && update == 0 && mask.empty() in function 'cv::batchDistance'
というエラーが発生しました。
matches・・・ のところでエラーが発生しているらしいのですが、
原因、対応について教えて頂けますでしょうか?
以上です。
Python
1img1 = cv2.imread("src/star_ptn.png") 2img2 = cv2.imread("src/star.png") 3detector1 = cv2.ORB_create() 4kps1,des1 = detector1.detectAndCompute(img1,None) 5kps2,des2 = detector1.detectAndCompute(img2,None) 6 7bf = cv2.BFMatcher(cv2.NORM_HAMMING,crossCheck = True) 8good = [] 9for m,n in matches: 10 if m.distance < 0.5 * n.distacne: 11 good.append([m]) 12 13img3 = cv2.drawMatchesKnn(img1,kps1,img2,kps2,good,None,flags = 2) 14cv2.imshow("kp1",img3) 15cv2.waitKey(0) 16cv2.destroyAllWindows() 17
上の画像が、star_ptn.png
下の画像が、star.png
です。
回答1件
あなたの回答
tips
プレビュー