我寫了一個小腳本,可以通過SIFT descriptors method
查找全局圖片中的對象。但是我對同一張圖片中的多個檢測結果有疑問。檢測圖片上的多個對象
我有這樣的全球圖景:
我有這樣的模板:
我的腳本是這樣的:
import numpy as np
import cv2
#########################
# SIFT descriptors part #
#########################
img1 = cv2.imread('/Users/valentinjungbluth/Desktop/SIFT:SURF Algo/lampe.jpg',0)
img2 = cv2.imread('/Users/valentinjungbluth/Desktop/SIFT:SURF Algo/ville.jpg',0)
# Initiate SIFT detector
sift = cv2.xfeatures2d.SIFT_create()
print (img1.dtype)
print (img2.dtype)
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2,k=2)
good = []
for m,n in matches :
if m.distance < 0.2*n.distance :
good.append([m])
img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,None,flags=2)
cv2.imwrite('matches.jpg',img3)
,其結果是:
我的問題是:
我怎麼可以檢測到這種別人燈?因爲所有的燈都非常相似,所以我想要與照片中存在的所有燈相匹配。
非常感謝!
編輯與Micka的回答是:
沒有出現在0.2規模的距離,但如果我把0.75:
難以解釋,但也許你可以使用一種類似於我在這個鏈接和鏈接中使用的方法:http://stackoverflow.com/questions/34310914/recognize-recurring-images-into- a-large-one/34314697#34314697 但我想其他燈在你的情況下看起來不夠相似。通過透視圖像,您可以嘗試從圖像中移除最右邊的燈泡,並在修改的圖像上開始檢測。 – Micka
@Micka謝謝你的回答。在我看來,其他燈是非常相似的。所以我需要找到我如何向我的劇本展示其他燈以考慮問題。 – Deadpool
你可以在你的發佈模板中試試你的算法,併發布結果嗎? https://picload.org/image/ralgwllg/sift_smaller.png – Micka