def __init__(self, path):
self.path = path
self.fps = 30
self.currName="unknown"
if os.path.isdir(self.path):
self.type=self.DIR
self.files = glob.glob(self.path+'/*.*')
self.currFile = 0
elif self.path.split('.')[-1].lower() in ['avi', 'mp4', 'mpeg', "mov"]:
self.cap = cv2.VideoCapture(opt.i)
self.frameIndex = 0
self.type=self.VID
if int((cv2.__version__).split('.')[0]) < 3:
self.fps = cap.get(cv2.cv.CV_CAP_PROP_FPS)
else:
self.fps = cap.get(cv2.CAP_PROP_FPS)
if self.fps<1:
self.fps=1
elif self.path.split('.')[-1].lower() in ['png','bmp','jpg','jpeg']:
self.type=self.IMG
self.fps=0
else:
print("Invalid file: "+self.path)
sys.exit(-1)
From:https://www.programcreek.com/python/example/77049/cv2.__version__