Created
August 7, 2022 18:45
-
-
Save korjaa/f5226c2845ca5974161cd406151c22b0 to your computer and use it in GitHub Desktop.
OpenCV Player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import cv2 | |
def main(): | |
cap = cv2.VideoCapture("uhU.webm") | |
cap.set(cv2.CAP_PROP_POS_MSEC, 1000.0) | |
#cap.set(cv2.CAP_PROP_POS_FRAMES, 1000.0) | |
w, h = cap.get(cv2.CAP_PROP_FRAME_WIDTH), cap.get(cv2.CAP_PROP_FRAME_HEIGHT) | |
fps = cap.get(cv2.CAP_PROP_FPS) | |
stop = False | |
while not stop: | |
# Read frame | |
ret, frame = cap.read() | |
if ret == False: | |
raise RuntimeError("Failed to read frame") | |
frame_i = cap.get(cv2.CAP_PROP_POS_FRAMES) | |
# Resize | |
#breakpoint() | |
frame = cv2.resize(frame, tuple(int(d*0.33) for d in frame.shape[1:None:-1])) | |
# Display | |
cv2.imshow("Frame", frame) | |
if cv2.waitKey(25) == ord("q"): | |
stop = True | |
break | |
if not cap.isOpened() or stop: | |
break | |
cap.release() | |
cv2.destroyAllWindows() | |
if __name__ == "__main__": | |
logging.basicConfig(level=logging.DEBUG) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment