Skip to content

Instantly share code, notes, and snippets.

@1chimaruGin
Last active December 13, 2020 11:15
Show Gist options
  • Save 1chimaruGin/35e01a63a3dee4e6db9e7e92a12d6e0f to your computer and use it in GitHub Desktop.
Save 1chimaruGin/35e01a63a3dee4e6db9e7e92a12d6e0f to your computer and use it in GitHub Desktop.
import cv2
import time
import concurrent.futures
def display_frames(name):
cap = cv2.VideoCapture(name)
while True:
ret, frames = cap.read()
# process frames here
if not ret:
break
cv2.imshow(str(cap), frames)
cv2.waitKey(1)
cap.release()
return name
def main():
t1 = time.time()
names = [
'test1.avi',
'test2.avi',
'test3.avi',
'test4.avi']
with concurrent.futures.ProcessPoolExecutor(max_workers=4) as executor:
executor.map(display_frames, names)
cv2.destroyAllWindows()
print("Elapse timee: {} seconds".format(time.time()-t1))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment