Page MenuHomec4science

scan_images.py
No OneTemporary

File Metadata

Created
Wed, Apr 30, 01:19

scan_images.py

from crop import *
from move import *
from imutils import paths
import argparse
import os
parser = argparse.ArgumentParser(description='Labeling tools')
parser.add_argument('--dir', help='Directory containing the input images')
parser.add_argument('--outdir', help='Directory containing the scanned images')
parser.add_argument('--batch_size', type=int, help='Number of images to be processed\
starting from 0')
args = vars(parser.parse_args())
imagePaths = sorted([os.path.join(args['dir'], f) for f in os.listdir(args['dir']) \
if os.path.isfile(os.path.join(args['dir'], f))])
#imagePaths = sorted(list(paths.list_images(args["dir"])))
imagedir = imagePaths[0].split(os.path.sep)
imagedir = os.sep.join(imagedir[:-1])
outputdir = args['outdir']
PV_dir = imagedir + '/PV'
PV_label_dir = imagedir + '/PV'+'/labels'
PVout_dir = outputdir + '/PV'
PVout_label_dir = outputdir + '/PV'+'/labels'
almostPVout_dir = outputdir + '/almostPV'
almostPVout_label_dir = outputdir + '/almostPV'+'/labels'
#Create the directories if they do not exist
if not os.path.exists(PV_dir):
os.makedirs(PV_dir)
if not os.path.exists(PV_label_dir):
os.makedirs(PV_label_dir)
if not os.path.exists(PVout_dir):
os.makedirs(PVout_dir)
if not os.path.exists(PVout_label_dir):
os.makedirs(PVout_label_dir)
if not os.path.exists(almostPVout_dir):
os.makedirs(almostPVout_dir)
if not os.path.exists(almostPVout_label_dir):
os.makedirs(almostPVout_label_dir)
for image in imagePaths[0:args["batch_size"]]:
# _ = input('Do you want to quit?')
# if _ == 'y':
# break
# else:
if(not image.endswith('.DS_Store')):
print(image)
#print(PVout_dir)
#print(PVout_label_dir)
#print(almostPVout_dir)
#print(almostPVout_label_dir)
m = Move(image,outputdir)
m.do_move()

Event Timeline