Skip to content

Commit

Permalink
Update video_stabilization.py
Browse files Browse the repository at this point in the history
For OpenCV version greater than 3.0 assigned "estimateAffine2D" function for finding transformation matrix.
  • Loading branch information
pranav-gupta-7 authored and dustinfreeman committed Jul 31, 2024
1 parent 631fe2b commit 824feb1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions VideoStabilization/video_stabilization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -165,4 +169,4 @@ def fixBorder(frame):
cap.release()
out.release()
# Close windows
cv2.destroyAllWindows()
cv2.destroyAllWindows()

0 comments on commit 824feb1

Please sign in to comment.