示例#1
0
def plot_keypoint_scales(hs, fnum=1):
    print('[dev] plot_keypoint_scales()')
    cx2_kpts = hs.feats.cx2_kpts
    cx2_nFeats = map(len, cx2_kpts)
    kpts = np.vstack(cx2_kpts)
    print('[dev] --- LaTeX --- ')
    _printopts = np.get_printoptions()
    np.set_printoptions(precision=3)
    print(pytex.latex_scalar(r'\# keypoints, ', len(kpts)))
    print(pytex.latex_mystats(r'\# keypoints per image', cx2_nFeats))
    acd = kpts[:, 2:5].T
    scales = np.sqrt(acd[0] * acd[2])
    scales = np.array(sorted(scales))
    print(pytex.latex_mystats(r'keypoint scale', scales))
    np.set_printoptions(**_printopts)
    print('[dev] ---/LaTeX --- ')
    #
    df2.figure(fnum=fnum, docla=True, title='sorted scales')
    df2.plot(scales)
    df2.adjust_subplots_safe()
    #ax = df2.gca()
    #ax.set_yscale('log')
    #ax.set_xscale('log')
    #
    fnum += 1
    df2.figure(fnum=fnum, docla=True, title='hist scales')
    df2.show_histogram(scales, bins=20)
    df2.adjust_subplots_safe()
    #ax = df2.gca()
    #ax.set_yscale('log')
    #ax.set_xscale('log')
    return fnum
示例#2
0
def plot_keypoint_scales(hs, fnum=1):
    print('[dev] plot_keypoint_scales()')
    cx2_kpts = hs.feats.cx2_kpts
    cx2_nFeats = map(len, cx2_kpts)
    kpts = np.vstack(cx2_kpts)
    print('[dev] --- LaTeX --- ')
    _printopts = np.get_printoptions()
    np.set_printoptions(precision=3)
    print(pytex.latex_scalar(r'\# keypoints, ', len(kpts)))
    print(pytex.latex_mystats(r'\# keypoints per image', cx2_nFeats))
    acd = kpts[:, 2:5].T
    scales = np.sqrt(acd[0] * acd[2])
    scales = np.array(sorted(scales))
    print(pytex.latex_mystats(r'keypoint scale', scales))
    np.set_printoptions(**_printopts)
    print('[dev] ---/LaTeX --- ')
    #
    df2.figure(fnum=fnum, docla=True, title='sorted scales')
    df2.plot(scales)
    df2.adjust_subplots_safe()
    #ax = df2.gca()
    #ax.set_yscale('log')
    #ax.set_xscale('log')
    #
    fnum += 1
    df2.figure(fnum=fnum, docla=True, title='hist scales')
    df2.show_histogram(scales, bins=20)
    df2.adjust_subplots_safe()
    #ax = df2.gca()
    #ax.set_yscale('log')
    #ax.set_xscale('log')
    return fnum
示例#3
0
def dbstats(hs):
    # Chip / Name / Image stats
    dbinfo_locals = db_info.db_info(hs)
    db_name = hs.get_db_name(True)
    #num_images = dbinfo_locals['num_images']
    num_chips = dbinfo_locals['num_chips']
    num_names = len(dbinfo_locals['valid_nxs'])
    num_singlenames = len(dbinfo_locals['singleton_nxs'])
    num_multinames = len(dbinfo_locals['multiton_nxs'])
    num_multichips = len(dbinfo_locals['multiton_cxs'])
    multiton_nx2_nchips = dbinfo_locals['multiton_nx2_nchips']

    #tex_nImage = latex_formater.latex_scalar(r'\# images', num_images)
    tex_nChip = latex_formater.latex_scalar(r'\# chips', num_chips)
    tex_nName = latex_formater.latex_scalar(r'\# names', num_names)
    tex_nSingleName = latex_formater.latex_scalar(r'\# singlenames',
                                                  num_singlenames)
    tex_nMultiName = latex_formater.latex_scalar(r'\# multinames',
                                                 num_multinames)
    tex_nMultiChip = latex_formater.latex_scalar(r'\# multichips',
                                                 num_multichips)
    tex_multi_stats = latex_formater.latex_mystats(r'\# multistats',
                                                   multiton_nx2_nchips)

    tex_kpts_scale_thresh = latex_formater.latex_multicolumn(
        'Scale Threshold (%d %d)' %
        (hs.prefs.feat_cfg.scale_min,
         hs.prefs.feat_cfg.scale_max)) + r'\\' + '\n'

    (tex_nKpts, tex_kpts_stats,
     tex_scale_stats) = db_info.get_keypoint_stats(hs)
    tex_title = latex_formater.latex_multicolumn(
        db_name + ' database statistics') + r'\\' + '\n'
    dedent = textwrap.dedent

    tabular_head = dedent(r'''
    \begin{tabular}{|l|l|}
    ''')
    tabular_tail = dedent(r'''
    \end{tabular}
    ''')
    hline = ''.join([r'\hline', '\n'])
    tabular_body_list = [
        tex_title,
        tex_nChip,
        tex_nName,
        tex_nSingleName,
        tex_nMultiName,
        tex_nMultiChip,
        tex_multi_stats,
        '',
        tex_kpts_scale_thresh,
        tex_nKpts,
        tex_kpts_stats,
        tex_scale_stats,
    ]
    tabular_body = hline.join(tabular_body_list)
    tabular = hline.join([tabular_head, tabular_body, tabular_tail])
    print('[dev stats]')
    print(tabular)
示例#4
0
def dbstats(hs):
    import db_info
    # Chip / Name / Image stats
    dbinfo_locals = db_info.db_info(hs)
    db_name = hs.get_db_name(True)
    #num_images = dbinfo_locals['num_images']
    num_chips = dbinfo_locals['num_chips']
    num_names = len(dbinfo_locals['valid_nxs'])
    num_singlenames = len(dbinfo_locals['singleton_nxs'])
    num_multinames = len(dbinfo_locals['multiton_nxs'])
    num_multichips = len(dbinfo_locals['multiton_cxs'])
    multiton_nx2_nchips = dbinfo_locals['multiton_nx2_nchips']

    #tex_nImage = pytex.latex_scalar(r'\# images', num_images)
    tex_nChip = pytex.latex_scalar(r'\# chips', num_chips)
    tex_nName = pytex.latex_scalar(r'\# names', num_names)
    tex_nSingleName = pytex.latex_scalar(r'\# singlenames', num_singlenames)
    tex_nMultiName  = pytex.latex_scalar(r'\# multinames', num_multinames)
    tex_nMultiChip  = pytex.latex_scalar(r'\# multichips', num_multichips)
    tex_multi_stats = pytex.latex_mystats(r'\# multistats', multiton_nx2_nchips)

    tex_kpts_scale_thresh = pytex.latex_multicolumn('Scale Threshold (%d %d)' %
                                                    (hs.prefs.feat_cfg.scale_min,
                                                     hs.prefs.feat_cfg.scale_max)) + r'\\' + '\n'

    (tex_nKpts, tex_kpts_stats, tex_scale_stats) = db_info.get_keypoint_stats(hs)
    tex_title = pytex.latex_multicolumn(db_name + ' database statistics') + r'\\' + '\n'
    dedent = textwrap.dedent

    tabular_head = dedent(r'''
    \begin{tabular}{|l|l|}
    ''')
    tabular_tail = dedent(r'''
    \end{tabular}
    ''')
    hline = ''.join([r'\hline', '\n'])
    tabular_body_list = [
        tex_title,
        tex_nChip,
        tex_nName,
        tex_nSingleName,
        tex_nMultiName,
        tex_nMultiChip,
        tex_multi_stats,
        '',
        tex_kpts_scale_thresh,
        tex_nKpts,
        tex_kpts_stats,
        tex_scale_stats,
    ]
    tabular_body = hline.join(tabular_body_list)
    tabular = hline.join([tabular_head, tabular_body, tabular_tail])
    print(tabular)
示例#5
0
def get_keypoint_stats(hs):
    from hscom import latex_formater as pytex
    hs.dbg_cx2_kpts()
    # Keypoint stats
    cx2_kpts = hs.feats.cx2_kpts
    # Check cx2_kpts
    cx2_nFeats = map(len, cx2_kpts)
    kpts = np.vstack(cx2_kpts)
    print('[dbinfo] --- LaTeX --- ')
    _printopts = np.get_printoptions()
    np.set_printoptions(precision=3)
    acd = kpts[:, 2:5].T
    scales = np.sqrt(acd[0] * acd[2])
    scales = np.array(sorted(scales))
    tex_scale_stats = pytex.latex_mystats(r'kpt scale', scales)
    tex_nKpts       = pytex.latex_scalar(r'\# kpts', len(kpts))
    tex_kpts_stats  = pytex.latex_mystats(r'\# kpts/chip', cx2_nFeats)
    print(tex_nKpts)
    print(tex_kpts_stats)
    print(tex_scale_stats)
    np.set_printoptions(**_printopts)
    print('[dbinfo] ---/LaTeX --- ')
    return (tex_nKpts, tex_kpts_stats, tex_scale_stats)