-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelocate_images.py
43 lines (36 loc) · 1.31 KB
/
relocate_images.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 24 16:00:10 2020
@author: maria
"""
import os
import sys
import numpy as np
import time
from PIL import Image, ImageDraw
import skimage
import cv2
# ROOT_DIR = 'F:/Fredy/Dataset/data/train/Carton'
# assert os.path.exists(ROOT_DIR), 'ROOT_DIR does not exist. Did you forget to read the instructions above? ;)'
CATEGORIES = [
{"supercategory": "recycle","id": 1,"name": "Alu"},
{"supercategory": "recycle","id": 2,"name": "Carton"},
{"supercategory": "recycle","id": 3,"name": "Bottle"},
{"supercategory": "recycle","id": 4,"name": "Nylon"},
]
############### TEST ######################
input_dir ='D:/Datasets/bigDataset4cl/train/bg'
image_paths = []
for filename in os.listdir(input_dir):
if os.path.splitext(filename)[1].lower() in ['.png', '.jpg', '.jpeg']:
image_paths.append(os.path.join(input_dir, filename))
i = 10000
for image_path in image_paths:
img=cv2.imread(image_path)
height, width = img.shape[:2]
if height!=800 or width!=800:
img = cv2.resize(img, (800,800))
#print (img)
# cv2.imwrite(path_folder +"/recy_images/"+str(category_id)+"_"+str(num_id)+".png", img)
cv2.imwrite("D:/Datasets/bigDataset4cl/train/bg/bb/"+ str(i)+".jpg", img)
i -= 1