解決AttributeError: module 'cv2.cv2' has no attribute 'estimateRigidTransform'


問題: AttributeError: module ‘cv2.cv2’ has no attribute ‘estimateRigidTransform’
分析: 出現該問題的原因可能是opencv的版本太高,不存在estimateRigidTransform方法,查看文檔後我們可以發現,該方法已被棄用,如下表述所示。

Deprecated:
Use cv::estimateAffine2D, cv::estimateAffinePartial2D instead. 
If you are using this fuction with images, extract points using
cv::calcOpticalFlowPyrLK and then use the estimation fuctions.

 根據表述我們可以使用estimateAffine2DestimateAffinePartial2D兩個方法代替使用,但是到底應該選擇哪一個方法進行替代,還需要看estimateRigidTransform方法的第三個參數fullAffine的取值。

  • fullAffine爲true表示的是六自由度的仿射變換,對應的方法爲estimateAffine2D
  • fullAffine爲false表示的是四自由度的仿射變換,對應的方法爲estimateAffinePartial2D

以上兩個方法的具體使用參考文檔:opencv

注意: 使用estimateAffine2DestimateAffinePartial2D方法需要兩個返回值,第一個返回值對應的是方法estimateRigidTransform的返回值,第二個返回值表示的是內點inliers,它的具體作用尚未得知。

發佈了49 篇原創文章 · 獲贊 11 · 訪問量 3039
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章