def expt_meshdtct_perf_spltASIFT(column_num = 8, row_num = 8, template_f = 'qrmarker.png'):
    split_num = column_num * row_num
    template_fn = myfsys.get_template_file_full_path_(template_f)
    detector, matcher = init_feature(emod.Features.SIFT)
    imgQ, s_kpQ, s_descQ = split_asift_detect(detector, template_fn, split_num=split_num)
    keyargs = {'prefix_shape': emod.PrefixShapes.PL.value, 'template_fn': template_fn}

    testset_full_path = myfsys.get_dir_full_path_testset('cgs', **keyargs)
    print(testset_full_path)
    testcase_fns = os.listdir(testset_full_path)
    testcase_fns.sort()
    print(testcase_fns)
    results = []
    for input_fns in testcase_fns:
        calculate_each_mesh(column_num, detector, input_fns, matcher, results, row_num, s_descQ, s_kpQ)
def expt_setting(**kwargs):
    import sys
    imgQ = cv2.imread(kwargs['fn1'], 0)
    imgT = cv2.imread(kwargs['fn2'], 0)
    detector, matcher = init_feature(kwargs['feature'])
    if imgQ is None:
        print('Failed to load fn1:', kwargs['fn1'])
        sys.exit(1)

    if imgT is None:
        print('Failed to load fn2:', kwargs['fn2'])
        sys.exit(1)

    if detector is None:
        print('unknown feature:', kwargs['feature'])
        sys.exit(1)

    temp_inf = slac.TmpInf(**kwargs['template_information'])
    return imgQ, imgT, detector, matcher, temp_inf
    # logging.getLogger('make_database').addHandler(timeRotationHandler)
    # logging.getLogger('make_database').addHandler(consoleHandler)
    logging.getLogger('make_database.split_affinesim').setLevel(level=logging.DEBUG)
    logging.getLogger('make_database.split_affinesim').addHandler(timeRotationHandler)
    logging.getLogger('make_database.split_affinesim').addHandler(consoleHandler)
    logging.getLogger('expt_modules').setLevel(level=logging.DEBUG)
    logging.getLogger('expt_modules').addHandler(timeRotationHandler)
    logging.getLogger('expt_modules').addHandler(consoleHandler)
    logging.getLogger('my_file_path_manager').setLevel(level=logging.DEBUG)
    logging.getLogger('my_file_path_manager').addHandler(timeRotationHandler)
    logging.getLogger('my_file_path_manager').addHandler(consoleHandler)

    logger.info(__doc__.format(os.path.basename(__file__)))
    a = myfsys.make_list_template_filename()
    a = emod.only(a, 'glass.png')
    detector, matcher = init_feature(emod.Features.SIFT.name)
    column_num = 8
    row_num = 8
    split_num = column_num * row_num
    expt_name = os.path.basename(expt_path)
    for template_fn in a:
        logger.info('Template:{}'.format(template_fn))
        # global s_kpQ, s_descQ, testset_full_path
        template_full_fn = myfsys.get_template_file_full_path_(template_fn)
        # imgQ, s_kpQ, s_descQ = split_asift_detect(detector, template_full_fn, split_num=split_num)
        keyargs = {'prefix_shape': emod.PrefixShapes.PL.value, 'template_fn': template_fn}
        testset_full_path = myfsys.get_dir_full_path_testset('cgs', **keyargs)
        testset_name = os.path.basename(testset_full_path)
        logger.debug('testset_name is {}'.format(testset_name))
        logger.info('Test Set:{}'.format(testset_name))
        output_dir = myfsys.setup_output_directory(expt_name, testset_name, 'npfiles')
    import sys, getopt
    opts, args = getopt.getopt(sys.argv[1:], '', ['feature='])
    opts = dict(opts)
    feature_name = opts.get('--feature', 'sift')
    try:
        fn1, fn2, column_num, row_num = args
    except:
        dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
        fn1 = myfsys.get_template_file_full_path_('qrmarker.png')
        fn2 = os.path.abspath(
            os.path.join(dir, 'data/inputs/cgs/pl_qrmarker/288_010-350.png'))
        column_num = 8
        row_num = 8

    detector, matcher = init_feature(feature_name)

    if detector is None:
        logger.info('unknown feature:{}'.format(feature_name))
        sys.exit(1)

    split_num = column_num * row_num
    img_q, splt_kp_q, splt_desc_q = split_asift_detect(detector, fn1,
                                                       split_num)

    logger.debug('using {}'.format(feature_name))

    img_t, kp_t, desc_t = emod.detect(detector, fn2)
    print('imgQ - %d features, imgT - %d features' %
          (saf.count_keypoints(splt_kp_q), len(kp_t)))
def get_detector_matchier(feature='sift'):
    detector, matcher = init_feature(feature)
    if detector is None:
        print('unknown feature:', feature)
    return detector, matcher