Skip to content

Commit 824feb1

Browse files
pranav-gupta-7dustinfreeman
authored andcommitted
Update video_stabilization.py
For OpenCV version greater than 3.0 assigned "estimateAffine2D" function for finding transformation matrix.
1 parent 631fe2b commit 824feb1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

VideoStabilization/video_stabilization.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ def fixBorder(frame):
9191
curr_pts = curr_pts[idx]
9292

9393
#Find transformation matrix
94-
m = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False) #will only work with OpenCV-3 or less
94+
if float((cv2.__version__)[0:3])<=3.0:
95+
m = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False) #will only work with OpenCV-3 or less
96+
97+
else:
98+
m,_ = cv2.estimateAffine2D(prev_pts, curr_pts)# will work with OpenCV>3.0
9599

96100
# Extract traslation
97101
dx = m[0,2]
@@ -165,4 +169,4 @@ def fixBorder(frame):
165169
cap.release()
166170
out.release()
167171
# Close windows
168-
cv2.destroyAllWindows()
172+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)