def run(self): for cls in self._cls: path = os.path.join(self._src, cls) out = open(path + '.txt', 'w') for img in ImgFileIter(path, cls).run(): self._hfunc.update(img) out.write(self._hfunc.hexdigest() + '\n') out.close()
""" Usage: db_ext_rb.py <src> <dst> Options: -h --help """ import cv2 import os from docopt import docopt from mscr.util import ImgFileIter, Crop from mscr.blocks import RandBlockIter if __name__ == '__main__': args = docopt(__doc__) src = args['<src>'] dst = args['<dst>'] for folder in ['ms', 'txt']: fileiter = ImgFileIter(os.path.join(src, folder), crop=Crop()) blockiter = RandBlockIter(15) count = 0 for x in fileiter.run(): for b, _ in blockiter.run(x): outfile = os.path.join(dst, folder, str(count).zfill(8) + '.jpg') cv2.imwrite(outfile, b) count += 1
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Usage: db_dimstat.py <src> Options: -h --help """ import numpy as np from docopt import docopt from mscr.util import ImgFileIter if __name__ == '__main__': args = docopt(__doc__) src = args['<src>'] dim = [] fileIter = ImgFileIter(src) for x in fileIter.run(): tmp = x.shape[:2] dim = np.vstack((dim, tmp)) if len(dim) > 0 else tmp print dim.mean(axis=0), dim.std(axis=0)
Usage: db_ext_rb.py <src> <dst> Options: -h --help """ import cv2 import os from docopt import docopt from mscr.util import ImgFileIter, Crop from mscr.blocks import RandBlockIter if __name__ == '__main__': args = docopt(__doc__) src = args['<src>'] dst = args['<dst>'] for folder in ['ms', 'txt']: fileiter = ImgFileIter(os.path.join(src, folder), crop=Crop()) blockiter = RandBlockIter(15) count = 0 for x in fileiter.run(): for b, _ in blockiter.run(x): outfile = os.path.join(dst, folder, str(count).zfill(8) + '.jpg') cv2.imwrite(outfile, b) count += 1