Skip to content

VidGear

VidGear is a powerful python Video Processing library built with multiple APIs (a.k.a Gears) each with a unique set of trailblazing features. These APIs provides an easy-to-use, highly extensible, multi-threaded & asyncio wrapper around many underlying state-of-the-art libraries such as OpenCV, FFmpeg, ZeroMQ, picamera, starlette, pafy and python-mss.

Stabilizer Example

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

# To open live video stream on webcam at first index(i.e. 0) device
stream = CamGear(source=0).start()

# initiate stabilizer object with default parameters
stab = Stabilizer()

# loop over
while True:

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

    # check for frame if Nonetype
    if frame is None:
        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("Output 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.stop()

See also

  • Python
  • Dash - Dash is the original low-code framework for rapidly building data apps in Python.

Favorite site