Skip to content

Instantly share code, notes, and snippets.

@sikang99
Last active March 3, 2025 13:45
Show Gist options
  • Save sikang99/431011fdd4aa07c6b126fc6a790105d1 to your computer and use it in GitHub Desktop.
Save sikang99/431011fdd4aa07c6b126fc6a790105d1 to your computer and use it in GitHub Desktop.
Video Stabilization

Video Stabilization

  • AIS : AI Image Stabilization
  • DIS : Digital Image Stabilization
  • EIS : Electronic Image Stabilization
  • HIS : Hybrid Image Stabilization = EIS + OIS
  • OIS : Optical Image Stabilization

Articles

Information

Videos

Papers

Open Source

@sikang99
Copy link
Author

# import required libraries
from vidgear.gears.stabilizer import Stabilizer
import cv2

# Open suitable video stream, such as webcam on first index(i.e. 0)
stream = cv2.VideoCapture("UnstabilizedTest10sec.mp4")

# initiate stabilizer object with default parameters
#stab = Stabilizer()
stab = Stabilizer(smoothing_radius=30, crop_n_zoom=True, border_size=5, logging=True)

# loop over
while True:

    # read frames from stream
    (grabbed, frame) = stream.read()

    # check for frame if not grabbed
    if not grabbed:
        break

    # send current frame to stabilizer for processing
    stabilized_frame = stab.stabilize(frame)

    # wait for stabilizer which still be initializing
    if stabilized_frame is None:
        continue

    # {do something with the stabilized frame here}

    # Show output window
    cv2.imshow("Stabilized Frame", stabilized_frame)

    # check for 'q' key if pressed
    key = cv2.waitKey(1) & 0xFF
    if key == ord("q"):
        break

# close output window
cv2.destroyAllWindows()

# clear stabilizer resources
stab.clean()

# safely close video stream
stream.release()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment