Created
August 16, 2020 18:26
-
-
Save Justin-Heer/dce576c09c9d8fbfa5236b986f3de31e to your computer and use it in GitHub Desktop.
outputs a video of a training example
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 os | |
import cv2 | |
import glob | |
# Set image dir of your choice | |
imageDir = r'dataset\nervous_frames\_0\\' | |
# Read in files and sort | |
filenames = os.listdir(imageDir) | |
filenames.sort(key= lambda x: int(x[:-4])) | |
img_array=[] | |
# Initiate loop over filenames | |
for filename in filenames: | |
img = cv2.imread(imageDir+filename) | |
height, width, layers = img.shape | |
size = (width,height) | |
# Store every image array you want to write | |
img_array.append(img) | |
# initialize writer and write video | |
out = cv2.VideoWriter('out.avi',cv2.VideoWriter_fourcc(*'DIVX'), 15, size) | |
for i in range(len(img_array)): | |
out.write(img_array[i]) | |
out.release() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment