Exemple #1
0
    parser.add_argument('--algorithm', default='grid', help='')
    parser.add_argument('--threads',
                        type=int,
                        default=multiprocessing.cpu_count())
    parser_add_bool_arg('--overwrite', default=False, help='')
    parser_add_bool_arg('--regular', default=True, help='')
    # parser.add_argument('--x-step-frac', type=float, default=None, help='image step fraction')
    # parser.add_argument('--y-step-frac', type=float, default=None, help='image step fraction')
    parser_add_bool_arg('--dry', default=False, help='')
    parser_add_bool_arg('--skip-missing', default=False, help='')
    parser_add_bool_arg('--ignore-errors', default=False, help='')
    parser.add_argument('fns', nargs='+', help='File names')
    args = parser.parse_args()

    log_dir = args.log
    _dt = logwt(log_dir, 'main.log', shift_d=True)
    """
    if args.x_step_frac is not None:
        if args.y_step_frac is None:
            y_step_frac = args.y_step_frac
        else:
            y_step_frac = args.x_step_frac
        config.set_step_frac(args.x_step_frac, y_step_frac)
    """

    depth = 1
    # CNC like precision?
    # Default to true for me
    regular = True

    input_image_file_names = list()
Exemple #2
0
def run(args):
    log_dir = args.log
    out_dir = 'out'
    _dt = logwt(log_dir, 'main.log', shift_d=True)

    fn = args.pto[0]

    auto_size = not (args.stp or args.stm or args.stw or args.sth)

    if args.threads < 1:
        raise Exception('Bad threads')
    print(('Using %d threads' % args.threads))

    print(('Loading %s' % args.pto))
    project = PTOProject.from_file_name(args.pto)
    print('Creating tiler')

    t = Tiler(project,
              out_dir,
              stw=mksize(args.stw),
              sth=mksize(args.sth),
              stp=None,
              clip_width=args.clip_width,
              clip_height=args.clip_height,
              log_dir=log_dir,
              is_full=args.full)
    t.threads = args.threads
    t.verbose = args.verbose
    t.st_dir = args.st_dir
    t.force = args.force
    t.merge = args.merge
    t.out_extension = args.out_ext
    t.ignore_errors = args.ignore_errors
    t.ignore_crop = args.ignore_crop
    t.st_limit = float(args.st_limit)

    # TODO: make this more proper?
    if args.nona_args:
        t.nona_args = args.nona_args.replace('"', '').split(' ')
    if args.enblend_args:
        t.enblend_args = args.enblend_args.replace('"', '').split(' ')

    if args.super_t_xstep:
        t.super_t_xstep = args.super_t_xstep
    if args.super_t_ystep:
        t.super_t_ystep = args.super_t_ystep

    t.enblend_lock = args.enblend_lock

    if args.single_dir and not os.path.exists(args.single_dir):
        os.mkdir(args.single_dir)

    t.calc_expected_tiles()
    t.calc_vars()

    print('Forcing tiler on all images')
    for fn in glob.glob(args.st_dir + "/*.jpg"):
        print("")
        print(("%s" % fn))
        im = Image.open(fn)
        width, height = im.size
        x0, y0 = coord(fn)
        #t.make_tile(im, x, y, row, col)
        st_bounds = [x0, x0 + width, y0, y0 + height]
        t.process_image(fn, im, st_bounds)
Exemple #3
0
def run(args):
    if args.threads < 1:
        raise Exception('Bad threads')
    print 'Using %d threads' % args.threads

    log_dir = args.log
    out_dir = 'out'
    _dt = logwt(log_dir, 'main.log', shift_d=True)

    fn = args.pto[0]

    auto_size = not (args.stp or args.stm or args.stw or args.sth)

    print 'Assuming input %s is pto project to be stitched' % args.pto
    project = PTOProject.from_file_name(args.pto)
    print 'Creating tiler'
    stp = None
    if args.stp:
        stp = mksize(args.stp)
    elif args.stm:
        stp = mem2pix(mksize(args.stm))
        print 'Memory %s => %s pix' % (args.stm, size2str(stp))
    elif auto_size:
        stm = config.super_tile_memory()
        if stm:
            stp = mem2pix(mksize(stm))
            # having issues creating very large
            if stp > 2**32 / 4:
                # 66 GB max useful as currently written
                print 'WARNING: reducing to maximum tile size'
                stp = 2**32 / 4

    t = Tiler(project,
              out_dir,
              stw=mksize(args.stw),
              sth=mksize(args.sth),
              stp=stp,
              clip_width=args.clip_width,
              clip_height=args.clip_height,
              log_dir=log_dir,
              is_full=args.full)
    t.threads = args.threads
    t.verbose = args.verbose
    t.st_dir = args.st_dir
    t.out_extension = args.out_ext
    t.ignore_errors = args.ignore_errors
    t.ignore_crop = args.ignore_crop
    t.st_limit = float(args.st_limit)

    # TODO: make this more proper?
    if args.nona_args:
        t.nona_args = args.nona_args.replace('"', '').split(' ')
    if args.enblend_args:
        t.enblend_args = args.enblend_args.replace('"', '').split(' ')

    if args.super_t_xstep:
        t.super_t_xstep = args.super_t_xstep
    if args.super_t_ystep:
        t.super_t_ystep = args.super_t_ystep
    if args.clip_width:
        t.clip_width = args.clip_width
    if args.clip_height:
        t.clip_height = args.clip_height
    # if they specified clip but not supertile step recalculate the step so they don't have to do it
    if args.clip_width or args.clip_height and not (args.super_t_xstep
                                                    or args.super_t_ystep):
        t.recalc_step()

    t.enblend_lock = args.enblend_lock

    if args.single_dir and not os.path.exists(args.single_dir):
        os.mkdir(args.single_dir)

    print('Running tiler')
    try:
        t.run()
    except KeyboardInterrupt:
        if t.stale_worker:
            print 'WARNING: forcing exit on stuck worker'
            time.sleep(0.5)
            os._exit(1)
        raise
    print('Tiler done!')

    print('Creating single image')
    single_fn = args.single_fn
    if single_fn is None:
        single_fn = 'out.jpg'
    if args.single_dir:
        single_fn = os.path.join(args.single_dir, single_fn)
    # sometimes I restitch with different supertile size
    # this results in excessive merge, although really I should just delete the old files
    if 1:
        print 'Single: using glob strategy on merge'
        s_fns = glob.glob(os.path.join(args.st_dir, 'st_*x_*y.jpg'))
    else:
        print 'Single: using output strategy'
        s_fns = t.st_fns

    single_fn_alt = None
    if args.single_fn is None:
        single_fn_alt = single_fn.replace('.jpg', '.tif')

    try:
        singlify(s_fns, single_fn, single_fn_alt)
    except HugeImage:
        print 'WARNING: single: exceeds max image size, skipped'
Exemple #4
0
def run(args):
    log_dir = args.log
    out_dir = 'out'
    _outlog, _errlog, outdate, _errdate = logwt(log_dir,
                                                'main.log',
                                                shift_d=True)
    worker_stdout = outdate.fd
    bench = Benchmark()

    try:
        print('Assuming input %s is pto project to be stitched' % args.pto)
        project = PTOProject.from_file_name(args.pto)
        print('Creating tiler')
        threads, stp = make_threads_stp(args)

        t = Tiler(pto=project,
                  out_dir=out_dir,
                  stw=mksize(args.stw),
                  sth=mksize(args.sth),
                  stp=stp,
                  clip_width=args.clip_width,
                  clip_height=args.clip_height,
                  log_dir=log_dir,
                  is_full=args.full,
                  dry=args.dry,
                  worker_stdout=worker_stdout)
        t.set_threads(threads)
        t.set_verbose(args.verbose)
        t.set_st_dir(args.st_dir)
        t.set_out_extension(args.out_ext)
        t.set_ignore_errors(args.ignore_errors)
        t.set_ignore_crop(args.ignore_crop)
        t.set_st_limit(float(args.st_limit))

        # TODO: make this more proper?
        if args.nona_args:
            t.nona_args = args.nona_args.replace('"', '').split(' ')
        if args.enblend_args:
            t.enblend_args = args.enblend_args.replace('"', '').split(' ')

        if args.super_t_xstep:
            t.set_super_t_xstep(args.super_t_xstep)
        if args.super_t_ystep:
            t.set_super_t_ystep(args.super_t_ystep)
        if args.clip_width:
            t.set_clip_width(args.clip_width)
        if args.clip_height:
            t.set_clip_height(args.clip_height)
        # if they specified clip but not supertile step recalculate the step so they don't have to do it
        if args.clip_width or args.clip_height and not (args.super_t_xstep
                                                        or args.super_t_ystep):
            t.recalc_step()

        t.set_enblend_lock(args.enblend_lock)

        if args.single_dir and not os.path.exists(args.single_dir):
            os.mkdir(args.single_dir)

        config.set_enblend_safer_mode(args.safer_mode)
        config.set_enblend_safest_mode(args.safest_mode)

        print('Running tiler')
        try:
            t.run()
        except KeyboardInterrupt:
            if t.stale_worker:
                print('WARNING: forcing exit on stuck worker')
                time.sleep(0.5)
                os._exit(1)
            raise
        print('Tiler done!')

        print('Creating single image')
        single_fn = args.single_fn
        if single_fn is None:
            single_fn = 'out.jpg'
        if args.single_dir:
            single_fn = os.path.join(args.single_dir, single_fn)
        # sometimes I restitch with different supertile size
        # this results in excessive merge, although really I should just delete the old files
        if 1:
            print('Single: using glob strategy on merge')
            s_fns = glob.glob(os.path.join(args.st_dir, 'st_*x_*y.jpg'))
        else:
            print('Single: using output strategy')
            s_fns = t.st_fns

        single_fn_alt = None
        if args.single_fn is None:
            single_fn_alt = single_fn.replace('.jpg', '.tif')

        try:
            singlify(s_fns, single_fn, single_fn_alt)
        except HugeImage:
            print('WARNING: single: exceeds max image size, skipped')
    finally:
        bench.stop()
        print('Completed in %s' % bench)