From c66b6056fa38095f2620e6b68b7196844165faad Mon Sep 17 00:00:00 2001 From: Pranav Gupta Date: Mon, 9 Nov 2020 13:46:52 +0530 Subject: [PATCH] Update video_stabilization.py For OpenCV version greater than 3.0 assigned "estimateAffine2D" function for finding transformation matrix. --- VideoStabilization/video_stabilization.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/VideoStabilization/video_stabilization.py b/VideoStabilization/video_stabilization.py index 8eee1f47f..62340ae4e 100644 --- a/VideoStabilization/video_stabilization.py +++ b/VideoStabilization/video_stabilization.py @@ -91,7 +91,11 @@ def fixBorder(frame): curr_pts = curr_pts[idx] #Find transformation matrix - m = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False) #will only work with OpenCV-3 or less + if float((cv2.__version__)[0:3])<=3.0: + m = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False) #will only work with OpenCV-3 or less + + else: + m,_ = cv2.estimateAffine2D(prev_pts, curr_pts)# will work with OpenCV>3.0 # Extract traslation dx = m[0,2] @@ -165,4 +169,4 @@ def fixBorder(frame): cap.release() out.release() # Close windows -cv2.destroyAllWindows() \ No newline at end of file +cv2.destroyAllWindows()