Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (22 sloc) 669 Bytes
from threading import Thread
import cv2
class VideoGet:
Class that continuously gets frames from a VideoCapture object
with a dedicated thread.
def __init__(self, src=0): = cv2.VideoCapture(src)
(self.grabbed, self.frame) =
self.stopped = False
def start(self):
Thread(target=self.get, args=()).start()
return self
def get(self):
while not self.stopped:
if not self.grabbed:
(self.grabbed, self.frame) =
def stop(self):
self.stopped = True