Commit 2fe06b7fce991c955dd4809fec2072f809376918

Authored by Chunk
1 parent 05cbdcd9
Exists in master and in 1 other branch refactor

staged.

Showing 1 changed file with 5 additions and 4 deletions   Show diff stats
mdata/crop.py
... ... @@ -20,7 +20,7 @@ def crop_Test():
20 20 print image
21 21  
22 22 # try:
23   - # im = Image.open(image)
  23 + # im = Image.open(image)
24 24 # w, h = im.size
25 25 # if w < 300 or h < 300:
26 26 # continue
... ... @@ -33,15 +33,16 @@ def crop_Test():
33 33 try:
34 34 img = cv2.imread(image, cv2.CV_LOAD_IMAGE_UNCHANGED)
35 35 h, w = img.shape[:2]
  36 + if w < 300 or h < 300:
  37 + continue
36 38 left, upper = random.randint(0, w - 300), random.randint(0, h - 300)
37 39 img_crop = img[upper:upper + 300, left:left + 300]
38   - cv2.imwrite(os.path.join(base_dir, category + '_crop_cv', name),img_crop)
  40 + cv2.imwrite(os.path.join(base_dir, category + '_crop_cv', name), img_crop)
39 41 except Exception as e:
40   - print '[EXCPT]',e
  42 + print '[EXCPT]', e
41 43 pass
42 44  
43 45  
44   -
45 46 if __name__ == '__main__':
46 47 timer = Timer()
47 48  
... ...