import os import cv2 rootdir = "directory path" for subdir, dirs, files in os.walk(rootdir): for file in files: frame = cv2.imread(os.path.join(subdir, file))