我一直在尝试使用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个无值。我做错什么了?在
目前没有回答
相关问题 更多 >
编程相关推荐