From 824feb11d8f2d473e9a604729b11dcb01830c212 Mon Sep 17 00:00:00 2001 From: Pranav Gupta Date: Mon, 9 Nov 2020 13:46:52 +0530 Subject: [PATCH 1/2] 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() From 218cf76705205c72b3879491748eb7dfb706d909 Mon Sep 17 00:00:00 2001 From: Dustin Freeman Date: Wed, 31 Jul 2024 12:02:03 -0400 Subject: [PATCH 2/2] more coherent version testing --- VideoStabilization/video_stabilization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VideoStabilization/video_stabilization.py b/VideoStabilization/video_stabilization.py index 62340ae4e..692442074 100644 --- a/VideoStabilization/video_stabilization.py +++ b/VideoStabilization/video_stabilization.py @@ -91,7 +91,7 @@ def fixBorder(frame): curr_pts = curr_pts[idx] #Find transformation matrix - if float((cv2.__version__)[0:3])<=3.0: + if int((cv2.__version__).split('.')[0]) <= 3: m = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False) #will only work with OpenCV-3 or less else: