예제 #1
0
def test_adaptive_scale_main():
    r"""
    CommandLine:
        python -m pyhesaff.tests.test_adaptive_scale --test-test_adaptive_scale_main
        python -m pyhesaff.tests.test_adaptive_scale --test-test_adaptive_scale_main --show

    Example:
        >>> # DISABLE_DOCTEST
        >>> from pyhesaff.tests.test_adaptive_scale import *  # NOQA
        >>> # build test data
        >>> # execute function
        >>> result = test_adaptive_scale_main()
        >>> # verify results
        >>> print(result)
    """
    from plottool import draw_func2 as df2
    from plottool.viz_keypoints import show_keypoints
    import vtool.ellipse as vtellipse
    print('__main__ = test_adaptive_scale.py')
    np.set_printoptions(threshold=5000, linewidth=5000, precision=3)

    #adaptive_locals = test_adaptive_scale()
    # They seem to work
    # TODO: take the gui functions out of this test
    test_adaptive_scale()

    if ut.show_was_requested():
        exec(df2.present())
예제 #2
0
def test_adaptive_scale_main():
    r"""
    CommandLine:
        python -m pyhesaff.tests.test_adaptive_scale --test-test_adaptive_scale_main
        python -m pyhesaff.tests.test_adaptive_scale --test-test_adaptive_scale_main --show

    Example:
        >>> # DISABLE_DOCTEST
        >>> from pyhesaff.tests.test_adaptive_scale import *  # NOQA
        >>> # build test data
        >>> # execute function
        >>> result = test_adaptive_scale_main()
        >>> # verify results
        >>> print(result)
    """
    from plottool import draw_func2 as df2
    from plottool.viz_keypoints import show_keypoints
    import vtool.ellipse as vtellipse
    print('__main__ = test_adaptive_scale.py')
    np.set_printoptions(threshold=5000, linewidth=5000, precision=3)

    #adaptive_locals = test_adaptive_scale()
    # They seem to work
    # TODO: take the gui functions out of this test
    test_adaptive_scale()

    if ut.show_was_requested():
        exec(df2.present())
예제 #3
0
파일: smk1.py 프로젝트: whaozl/ibeis
    centroids = invindex.words
    num_pca_dims = 3  # 3
    whiten = False
    kwd = dict(
        num_pca_dims=num_pca_dims,
        whiten=whiten,
    )

    #clustertool.rrr()
    def makeplot_(fnum, prefix, data, labels='centroids', centroids=centroids):
        return clustertool.plot_centroids(data,
                                          centroids,
                                          labels=labels,
                                          fnum=fnum,
                                          prefix=prefix + '\n',
                                          **kwd)

    makeplot_(1, 'centroid vecs', centroids)
    #makeplot_(2, 'database vecs', invindex.idx2_dvec)
    #makeplot_(3, 'query vecs', qfx2_vec)
    #makeplot_(4, 'database vecs', invindex.idx2_dvec)
    #makeplot_(5, 'query vecs', qfx2_vec)
    #################


if __name__ == '__main__':
    main_locals = main()
    main_execstr = utool.execstr_dict(main_locals, 'main_locals')
    exec(main_execstr)
    exec(df2.present())
예제 #4
0
파일: smk1.py 프로젝트: Erotemic/ibeis
    from ibeis.dev import dbinfo
    print(ibs.get_infostr())
    dbinfo.get_dbinfo(ibs, verbose=True)
    ################
    print('Inverted Index Stats: vectors per word')
    print(utool.stats_str(map(len, invindex.wx2_idxs.values())))
    ################
    #qfx2_vec     = annots_df['vecs'][1]
    centroids    = invindex.words
    num_pca_dims = 3  # 3
    whiten       = False
    kwd = dict(num_pca_dims=num_pca_dims,
               whiten=whiten,)
    #clustertool.rrr()
    def makeplot_(fnum, prefix, data, labels='centroids', centroids=centroids):
        return clustertool.plot_centroids(data, centroids, labels=labels,
                                          fnum=fnum, prefix=prefix + '\n', **kwd)
    makeplot_(1, 'centroid vecs', centroids)
    #makeplot_(2, 'database vecs', invindex.idx2_dvec)
    #makeplot_(3, 'query vecs', qfx2_vec)
    #makeplot_(4, 'database vecs', invindex.idx2_dvec)
    #makeplot_(5, 'query vecs', qfx2_vec)
    #################


if __name__ == '__main__':
    main_locals = main()
    main_execstr = utool.execstr_dict(main_locals, 'main_locals')
    exec(main_execstr)
    exec(df2.present())
def test_cpp_rotinvar_main():
    r"""
    CommandLine:
        python -m pyhesaff.tests.test_cpp_rotation_invariance --test-test_cpp_rotinvar_main
        python -m pyhesaff.tests.test_cpp_rotation_invariance --test-test_cpp_rotinvar_main --show


    Example:
        >>> # DISABLE_DOCTEST
        >>> from pyhesaff.tests.test_cpp_rotation_invariance import *  # NOQA
        >>> # build test data
        >>> # execute function
        >>> result = test_cpp_rotinvar_main()
        >>> # verify results
        >>> print(result)
    """
    # TODO; take visualization out of this test by default
    from pyhesaff.tests import pyhestest
    import pyhesaff
    # Read data
    print('[rotinvar] loading test data')
    img_fpath = pyhestest.get_test_image()
    [kpts1], [desc1] = pyhesaff.detect_feats_list([img_fpath],
                                                  rotation_invariance=False)
    [kpts2], [desc2] = pyhesaff.detect_feats_list([img_fpath],
                                                  rotation_invariance=True)
    np.set_printoptions(threshold=5000,
                        linewidth=5000,
                        precision=8,
                        suppress=True)

    print('kpts1.shape = %r' % (kpts1.shape, ))
    print('kpts2.shape = %r' % (kpts2.shape, ))

    print('desc1.shape = %r' % (desc1.shape, ))
    print('desc2.shape = %r' % (desc2.shape, ))

    print('\n----\n'.join([
        str(k1) + '\n' + str(k2) for k1, k2 in zip(kpts1[0:10], kpts2[0:10])
    ]))

    n = 4
    #clip = min(len(kpts1), n)

    # HACK FIXME
    fxs = np.array(pyhestest.spaced_elements2(kpts2, n).tolist()[0:3])

    print('fxs=%r' % fxs)
    kpts1 = kpts1[fxs]
    kpts2 = kpts2[fxs]
    desc1 = desc1[fxs]
    desc2 = desc2[fxs]

    print('\n----\n'.join(
        [str(k1) + '\n' + str(k2) for k1, k2 in zip(kpts1, kpts2)]))

    imgBGR = pyhestest.cv2.imread(img_fpath)
    sel = min(len(kpts1) - 1, 3)

    TEST_keypoint(imgBGR,
                  img_fpath,
                  kpts1,
                  desc1,
                  sel,
                  fnum=1,
                  figtitle='Downward Rotation')
    TEST_keypoint(imgBGR,
                  img_fpath,
                  kpts2,
                  desc2,
                  sel,
                  fnum=9001,
                  figtitle='Adapted Rotation')

    #locals_ = TEST_keypoint(imgBGR, img_fpath, kpts1, desc1, sel)
    #exec(utool.execstr_dict(locals_, 'locals_'))
    #exec(utool.execstr_dict(f1_loc, 'f1_loc'))  # NOQA

    #pinteract.interact_keypoints(imgBGR, kpts2, desc, arrow=True, rect=True)
    if ut.show_was_requested():
        exec(df2.present())
예제 #6
0
        print(lbl)
        fnum = df2.next_fnum()
        df2.figure(fnum=fnum, doclf=True)
        #viz_matches.show_matches(ibs, qres, aid2, fnum=fnum, in_image=True)
        #viz.show_qres(ibs, qres, fnum=fnum, top_aids=top_aids, ensure=False)
        interact.ishow_qres(ibs, qres, fnum=fnum, top_aids=top_aids, ensure=False)
        df2.set_figtitle(lbl)
        df2.adjust_subplots_safe(top=.8)

    fnum = df2.next_fnum()

    qaid2_svtups = comp_locals_['qaid2_svtups']
    qaid2_chipmatch_FILT = comp_locals_['qaid2_chipmatch_FILT']
    aid1 = qaid = comp_locals_['qaid']
    aid2_svtup  = qaid2_svtups[aid1]
    chipmatch_FILT = qaid2_chipmatch_FILT[aid1]
    viz.show_sver(ibs, aid1, aid2, chipmatch_FILT, aid2_svtup, fnum=fnum)
    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # For windows
    import ibeis
    main_locals = ibeis.main(defaultdb='testdb1', gui=False)
    ibs = main_locals['ibs']
    test_locals = utool.run_test(TEST_QUERY_COMP, ibs)
    if '--noshow' not in sys.argv:
        df2.present()
    execstr = utool.execstr_dict(test_locals, 'test_locals')
    exec(execstr)
def test_cpp_rotinvar_main():
    r"""
    CommandLine:
        python -m pyhesaff.tests.test_cpp_rotation_invariance --test-test_cpp_rotinvar_main
        python -m pyhesaff.tests.test_cpp_rotation_invariance --test-test_cpp_rotinvar_main --show


    Example:
        >>> # DISABLE_DOCTEST
        >>> from pyhesaff.tests.test_cpp_rotation_invariance import *  # NOQA
        >>> # build test data
        >>> # execute function
        >>> result = test_cpp_rotinvar_main()
        >>> # verify results
        >>> print(result)
    """
    # TODO; take visualization out of this test by default
    from pyhesaff.tests import pyhestest
    import pyhesaff
    # Read data
    print('[rotinvar] loading test data')
    img_fpath = pyhestest.get_test_image()
    [kpts1], [desc1] = pyhesaff.detect_feats_list([img_fpath], rotation_invariance=False)
    [kpts2], [desc2] = pyhesaff.detect_feats_list([img_fpath], rotation_invariance=True)
    np.set_printoptions(threshold=5000, linewidth=5000, precision=8, suppress=True)

    print('kpts1.shape = %r' % (kpts1.shape,))
    print('kpts2.shape = %r' % (kpts2.shape,))

    print('desc1.shape = %r' % (desc1.shape,))
    print('desc2.shape = %r' % (desc2.shape,))

    print('\n----\n'.join([str(k1) + '\n' + str(k2) for k1, k2 in zip(kpts1[0:10], kpts2[0:10])]))

    n = 4
    #clip = min(len(kpts1), n)

    # HACK FIXME
    fxs = np.array(pyhestest.spaced_elements2(kpts2, n).tolist()[0:3])

    print('fxs=%r' % fxs)
    kpts1 = kpts1[fxs]
    kpts2 = kpts2[fxs]
    desc1 = desc1[fxs]
    desc2 = desc2[fxs]

    print('\n----\n'.join([str(k1) + '\n' + str(k2) for k1, k2 in zip(kpts1, kpts2)]))

    imgBGR = pyhestest.cv2.imread(img_fpath)
    sel = min(len(kpts1) - 1, 3)

    TEST_keypoint(imgBGR, img_fpath, kpts1, desc1, sel, fnum=1, figtitle='Downward Rotation')
    TEST_keypoint(imgBGR, img_fpath, kpts2, desc2, sel, fnum=9001, figtitle='Adapted Rotation')

    #locals_ = TEST_keypoint(imgBGR, img_fpath, kpts1, desc1, sel)
    #exec(utool.execstr_dict(locals_, 'locals_'))
    #exec(utool.execstr_dict(f1_loc, 'f1_loc'))  # NOQA

    #pinteract.interact_keypoints(imgBGR, kpts2, desc, arrow=True, rect=True)
    if ut.show_was_requested():
        exec(df2.present())