Skip to content

Commit

Permalink
parallel support for cropper script
Browse files Browse the repository at this point in the history
  • Loading branch information
papachristoumarios committed Feb 18, 2018
1 parent 40bd3e0 commit e1b781c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/team_cropper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from multiprocessing import Pool
import cv2
import numpy as np
import glob
Expand All @@ -11,13 +12,19 @@
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
cropped = img[0 : h, cx - h / 2 : cx + h / 2]
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)

0 comments on commit e1b781c

Please sign in to comment.