Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

vidgear python video streaming

# import required libraries
from vidgear.gears import VideoGear
import numpy as np
import cv2

# open any valid video stream with stabilization enabled(`stabilize = True`)
stream_stab = VideoGear(source = "test.mp4", stabilize = True).start()

# open same stream without stabilization for comparison
stream_org = VideoGear(source = "test.mp4").start()

# loop over
while True:

    # read stabilized frames
    frame_stab = stream_stab.read()

    # check for stabilized frame if Nonetype
    if frame_stab is None:
        break

    # read un-stabilized frame
    frame_org = stream_org.read()

    # concatenate both frames
    output_frame = np.concatenate((frame_org, frame_stab), axis=1)

    # put text over concatenated frame
    cv2.putText(
        output_frame, "Before", (10, output_frame.shape[0] - 10), cv2.FONT_HERSHEY_SIMPLEX,
        0.6, (0, 255, 0), 2,
    )
    cv2.putText(
        output_frame, "After", (output_frame.shape[1] // 2 + 10, output_frame.shape[0] - 10),
        cv2.FONT_HERSHEY_SIMPLEX,
        0.6, (0, 255, 0), 2,
    )

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

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

# close output window
cv2.destroyAllWindows()

# safely close both video streams
stream_org.stop()
stream_stab.stop()
Comment

vidgear python video streaming

# import required libraries
from vidgear.gears import VideoGear
import numpy as np
import cv2

# open any valid video stream with stabilization enabled(`stabilize = True`)
stream_stab = VideoGear(source = "test.mp4", stabilize = True).start()

# open same stream without stabilization for comparison
stream_org = VideoGear(source = "test.mp4").start()

# loop over
while True:

    # read stabilized frames
    frame_stab = stream_stab.read()

    # check for stabilized frame if Nonetype
    if frame_stab is None:
        break

    # read un-stabilized frame
    frame_org = stream_org.read()

    # concatenate both frames
    output_frame = np.concatenate((frame_org, frame_stab), axis=1)

    # put text over concatenated frame
    cv2.putText(
        output_frame, "Before", (10, output_frame.shape[0] - 10), cv2.FONT_HERSHEY_SIMPLEX,
        0.6, (0, 255, 0), 2,
    )
    cv2.putText(
        output_frame, "After", (output_frame.shape[1] // 2 + 10, output_frame.shape[0] - 10),
        cv2.FONT_HERSHEY_SIMPLEX,
        0.6, (0, 255, 0), 2,
    )

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

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

# close output window
cv2.destroyAllWindows()

# safely close both video streams
stream_org.stop()
stream_stab.stop()
Comment

PREVIOUS NEXT
Code Example
Python :: metasploit in python 
Python :: !value in python 
Python :: group by quintiles pandas 
Python :: python program to convert csv file into pdf 
Python :: pandas log percent change 
Python :: python laplace expansion 
Python :: # get documentation for module in terminal 
Python :: for _ in range python 
Python :: for i in range(1, 11): print(i, end="") 
Python :: Linear Search Python with enumerate 
Python :: pandas fill rows with entries occuring less often 
Python :: xgb model prediction changes if i save and load the model 
Python :: pyttsx3 ichanging voices 
Python :: looping emails using a database with python code 
Python :: Code Example of Comparing None with False type 
Python :: negative list slicing 
Python :: cubic interpolation python 
Python :: Combining functions 
Python :: registration of the path django urls in the core app or main app 
Python :: uncompress zip file in pythonanywhere 
Python :: linux show output 
Python :: Python NumPy atleast_3d Function Example when inputs are high dimesion 
Python :: get minimum value function with anealing in python 
Python :: Python NumPy asfortranarray Function Tuple to an array 
Python :: inverrt heatmap cmap 
Python :: python how to loop through array 
Python :: how to get defintiion of pysspark teable 
Python :: Create a list of multiples of 3 from 0 to 20. 
Python :: python code to scan paper table to excel 
Python :: penggunaan clear di python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =