我一直在尝试使用estimateRigidTransform
来确定视频中帧对之间的转换矩阵。我的问题是我输入代码的对几乎有一半返回无值。
我尝试将estimateRigidTransform
与整个帧一起使用,现在我要输入点了,结果稍好一些,但仍然不够好
############whole frames
frameBefore = cv2.imread("1.png")
frame = cv2.imread("result_00001.png")
transform = cv2.estimateRigidTransform(frameBefore,frameafter, False)
###########data points
frameBefore = cv2.imread("1.png")
prev_gray = cv2.cvtColor(frameBefore, cv2.COLOR_BGR2GRAY)
prev_pts = cv2.goodFeaturesToTrack(prev_gray,
maxCorners=200,
qualityLevel=0.01,
minDistance=30,
blockSize=3)
frame = cv2.imread("result_00001.png")
curr_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
curr_pts, status, err = cv2.calcOpticalFlowPyrLK(prev_gray, curr_gray, prev_pts, None)
assert prev_pts.shape == curr_pts.shape
idx = np.where(status==1)[0]
prev_pts = prev_pts[idx]
curr_pts = curr_pts[idx]
transform = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False)
对于43000帧,我得到18000无值。我在做什么错了?