1
我開始學習Python(2.7),並嘗試使用計算機視覺(使用模塊openCv「cv2」)。我使用OpenCV版本2.4。屬性計算不適用於來自openCV for python的ORB
我目前正試圖運行一個來自this tutorial的示例,它位於ORB(面向軌道的快速和旋轉的簡短軌道),這將幫助我跟蹤視頻上的對象。
的問題是,我得到了一個錯誤,當我運行示例(我只是改變了圖像加載,以使這個例子可重複):
import cv2
from matplotlib import pyplot as plt
#create image
img = np.zeros((512,512,3), np.uint8)
cv2.line(img,(0,0),(511,511),(255,0,0),5)
# Initiate STAR detector
orb = cv2.ORB()
# find the keypoints with ORB
kp = orb.detect(img,None)
# compute the descriptors with ORB
kp, des = orb.compute(img, kp)
# draw only keypoints location,not size and orientation
img2 = cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)
plt.imshow(img2),plt.show()
然後我有以下消息的錯誤:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-f294d6a53bcc> in <module>()
12 print(kp)
13 # compute the descriptors with ORB
---> 14 kp, des = orb.compute(img, kp)
15
16 # draw only keypoints location,not size and orientation
AttributeError: 'cv2.ORB' object has no attribute 'compute'
我不明白爲什麼這個屬性不存在這個對象。我的腳本會壓制它嗎?
任何幫助是非常歡迎。
非常感謝。 Edwin