[英]OpenCV Python - findHomography with RANSAC
I'm trying to run findHomography() using RANSAC, but I'm receiving a TypeError. 我正在尝试使用RANSAC运行findHomography() ,但我收到了一个TypeError。 My code works when I don't specify method at all, but even
method=0
causes a TypeError. 当我根本没有指定方法时,我的代码工作,但即使
method=0
也会导致TypeError。
Code 码
T, mask = cv2.findHomography(points_subset[i], points_subset[i+1], False, method=cv2.RANSAC)
Error 错误
Traceback (most recent call last):
File "stab.py", line 368, in <module>
stabilize_video(path, video_name)
File "stab.py", line 331, in stabilize_video
transforms, points, frame = calc_transformations(cap)
File "stab.py", line 113, in calc_transformations
T, mask = cv2.findHomography(points_subset[i], points_subset[i+1], False, method=cv2.RANSAC)
TypeError: Argument given by name ('method') and position (3)
Your error is occurring because you are attempting to specify the method
parameter twice; 您的错误正在发生,因为您尝试两次指定
method
参数; once as a positional argument, and again as a keyword argument. 一次作为位置参数,再次作为关键字参数。 The
False
argument can be removed to correct your error. 可以删除
False
参数以更正错误。 If you are trying to use RANSAC to find the homography, the correct call looks like this: 如果您尝试使用RANSAC查找单应性,则正确的调用如下所示:
T, mask = cv2.findHomography(points_subset[i], points_subset[i+1], method=cv2.RANSAC)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.