如何在OpenCV 3.0或更高版本中使用estimateRigidTransform?是否有其他替代方法?

11
我想使用OpenCV中的estimateRigidTransform函数,但它会抛出一个错误。

AttributeError Traceback (most recent call last) in 30 31 #查找变换矩阵 ---> 32 m = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False) #只能与OpenCV-3或更低版本一起使用 33 34 # 提取平移

AttributeError: 模块 'cv2.cv2' 没有属性 'estimateRigidTransform'

我使用的是OpenCV 4.0.0版本。
1个回答

12
estimateRigidTransform文档 所示,该函数已被弃用:

已弃用: 改用cv::estimateAffine2D、cv::estimateAffinePartial2D代替。如果您正在使用此函数处理图像,请使用cv::calcOpticalFlowPyrLK提取点,然后使用估计函数。

cv::estimateAffine2D 对噪声更加鲁棒,但计算成本更高,而cv::estimateAffinePartial2D 则相对较便宜。它们类似于将estimateRigidTransformfullAffine参数分别设置为true或者false

1
new_t = cv2.estimateRigidTransform(img, anchor, fullAffine=False) 这段代码在 anchor 大小为 (1280, 1920) 且 img 大小为 (1280, 1920) 时无法正常工作。我将 estimageRigidTransofrm 替换为 estimateAffice2d(img, anchor),但出现了以下错误:cv2.error: OpenCV(4.1.2) /io/opencv/modules/calib3d/src/ptsetreg.cpp:831: error: (-215:Assertion failed) count >= 0 && to.checkVector(2) == count in function 'estimateAffine2D'。请问如何进行更正? - fisakhan
如果我正确理解了你的信息,你是将整个(1280 x 1920)图像输入到两个函数中吗?- 你只需要给它们来自源图像和目标图像的匹配点对。 - Diarmaid O Cualain
@DiarmaidOCualain,您能否解释一下“来自源图像和目标图像的匹配点对”是什么意思? - Enos jeba
1
我指的是匹配点对:源(src)图像中的(x,y)点和目标(dst)图像中的(x,y)点构成一对。 - Diarmaid O Cualain

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接