From e1b781cbe30ea649add1c329244cca665ad55146 Mon Sep 17 00:00:00 2001 From: Marios Papachristou Date: Sun, 18 Feb 2018 14:42:59 +0200 Subject: [PATCH] parallel support for cropper script --- scripts/team_cropper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/team_cropper.py b/scripts/team_cropper.py index e163eb8..c755d25 100644 --- a/scripts/team_cropper.py +++ b/scripts/team_cropper.py @@ -1,3 +1,4 @@ +from multiprocessing import Pool import cv2 import numpy as np import glob @@ -11,7 +12,7 @@ img_list = glob.glob('*.jpg') -for img_file in img_list: +def mutate(img_file): img = cv2.imread(img_file) h, w = img.shape[:2] cx, cy = w / 2, h / 2 @@ -19,5 +20,11 @@ resized = cv2.resize(cropped, (0,0), fx = percent, fy = percent ) try: res = cv2.imwrite('{}{}'.format(img_dest, img_file), resized) + print('Success in {}'.format(img_file)) except: print('Error in {}'.format(img_file)) + + + +pool = Pool(5) +pool.map(mutate, img_list)