Beispiel #1
0
 def _draw_matches(px, title, inliers):
     dmkwargs = dict(fs=None,
                     title=title,
                     all_kpts=False,
                     draw_lines=True,
                     docla=True,
                     draw_border=True,
                     fnum=fnum,
                     pnum=pnum1_(px),
                     colors=df2.ORANGE)
     __fm = np.vstack((inliers, inliers)).T
     df2.show_chipmatch2(chip1, chip2, kpts1_m, kpts2_m, __fm, **dmkwargs)
     return px + 1
Beispiel #2
0
def show_sv_simple(chip1, chip2, kpts1, kpts2, fm, inliers, mx=None, fnum=1, vert=None, **kwargs):
    """

    CommandLine:
        python -m plottool.draw_sv --test-show_sv_simple --show

    Example:
        >>> # DISABLE_DOCTEST
        >>> from plottool.draw_sv import *  # NOQA
        >>> import vtool as vt
        >>> kpts1, kpts2, fm, aff_inliers, chip1, chip2, xy_thresh_sqrd = vt.testdata_matching_affine_inliers()
        >>> inliers = aff_inliers
        >>> mx = None
        >>> fnum = 1
        >>> vert = None  # ut.get_argval('--vert', type_=bool, default=None)
        >>> result = show_sv_simple(chip1, chip2, kpts1, kpts2, fm, inliers, mx, fnum, vert=vert)
        >>> print(result)
        >>> ut.show_if_requested()
    """
    import plottool as pt
    colors = df2.distinct_colors(2, brightness=.95)
    color1, color2 = colors[0:2]
    # Begin the drawing
    fnum = pt.ensure_fnum(fnum)
    df2.figure(fnum=fnum, pnum=(1, 1, 1), docla=True, doclf=True)
    #dmkwargs = dict(fs=None, title='Inconsistent Matches', all_kpts=False, draw_lines=True,
    #                docla=True, draw_border=True, fnum=fnum, pnum=(1, 1, 1), colors=df2.ORANGE)
    inlier_mask = vt.index_to_boolmask(inliers, maxval=len(fm))
    fm_inliers = fm.compress(inlier_mask, axis=0)
    fm_outliers = fm.compress(np.logical_not(inlier_mask), axis=0)
    ax, xywh1, xywh2 = df2.show_chipmatch2(chip1, chip2, vert=vert)
    fmatch_kw = dict(ell_linewidth=2, ell_alpha=.7, line_alpha=.7)
    df2.plot_fmatch(xywh1, xywh2, kpts1, kpts2, fm_inliers, colors=color1, **fmatch_kw)
    df2.plot_fmatch(xywh1, xywh2, kpts1, kpts2, fm_outliers, colors=color2, **fmatch_kw)
Beispiel #3
0
def show_sv_simple(chip1,
                   chip2,
                   kpts1,
                   kpts2,
                   fm,
                   inliers,
                   mx=None,
                   fnum=1,
                   vert=None,
                   **kwargs):
    """

    CommandLine:
        python -m plottool.draw_sv --test-show_sv_simple --show

    Example:
        >>> # DISABLE_DOCTEST
        >>> from plottool.draw_sv import *  # NOQA
        >>> import vtool as vt
        >>> kpts1, kpts2, fm, aff_inliers, chip1, chip2, xy_thresh_sqrd = vt.testdata_matching_affine_inliers()
        >>> inliers = aff_inliers
        >>> mx = None
        >>> fnum = 1
        >>> vert = None  # ut.get_argval('--vert', type_=bool, default=None)
        >>> result = show_sv_simple(chip1, chip2, kpts1, kpts2, fm, inliers, mx, fnum, vert=vert)
        >>> print(result)
        >>> ut.show_if_requested()
    """
    import plottool as pt
    colors = df2.distinct_colors(2, brightness=.95)
    color1, color2 = colors[0:2]
    # Begin the drawing
    fnum = pt.ensure_fnum(fnum)
    df2.figure(fnum=fnum, pnum=(1, 1, 1), docla=True, doclf=True)
    #dmkwargs = dict(fs=None, title='Inconsistent Matches', all_kpts=False, draw_lines=True,
    #                docla=True, draw_border=True, fnum=fnum, pnum=(1, 1, 1), colors=df2.ORANGE)
    inlier_mask = vt.index_to_boolmask(inliers, maxval=len(fm))
    fm_inliers = fm.compress(inlier_mask, axis=0)
    fm_outliers = fm.compress(np.logical_not(inlier_mask), axis=0)
    ax, xywh1, xywh2 = df2.show_chipmatch2(chip1, chip2, vert=vert)
    fmatch_kw = dict(ell_linewidth=2, ell_alpha=.7, line_alpha=.7)
    df2.plot_fmatch(xywh1,
                    xywh2,
                    kpts1,
                    kpts2,
                    fm_inliers,
                    colors=color1,
                    **fmatch_kw)
    df2.plot_fmatch(xywh1,
                    xywh2,
                    kpts1,
                    kpts2,
                    fm_outliers,
                    colors=color2,
                    **fmatch_kw)
Beispiel #4
0
def show_matches(ibs, qres, aid2, sel_fm=[], **kwargs):
    """ shows single annotated match result. """
    in_image = kwargs.get('in_image', False)
    draw_fmatches = kwargs.get('draw_fmatches', True)
    aid1 = qres.qaid
    fm = qres.aid2_fm[aid2]
    fs = qres.aid2_fs[aid2]
    # Read query and result info (chips, names, ...)
    rchip1, rchip2 = vh.get_chips(ibs, [aid1, aid2], **kwargs)
    if draw_fmatches:
        kpts1, kpts2 = vh.get_kpts( ibs, [aid1, aid2], **kwargs)
    else:
        kpts1, kpts2 = None, None

    # Build annotation strings / colors
    lbl1 = 'q' + vh.get_aidstrs(aid1)
    lbl2 = vh.get_aidstrs(aid2)
    if in_image:  # HACK!
        lbl1 = None
        lbl2 = None
    # Draws the chips and keypoint matches
    try:
        ax, xywh1, xywh2 = df2.show_chipmatch2(rchip1, rchip2, kpts1, kpts2,
                                               fm, fs=fs, lbl1=lbl1, lbl2=lbl2,
                                               **kwargs)
    except Exception as ex:
        utool.printex(ex, 'consider qr.remove_corrupted_queries',
                      '[viz_matches]')
        print('')
        raise
    (x1, y1, w1, h1) = xywh1
    (x2, y2, w2, h2) = xywh2
    if len(sel_fm) > 0:
        # Draw any selected matches
        sm_kw = dict(rect=True, colors=df2.BLUE)
        df2.plot_fmatch(xywh1, xywh2, kpts1, kpts2, sel_fm, **sm_kw)
    offset1 = (x1, y1)
    offset2 = (x2, y2)
    annotate_matches(ibs, qres, aid2, xywh2=xywh2, xywh1=xywh1,
                     offset1=offset1, offset2=offset2, **kwargs)
    return ax, xywh1, xywh2
Beispiel #5
0
 def _draw_matches(px, title, inliers):
     dmkwargs = dict(fs=None, title=title, all_kpts=False, draw_lines=True,
                     docla=True, draw_border=True, fnum=fnum, pnum=pnum1_(px), colors=df2.ORANGE)
     __fm = np.vstack((inliers, inliers)).T
     df2.show_chipmatch2(chip1, chip2, kpts1_m, kpts2_m, __fm, **dmkwargs)
     return px + 1