def get_file_path_template_input(testcase, test_sample, template):
    if not template is None:
        templates = myfsys.get_dir_full_path_(DirNames.TEMPLATES.value)
        return os.path.abspath(os.path.join(templates, template))
    if not test_sample is None:
        inputs = myfsys.get_dir_full_path_(DirNames.INPUTS.value)
        return os.path.abspath(os.path.join(inputs, testcase, test_sample))
def setup_expt_directory():
    outputs_dir = myfsys.get_dir_full_path_(DirNames.OUTPUTS.value)
    expt_name, ext = os.path.splitext(os.path.basename(__file__))
    expt_path = os.path.join(outputs_dir, expt_name)
    if os.path.exists(expt_path):
        return expt_path
    os.mkdir(expt_path)
    return expt_path
Example #3
0
            if template_fn == tmp_fn:
                yield {'prefix_shape': prefix, 'template_fn': tmp_fn}

def get_testcase_fn(testset_fullpath, sampling_num=0):
    testcase_fns = os.listdir(testset_full_path)
    testcase_fns.sort()
    if not sampling_num == 0:
        for i, test_case_fn in enumerate(testcase_fns):
            if i % sampling_num == 0:
                yield test_case_fn
    else:
        for i, test_case_fn in enumerate(testcase_fns):
            yield test_case_fn

if __name__ == "__main__":
    expt_path = os.path.join(myfsys.get_dir_full_path_('outputs'), "expt_mesh_interpolation")
    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)

    prefixes = (prfx.PL.value,
                prfx.MLTF.value,
                prfx.CRV.value)
    tmp_fn_list = ('qrmarker.png',
                   'nabe.png')
    #tmp_fn_list = emod.only(tmp_fn_list, 'glass.png')
    tmp_name = tuple(os.path.splitext(fn)[0] for fn in tmp_fn_list)
    testset_set = list(itertools.product(prefixes, tmp_fn_list)) #2set product
    sampling_num = 57
        for vs in nodes_position)
    nodes_dispersion = np.array(list(i if i is not None else np.nan
                                     for i in nodes_dispersion),
                                dtype=np.float32)
    return nodes_dispersion


def mold2Longitude_Latitude(filename):
    filename = filename.replace('_', '-')
    tmp = filename.split('-')
    LoLa = '{0}, {1}'.format(tmp[0], tmp[1])
    return LoLa


if __name__ == "__main__":
    expt_path = os.path.join(myfsys.get_dir_full_path_('outputs'),
                             "expt_split_affinesim_combinable_interporation")
    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)

    prefixes = (prfx.PL.value, prfx.MLTF.value, prfx.CRV.value)
    tmp_fn_list = ('qrmarker.png', 'nabe.png')
    #tmp_fn_list = emod.only(tmp_fn_list, 'glass.png')
    tmp_name = tuple(os.path.splitext(fn)[0] for fn in tmp_fn_list)
    testset_set = list(itertools.product(prefixes, tmp_fn_list))  #2set product
    sampling_num = 57
    gene = get_testset(testset_set)
    dfs = pd.DataFrame()
def get_img(fn):
    img = cv2.imread(fn, 0)
    if img is None:
        raise ValueError('Failed to load fn1:', fn)
    return img


def get_detector_matchier(feature='sift'):
    detector, matcher = init_feature(feature)
    if detector is None:
        print('unknown feature:', feature)
    return detector, matcher


if __name__ == "__main__":
    template_dir_path = myfsys.get_dir_full_path_(
        myfsys.DirNames.TEMPLATES.value)
    dump_dir = 'dump_features'
    a = myfsys.make_list_template_filename()
    feature = 'sift'

    def mkdir_dump_dir(*args, **kwargs):
        path = os.path.join(kwargs.get('base_dir', ''), *args)
        if os.path.exists(path):
            print(path + 'is exist')
            return path, True
        os.makedirs(path, exist_ok=True)
        print('make dir_path_full')
        return path, False

    for template_fn in a:
        fn, ext = os.path.splitext(template_fn)
Example #6
0
    vis = draw_matches_for_meshes(imgQ, imgT, Hs=Hs)
    cv2.imwrite(myfsys.getf_output(expt_names, 'meshes.png'), vis)

    visS = draw_matches_for_meshes(imgQ, imgT, Hs=Hs_stable)
    cv2.imwrite(myfsys.getf_output(expt_names, 'meshes_stable.png'), visS)

    viw = explore_match_for_meshes('affine find_obj', imgQ, imgT, kp_pairs_long_stable, Hs=Hs_stable)
    cv2.imwrite(myfsys.getf_output(expt_names, 'meshes_and_keypoints_stable.png'), viw)

    return vis, visS, viw


if __name__ == '__main__':
    expt_path = myfsys.setup_expt_directory(os.path.basename(__file__))
    logging.basicConfig(filename=os.path.join(expt_path, 'log.txt'), level=logging.DEBUG)
    a = os.listdir(myfsys.get_dir_full_path_(myfsys.DirNames.TEMPLATES.value))
    a.pop(a.index('mesh_label.png'))
    detector, matcher = init_feature(emod.Features.SIFT.name)
    for template in a:
        template_name, ext = template.split('.')
        print(template_name)
        fn = myfsys.get_template_file_full_path_(template)
        imgQ, kpQ, descQ = detect(detector, fn, splt_num=64, simu_type='asift')
        #実験は平面のみ
        subj_dir = emod.PrefixShapes.PL.value + template_name
        testsets = os.listdir(myfsys.get_inputs_dir_full_path(subj_dir))
        for testcase in testsets:
            print(myfsys.getf_input(subj_dir, testcase))


        # fnQ = ('qrmarker.png', 'menko.png', 'nabe.png', 'nabe.png', 'nabe.png')