예제 #1
0
파일: db_hash.py 프로젝트: apacha/mscr
 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()
예제 #2
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
예제 #3
0
파일: db_dimstat.py 프로젝트: fpeder/mscr
#!/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)
예제 #4
0
파일: db_dimstat.py 프로젝트: apacha/mscr
#!/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)
예제 #5
0
파일: db_ext_rb.py 프로젝트: fpeder/mscr
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