Last active
December 13, 2020 11:15
-
-
Save 1chimaruGin/35e01a63a3dee4e6db9e7e92a12d6e0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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