diff --git a/mdata/crop.py b/mdata/crop.py index 1cc3df3..a1e6476 100644 --- a/mdata/crop.py +++ b/mdata/crop.py @@ -20,7 +20,7 @@ def crop_Test(): print image # try: - # im = Image.open(image) + # im = Image.open(image) # w, h = im.size # if w < 300 or h < 300: # continue @@ -33,15 +33,16 @@ def crop_Test(): try: img = cv2.imread(image, cv2.CV_LOAD_IMAGE_UNCHANGED) h, w = img.shape[:2] + if w < 300 or h < 300: + continue left, upper = random.randint(0, w - 300), random.randint(0, h - 300) img_crop = img[upper:upper + 300, left:left + 300] - cv2.imwrite(os.path.join(base_dir, category + '_crop_cv', name),img_crop) + cv2.imwrite(os.path.join(base_dir, category + '_crop_cv', name), img_crop) except Exception as e: - print '[EXCPT]',e + print '[EXCPT]', e pass - if __name__ == '__main__': timer = Timer() -- libgit2 0.21.2