def TEST_keypoint(imgBGR, img_fpath, kpts, desc, sel, fnum=1, figtitle=''):
    from plottool import draw_func2 as df2
    from plottool.viz_keypoints import _annotate_kpts, show_keypoints
    from plottool.viz_featrow import draw_feat_row
    import plottool
    import vtool.patch as ptool
    #----------------------#
    # --- Extract Data --- #
    #----------------------#
    kp = kpts[sel]
    # Extract patches, gradients, and orientations
    print('[rotinvar] 1) Extract patch, gradients, and orientations')
    wpatch, wkp = ptool.get_warped_patch(imgBGR, kp, gray=True)
    gradx, grady = ptool.patch_gradient(wpatch)
    gmag = ptool.patch_mag(gradx, grady)
    gori = ptool.patch_ori(gradx, grady)
    gori_weights = ptool.gaussian_weight_patch(gmag)

    # Get orientation histogram
    print('[rotinvar] 2) Get orientation histogram')
    hist, centers = ptool.get_orientation_histogram(gori, gori_weights)

    #----------------------#
    # --- Draw Results --- #
    #----------------------#
    f1_loc = TEST_figure1(wpatch,
                          gradx,
                          grady,
                          gmag,
                          gori,
                          hist,
                          centers,
                          fnum=fnum)
    df2.set_figtitle(figtitle + 'Dominant Orienation Extraction')

    TEST_figure2(imgBGR, kpts, desc, sel, fnum=fnum + 1)
    df2.set_figtitle(figtitle)
    #    TEST_figure2(imgBGR, kpts2, Desc2, sel, fnum=fnum + 2)
    #    df2.set_figtitle('Rotation Invariant')

    #df2.draw_keypoint_gradient_orientations(imgBGR, kp=kpts2[sel],
    #                                        sift=desc[sel], mode='vec',
    #                                        fnum=4)

    #df2.draw_vector_field(gradx, grady, pnum=(1, 1, 1), fnum=4)
    #df2.draw_kpts2(np.array([wkp]), sifts=desc[sel:sel + 1], ori=True)
    return locals()
Exemplo n.º 2
0
def TEST_keypoint(imgBGR, img_fpath, kpts, desc, sel):
    import pyhesaff
    import vtool.patch as ptool
    from plottool import draw_func2 as df2
    #----------------------#
    # --- Extract Data --- #
    #----------------------#
    kp = kpts[sel]
    # Extract patches, gradients, and orientations
    print('[rotinvar] 1) Extract patch, gradients, and orientations')
    wpatch, wkp = ptool.get_warped_patch(imgBGR, kp, gray=True)
    gradx, grady = ptool.patch_gradient(wpatch, gaussian_weighted=False)
    gmag = ptool.patch_mag(gradx, grady)
    gori = ptool.patch_ori(gradx, grady)

    # Get orientation histogram
    print('[rotinvar] 2) Get orientation histogram')
    gori_weights = ptool.gaussian_weight_patch(gmag)
    hist, centers = ptool.get_orientation_histogram(gori, gori_weights)

    # Get dominant direction in radians
    kpts2 = TEST_ptool_find_kpts_direction(imgBGR, kpts)
    kpts2, desc2 = pyhesaff.vtool_adapt_rotation(img_fpath, kpts)

    #----------------------#
    # --- Draw Results --- #
    #----------------------#
    f1_loc = TEST_figure1(wpatch, gradx, grady, gmag, gori, hist, centers)
    df2.set_figtitle('Dominant Orienation Extraction')

    TEST_figure2(imgBGR, kpts, desc, sel, fnum=2)
    df2.set_figtitle('Gravity Vector')
    TEST_figure2(imgBGR, kpts2, desc2, sel, fnum=3)
    df2.set_figtitle('Rotation Invariant')

    #df2.draw_keypoint_gradient_orientations(imgBGR, kp=kpts2[sel],
    #                                        sift=desc[sel], mode='vec',
    #                                        fnum=4)

    #df2.draw_vector_field(gradx, grady, pnum=(1, 1, 1), fnum=4)
    #df2.draw_kpts2(np.array([wkp]), sifts=desc[sel:sel + 1], ori=True)
    return locals()
Exemplo n.º 3
0
def TEST_keypoint(imgBGR, img_fpath, kpts, desc, sel):
    import pyhesaff
    #----------------------#
    # --- Extract Data --- #
    #----------------------#
    kp = kpts[sel]
    # Extract patches, gradients, and orientations
    print('[rotinvar] 1) Extract patch, gradients, and orientations')
    wpatch, wkp  = ptool.get_warped_patch(imgBGR, kp, gray=True)
    gradx, grady = ptool.patch_gradient(wpatch, gaussian_weighted=False)
    gmag         = ptool.patch_mag(gradx, grady)
    gori         = ptool.patch_ori(gradx, grady)

    # Get orientation histogram
    print('[rotinvar] 2) Get orientation histogram')
    gori_weights = ptool.gaussian_weight_patch(gmag)
    hist, centers = ptool.get_orientation_histogram(gori, gori_weights)

    # Get dominant direction in radians
    kpts2 = TEST_ptool_find_kpts_direction(imgBGR, kpts)
    kpts2, desc2 = pyhesaff.vtool_adapt_rotation(img_fpath, kpts)

    #----------------------#
    # --- Draw Results --- #
    #----------------------#
    f1_loc = TEST_figure1(wpatch, gradx, grady, gmag, gori, hist, centers)
    df2.set_figtitle('Dominant Orienation Extraction')

    TEST_figure2(imgBGR, kpts, desc, sel, fnum=2)
    df2.set_figtitle('Gravity Vector')
    TEST_figure2(imgBGR, kpts2, desc2, sel, fnum=3)
    df2.set_figtitle('Rotation Invariant')

    #df2.draw_keypoint_gradient_orientations(imgBGR, kp=kpts2[sel],
    #                                        sift=desc[sel], mode='vec',
    #                                        fnum=4)

    #df2.draw_vector_field(gradx, grady, pnum=(1, 1, 1), fnum=4)
    #df2.draw_kpts2(np.array([wkp]), sifts=desc[sel:sel + 1], ori=True)
    return locals()
def TEST_keypoint(imgBGR, img_fpath, kpts, desc, sel, fnum=1, figtitle=''):
    from plottool import draw_func2 as df2
    from plottool.viz_keypoints import _annotate_kpts, show_keypoints
    from plottool.viz_featrow import draw_feat_row
    import plottool
    import vtool.patch as ptool
    #----------------------#
    # --- Extract Data --- #
    #----------------------#
    kp = kpts[sel]
    # Extract patches, gradients, and orientations
    print('[rotinvar] 1) Extract patch, gradients, and orientations')
    wpatch, wkp  = ptool.get_warped_patch(imgBGR, kp, gray=True)
    gradx, grady = ptool.patch_gradient(wpatch)
    gmag         = ptool.patch_mag(gradx, grady)
    gori         = ptool.patch_ori(gradx, grady)
    gori_weights = ptool.gaussian_weight_patch(gmag)

    # Get orientation histogram
    print('[rotinvar] 2) Get orientation histogram')
    hist, centers = ptool.get_orientation_histogram(gori, gori_weights)

    #----------------------#
    # --- Draw Results --- #
    #----------------------#
    f1_loc = TEST_figure1(wpatch, gradx, grady, gmag, gori, hist, centers, fnum=fnum)
    df2.set_figtitle(figtitle + 'Dominant Orienation Extraction')

    TEST_figure2(imgBGR, kpts, desc, sel, fnum=fnum + 1)
    df2.set_figtitle(figtitle)
#    TEST_figure2(imgBGR, kpts2, Desc2, sel, fnum=fnum + 2)
#    df2.set_figtitle('Rotation Invariant')

    #df2.draw_keypoint_gradient_orientations(imgBGR, kp=kpts2[sel],
    #                                        sift=desc[sel], mode='vec',
    #                                        fnum=4)

    #df2.draw_vector_field(gradx, grady, pnum=(1, 1, 1), fnum=4)
    #df2.draw_kpts2(np.array([wkp]), sifts=desc[sel:sel + 1], ori=True)
    return locals()