【Python OPENCV】 Video Buffer and Threading

 import threading, time

import cv2

import queue


input_buffer = queue.Queue()


def processing():

    while True:

        print("get")

        frame=input_buffer.get()

        cv2.imshow("Video",frame)

        time.sleep(0.025)

        if cv2.waitKey(1) & 0xFF == ord('q'):

            break

    return


cap = cv2.VideoCapture('cats.mp4')

t = threading.Thread(target=processing)

t.start()


while True:

    ret, frame = cap.read()

    input_buffer.put(frame)

    time.sleep(0.025)

    print("put")

No comments:

This will make you a better decision maker | Annie Duke (author of “Thinking in Bets” and “Quit”, former pro poker…

Annie is a former professional poker player, decision-making expert, author, and special partner at First Round Capital.  ͏     ­͏     ­͏   ...

Contact Form

Name

Email *

Message *