Esempio n. 1
0
def test_shape(ori=0, skew=0, xscale=1, yscale=1, pnum=(1, 1, 1), fnum=1):
    df2.figure(fnum=fnum, pnum=pnum)
    kpts, sifts = test_keypoint(ori=ori,
                                skew=skew,
                                xscale=xscale,
                                yscale=yscale)
    ax = df2.gca()
    square_axis(ax)
    mpl_keypoint.draw_keypoints(ax,
                                kpts,
                                sifts=sifts,
                                ell_color=df2.ORANGE,
                                ori=True,
                                rect_color=df2.DARK_RED,
                                ori_color=df2.DEEP_PINK,
                                eig_color=df2.PINK,
                                rect=True,
                                eig=True,
                                bin_color=df2.RED,
                                arm1_color=df2.YELLOW,
                                arm2_color=df2.BLACK)

    kptsstr = '\n'.join(ktool.get_kpts_strs(kpts))
    #print(kptsstr)
    df2.upperleft_text(kptsstr)

    title = 'xyscale=(%.1f, %.1f),\n skew=%.1f, ori=%.2ftau' % (
        xscale, yscale, skew, ori / TAU)
    df2.set_title(title)
    df2.dark_background()
    return kpts, sifts
Esempio n. 2
0
def annotate_matches(ibs, qres, aid2,
                     offset1=(0, 0),
                     offset2=(0, 0),
                     xywh2=(0, 0, 0, 0),
                     xywh1=(0, 0, 0, 0),
                     **kwargs):
    # TODO Use this function when you clean show_matches
    in_image    = kwargs.get('in_image', False)
    show_query  = kwargs.get('show_query', True)
    draw_border = kwargs.get('draw_border', True)
    draw_lbl    = kwargs.get('draw_lbl', True)

    printDBG('[viz] annotate_matches()')
    aid1 = qres.qaid
    truth = ibs.get_match_truth(aid1, aid2)
    truth_color = vh.get_truth_color(truth)
    # Build title
    title = vh.get_query_text(ibs, qres, aid2, truth, **kwargs)
    # Build xlbl
    ax = df2.gca()
    ph.set_plotdat(ax, 'viztype', 'matches')
    ph.set_plotdat(ax, 'qaid', aid1)
    ph.set_plotdat(ax, 'aid1', aid1)
    ph.set_plotdat(ax, 'aid2', aid2)
    if draw_lbl:
        name1, name2 = ibs.get_annot_names([aid1, aid2])
        lbl1 = repr(name1)  + ' : ' + 'q' + vh.get_aidstrs(aid1)
        lbl2 = repr(name2)  + ' : ' +  vh.get_aidstrs(aid2)
    else:
        lbl1, lbl2 = None, None
    if vh.NO_LBL_OVERRIDE:
        title = ''
    df2.set_title(title, ax)
    # Plot annotations over images
    if in_image:
        bbox1, bbox2 = vh.get_bboxes(ibs, [aid1, aid2], [offset1, offset2])
        theta1, theta2 = ibs.get_annot_thetas([aid1, aid2])
        # HACK!
        if show_query:
            df2.draw_bbox(bbox1, bbox_color=df2.ORANGE, lbl=lbl1, theta=theta1)
        bbox_color2 = truth_color if draw_border else df2.ORANGE
        df2.draw_bbox(bbox2, bbox_color=bbox_color2, lbl=lbl2, theta=theta2)
    else:
        xy, w, h = df2._axis_xy_width_height(ax)
        bbox2 = (xy[0], xy[1], w, h)
        theta2 = 0
        if draw_border:
            df2.draw_border(ax, truth_color, 4, offset=offset2)
        if draw_lbl:
            # Custom user lbl for chips 1 and 2
            (x1, y1, w1, h1) = xywh1
            (x2, y2, w2, h2) = xywh2
            df2.absolute_lbl(x1 + w1, y1, lbl1)
            df2.absolute_lbl(x2 + w2, y2, lbl2)
        # No matches draw a red box
    if aid2 not in qres.aid2_fm or len(qres.aid2_fm[aid2]) == 0:
        if draw_border:
            df2.draw_boxedX(bbox2, theta=theta2)
Esempio n. 3
0
def show_keypoint_gradient_orientations(ibs, aid, fx, fnum=None, pnum=None, config2_=None):
    # Draw the gradient vectors of a patch overlaying the keypoint
    if fnum is None:
        fnum = df2.next_fnum()
    rchip = ibs.get_annot_chips(aid, config2_=config2_)
    kp    = ibs.get_annot_kpts(aid, config2_=config2_)[fx]
    sift  = ibs.get_annot_vecs(aid, config2_=config2_)[fx]
    df2.draw_keypoint_gradient_orientations(rchip, kp, sift=sift,
                                            mode='vec', fnum=fnum, pnum=pnum)
    df2.set_title('Gradient orientation\n %s, fx=%d' % (get_aidstrs(aid), fx))
Esempio n. 4
0
    def test_shape(ori=0, skew=0, xscale=1, yscale=1, pnum=(1, 1, 1), fnum=1):
        df2.figure(fnum=fnum, pnum=pnum)
        kpts, sifts = test_keypoint(ori=ori, skew=skew, xscale=xscale, yscale=yscale)
        ax = df2.gca()
        square_axis(ax)
        mpl_keypoint.draw_keypoints(ax, kpts, sifts=sifts, ell_color=df2.ORANGE, ori=True,
                                    rect_color=df2.DARK_RED,
                                    ori_color=df2.DEEP_PINK, eig_color=df2.PINK,
                                    rect=True, eig=True, bin_color=df2.RED,
                                    arm1_color=df2.YELLOW, arm2_color=df2.BLACK)

        kptsstr = '\n'.join(ktool.get_kpts_strs(kpts))
        #print(kptsstr)
        df2.upperleft_text(kptsstr)

        title = 'xyscale=(%.1f, %.1f),\n skew=%.1f, ori=%.2ftau' % (xscale, yscale, skew, ori / TAU)
        df2.set_title(title)
        df2.dark_background()
        return kpts, sifts
Esempio n. 5
0
def show_keypoint_gradient_orientations(ibs,
                                        aid,
                                        fx,
                                        fnum=None,
                                        pnum=None,
                                        config2_=None):
    # Draw the gradient vectors of a patch overlaying the keypoint
    if fnum is None:
        fnum = df2.next_fnum()
    rchip = ibs.get_annot_chips(aid, config2_=config2_)
    kp = ibs.get_annot_kpts(aid, config2_=config2_)[fx]
    sift = ibs.get_annot_vecs(aid, config2_=config2_)[fx]
    df2.draw_keypoint_gradient_orientations(rchip,
                                            kp,
                                            sift=sift,
                                            mode='vec',
                                            fnum=fnum,
                                            pnum=pnum)
    df2.set_title('Gradient orientation\n %s, fx=%d' % (get_aidstrs(aid), fx))
def TEST_figure1(wpatch, gradx, grady, gmag, gori, hist, centers):
    from plottool import draw_func2 as df2
    import plottool
    import vtool.patch as ptool
    print('[rotinvar] 4) Draw histogram with interpolation annotations')
    fnum = 1
    gorimag = plottool.color_orimag(gori, gmag, True)
    nRow, nCol = (2, 7)

    df2.figure(fnum=1, pnum=(nRow, 1, nRow), doclf=True, docla=True)
    plottool.draw_hist_subbin_maxima(hist, centers)
    df2.set_xlabel('grad orientation (radians)')
    df2.set_ylabel('grad magnitude')
    df2.set_title('dominant orientations')

    print('[rotinvar] 5) Show patch, gradients, magintude, and orientation')
    df2.imshow(wpatch, pnum=(nRow, nCol, 1), fnum=fnum, title='patch')
    df2.draw_vector_field(gradx,
                          grady,
                          pnum=(nRow, nCol, 2),
                          fnum=fnum,
                          title='gori (vec)')
    df2.imshow(gorimag, pnum=(nRow, nCol, 3), fnum=fnum, title='gori (col)')
    df2.imshow(np.abs(gradx), pnum=(nRow, nCol, 4), fnum=fnum, title='gradx')
    df2.imshow(np.abs(grady), pnum=(nRow, nCol, 5), fnum=fnum, title='grady')
    df2.imshow(gmag, pnum=(nRow, nCol, 6), fnum=fnum, title='gmag')

    gpatch = ptool.gaussian_patch(shape=gori.shape)
    df2.imshow(gpatch * 255,
               pnum=(nRow, nCol, 7),
               fnum=fnum,
               title='gauss weights',
               cmap_='hot')
    #gpatch3 = np.dstack((gpatch, gpatch, gpatch))
    #df2.draw_vector_field(gradx * gpatch, grady * gpatch, pnum=(nRow, nCol, 8), fnum=fnum, title='gori (vec)')
    #df2.imshow(gorimag * gpatch3, pnum=(nRow, nCol, 9), fnum=fnum, title='gori (col)')
    #df2.imshow(gradx * gpatch,   pnum=(nRow, nCol, 10), fnum=fnum, title='gradx')
    #df2.imshow(grady * gpatch,   pnum=(nRow, nCol, 11), fnum=fnum, title='grady')
    #df2.imshow(gmag * gpatch,    pnum=(nRow, nCol, 12), fnum=fnum, title='gmag')
    return locals()