Exemplo n.º 1
0
    def on_click_inside(self, event, ax):
        from plottool import plot_helpers as ph
        ibs       = self.ibs
        viztype = ph.get_plotdat(ax, 'viztype', '')
        is_match_type = viztype in ['matches', 'multi_match']

        key = '' if event.key is None else event.key
        print('key=%r ' % key)
        ctrl_down = key.find('control') == 0
        # Click in match axes
        if event.button == 3:
            return super(MatchInteraction, self).on_click_inside(event, ax)
        if is_match_type and ctrl_down:
            # Ctrl-Click
            print('.. control click')
            return self.sv_view()
        elif viztype in ['warped', 'unwarped']:
            print('clicked at patch')
            ut.print_dict(ph.get_plotdat_dict(ax))
            hs_aid = {
                'aid1': self.qaid,
                'aid2': self.daid,
            }[vh.get_ibsdat(ax, 'aid', None)]
            hs_fx = vh.get_ibsdat(ax, 'fx', None)
            print('hs_fx = %r' % (hs_fx,))
            print('hs_aid = %r' % (hs_aid,))
            if hs_aid is not None and viztype == 'unwarped':
                ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=pt.next_fnum())
            elif hs_aid is not None and viztype == 'warped':
                viz.show_keypoint_gradient_orientations(ibs, hs_aid, hs_fx,
                                                        fnum=pt.next_fnum())
        else:
            return super(MatchInteraction, self).on_click_inside(event, ax)
        self.draw()
Exemplo n.º 2
0
 def _click_matches_click(event):
     print_('[inter] clicked matches')
     if event is None:
         return
     button = event.button
     is_right_click = button == 3
     if is_right_click:
         return
     (x, y, ax) = (event.xdata, event.ydata, event.inaxes)
     # Out of axes click
     if None in [x, y, ax]:
         print('... out of axis')
         _chipmatch_view()
         viz.draw()
         return
     viztype = vh.get_ibsdat(ax, 'viztype', '')
     print_('[ir] viztype=%r ' % viztype)
     key = '' if event.key is None else event.key
     print_('key=%r ' % key)
     ctrl_down = key.find('control') == 0
     # Click in match axes
     if viztype == 'matches' and ctrl_down:
         # Ctrl-Click
         print('.. control click')
         return _sv_view(aid)
     elif viztype == 'matches':
         if len(fm) == 0:
             print('[inter] no feature matches to click')
         else:
             # Normal Click
             # Select nearest feature match to the click
             kpts1, kpts2 = ibs.get_annot_kpts([qaid, aid])
             kpts1_m = kpts1[fm[:, 0]]
             kpts2_m = kpts2[fm[:, 1]]
             x2, y2, w2, h2 = xywh2_ptr[0]
             _mx1, _dist1 = utool.nearest_point(x, y, kpts1_m)
             _mx2, _dist2 = utool.nearest_point(x - x2, y - y2, kpts2_m)
             mx = _mx1 if _dist1 < _dist2 else _mx2
             print('... clicked mx=%r' % mx)
             _select_ith_match(mx, qaid, aid)
     elif viztype in ['warped', 'unwarped']:
         hs_aid = ax.__dict__.get('_hs_aid', None)
         hs_fx = ax.__dict__.get('_hs_fx', None)
         if hs_aid is not None and viztype == 'unwarped':
             ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=df2.next_fnum())
         elif hs_aid is not None and viztype == 'warped':
             viz.show_keypoint_gradient_orientations(ibs, hs_aid, hs_fx, fnum=df2.next_fnum())
     else:
         print('...Unknown viztype: %r' % viztype)
     viz.draw()
Exemplo n.º 3
0
    def _on_chip_click(event):
        print('[inter] clicked chip')
        ax, x, y = event.inaxes, event.xdata, event.ydata
        if ih.clicked_outside_axis(event):
            if not ischild:
                print('... out of axis')
                mode_ptr[0] = (mode_ptr[0] + 1) % 3
                _chip_view(**kwargs)
        else:
            if event.button == 3:  # right-click
                import guitool_ibeis as gt
                #from ibeis.viz.interact import interact_chip
                height = fig.canvas.geometry().height()
                qpoint = gt.newQPoint(event.x, height - event.y)
                refresh_func = partial(_chip_view, **kwargs)

                callback_list = build_annot_context_options(
                    ibs,
                    aid,
                    refresh_func=refresh_func,
                    with_interact_chip=False,
                    config2_=config2_)
                qwin = fig.canvas
                gt.popup_menu(qwin, qpoint, callback_list)
                #interact_chip.show_annot_context_menu(
                #    ibs, aid, fig.canvas, qpoint, refresh_func=refresh_func,
                #    with_interact_chip=False, config2_=config2_)
            else:
                viztype = vh.get_ibsdat(ax, 'viztype')
                print('[ic] viztype=%r' % viztype)
                if viztype == 'chip' and event.key == 'shift':
                    _chip_view(**kwargs)
                    ih.disconnect_callback(fig, 'button_press_event')
                elif viztype == 'chip':
                    kpts = ibs.get_annot_kpts(aid, config2_=config2_)
                    if len(kpts) > 0:
                        fx = nearest_point(x, y, kpts, conflict_mode='next')[0]
                        print('... clicked fx=%r' % fx)
                        _select_fxth_kpt(fx)
                    else:
                        print('... len(kpts) == 0')
                elif viztype in ['warped', 'unwarped']:
                    fx = vh.get_ibsdat(ax, 'fx')
                    if fx is not None and viztype == 'warped':
                        viz.show_keypoint_gradient_orientations(
                            ibs, aid, fx, fnum=pt.next_fnum())
                else:
                    print('...Unknown viztype: %r' % viztype)

        viz.draw()
Exemplo n.º 4
0
    def _on_chip_click(event):
        print('[inter] clicked chip')
        ax, x, y = event.inaxes, event.xdata, event.ydata
        if ih.clicked_outside_axis(event):
            if not ischild:
                print('... out of axis')
                mode_ptr[0] = (mode_ptr[0] + 1) % 3
                _chip_view(**kwargs)
        else:
            if event.button == 3:   # right-click
                import guitool
                #from ibeis.viz.interact import interact_chip
                height = fig.canvas.geometry().height()
                qpoint = guitool.newQPoint(event.x, height - event.y)
                refresh_func = partial(_chip_view, **kwargs)

                callback_list = build_annot_context_options(
                    ibs, aid, refresh_func=refresh_func,
                    with_interact_chip=False,
                    config2_=config2_)
                qwin = fig.canvas
                guitool.popup_menu(qwin, qpoint, callback_list)
                #interact_chip.show_annot_context_menu(
                #    ibs, aid, fig.canvas, qpoint, refresh_func=refresh_func,
                #    with_interact_chip=False, config2_=config2_)
            else:
                viztype = vh.get_ibsdat(ax, 'viztype')
                print('[ic] viztype=%r' % viztype)
                if viztype == 'chip' and event.key == 'shift':
                    _chip_view(**kwargs)
                    ih.disconnect_callback(fig, 'button_press_event')
                elif viztype == 'chip':
                    kpts = ibs.get_annot_kpts(aid, config2_=config2_)
                    if len(kpts) > 0:
                        fx = vt.nearest_point(
                            x, y, kpts, conflict_mode='next')[0]
                        print('... clicked fx=%r' % fx)
                        _select_fxth_kpt(fx)
                    else:
                        print('... len(kpts) == 0')
                elif viztype in ['warped', 'unwarped']:
                    fx = vh.get_ibsdat(ax, 'fx')
                    if fx is not None and viztype == 'warped':
                        viz.show_keypoint_gradient_orientations(
                            ibs, aid, fx, fnum=df2.next_fnum())
                else:
                    print('...Unknown viztype: %r' % viztype)

        viz.draw()
Exemplo n.º 5
0
    def on_click(self, event):
        aid = self.daid
        qaid = self.qaid
        ibs = self.ibs
        xywh2_ptr = self.xywh2_ptr
        print('[inter] clicked matches')
        if event is None:
            return
        button = event.button
        is_right_click = button == 3

        # Out of axes click
        (x, y, ax) = (event.xdata, event.ydata, event.inaxes)
        if None in [x, y, ax]:
            in_axis = False
            if not is_right_click:
                print('... out of axis')
                self.chipmatch_view()
                viz.draw()
                return
        else:
            in_axis = True

        if in_axis:
            viztype = vh.get_ibsdat(ax, 'viztype', '')
            is_match_type = viztype in ['matches', 'multi_match']
            print('[ir] viztype=%r ' % viztype)
        else:
            is_match_type = False
            viztype = ''

        if is_right_click:
            from ibeis.gui import inspect_gui
            options = []

            if is_match_type:
                options += inspect_gui.get_aidpair_context_menu_options(
                    self.ibs,
                    self.qaid,
                    self.daid,
                    self.cm,
                    qreq_=self.qreq_,
                    #update_callback=self.show_page,
                    #backend_callback=None, aid_list=aid_list)
                )

            options += [
                ('Toggle same_fig', self.toggle_samefig),
                ('Toggle vert', self.toggle_vert),
                ('query last feature', self.query_last_feature),
                ('show each chip', self.show_each_chip),
                ('show each distinctiveness chip',
                 self.show_each_dstncvs_chip),
                ('show each foreground weight chip',
                 self.show_each_fgweight_chip),
                ('show each probchip', self.show_each_probchip),
                ('show coverage', self.show_coverage),
                #('show each probchip', self.query_last_feature),
            ]

            #options.append(('name_interaction', self.name_interaction))
            if self.H1 is not None:
                options.append(('Toggle homog', self.toggle_homog))
            if ut.is_developer():
                options.append(('dev_reload', self.dev_reload))
                options.append(('dev_embed', self.dev_embed))
            #options.append(('cancel', lambda: print('cancel')))
            self.show_popup_menu(options, event)
            return

        if in_axis:
            key = '' if event.key is None else event.key
            print('key=%r ' % key)
            ctrl_down = key.find('control') == 0
            # Click in match axes
            if is_match_type and ctrl_down:
                # Ctrl-Click
                print('.. control click')
                return self.sv_view()
            elif is_match_type:
                if len(self.fm) == 0:
                    print('[inter] no feature matches to click')
                else:
                    # Normal Click
                    # Select nearest feature match to the click
                    kpts1 = ibs.get_annot_kpts([qaid],
                                               config2_=self.query_config2_)[0]
                    kpts2 = ibs.get_annot_kpts([aid],
                                               config2_=self.data_config2_)[0]
                    kpts1_m = kpts1[self.fm.T[0]]
                    kpts2_m = kpts2[self.fm.T[1]]
                    x2, y2, w2, h2 = xywh2_ptr[0]
                    _mx1, _dist1 = ut.nearest_point(x, y, kpts1_m)
                    _mx2, _dist2 = ut.nearest_point(x - x2, y - y2, kpts2_m)
                    mx = _mx1 if _dist1 < _dist2 else _mx2
                    (fx1, fx2) = self.fm[mx]
                    print('... clicked mx=%r' % mx)
                    print('... fx1, fx2 = %r, %r' % (
                        fx1,
                        fx2,
                    ))
                    self.select_ith_match(mx)
            elif viztype in ['warped', 'unwarped']:
                print('clicked at patch')
                ut.print_dict(ph.get_plotdat_dict(ax))
                hs_aid = vh.get_ibsdat(ax, 'aid', None)
                hs_fx = vh.get_ibsdat(ax, 'fx', None)
                #hs_aid = ax.__dict__.get('_hs_aid', None)
                #hs_fx = ax.__dict__.get('_hs_fx', None)
                print('hs_fx = %r' % (hs_fx, ))
                print('hs_aid = %r' % (hs_aid, ))
                if hs_aid is not None and viztype == 'unwarped':
                    ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=df2.next_fnum())
                elif hs_aid is not None and viztype == 'warped':
                    viz.show_keypoint_gradient_orientations(
                        ibs, hs_aid, hs_fx, fnum=df2.next_fnum())
            elif viztype.startswith('colorbar'):
                # Hack to get a specific scoring feature
                sortx = self.fs.argsort()
                idx = np.clip(int(np.round(y * len(sortx))), 0, len(sortx) - 1)
                mx = sortx[idx]
                (fx1, fx2) = self.fm[mx]
                (fx1, fx2) = self.fm[mx]
                print('... selected score at rank idx=%r' % (idx, ))
                print('... selected score with fs=%r' % (self.fs[mx], ))
                print('... resolved to mx=%r' % mx)
                print('... fx1, fx2 = %r, %r' % (
                    fx1,
                    fx2,
                ))
                self.select_ith_match(mx)
            else:
                print('...Unknown viztype: %r' % viztype)
            viz.draw()
Exemplo n.º 6
0
    def on_click(self, event):
        aid       = self.daid
        qaid      = self.qaid
        ibs       = self.ibs
        xywh2_ptr = self.xywh2_ptr
        print('[inter] clicked matches')
        if event is None:
            return
        button = event.button
        is_right_click = button == 3

        # Out of axes click
        (x, y, ax) = (event.xdata, event.ydata, event.inaxes)
        if None in [x, y, ax]:
            in_axis = False
            if not is_right_click:
                print('... out of axis')
                self.chipmatch_view()
                viz.draw()
                return
        else:
            in_axis = True

        if in_axis:
            viztype = vh.get_ibsdat(ax, 'viztype', '')
            is_match_type = viztype in ['matches', 'multi_match']
            print('[ir] viztype=%r ' % viztype)
        else:
            is_match_type = False
            viztype = ''

        if is_right_click:
            from ibeis.gui import inspect_gui
            options = []

            if is_match_type:
                options += inspect_gui.get_aidpair_context_menu_options(
                    self.ibs, self.qaid, self.daid, self.cm,
                    qreq_=self.qreq_,
                    #update_callback=self.show_page,
                    #backend_callback=None, aid_list=aid_list)
                )

            options += [
                ('Toggle same_fig', self.toggle_samefig),
                ('Toggle vert', self.toggle_vert),
                ('query last feature', self.query_last_feature),
                ('show each chip', self.show_each_chip),
                ('show each distinctiveness chip', self.show_each_dstncvs_chip),
                ('show each foreground weight chip', self.show_each_fgweight_chip),
                ('show each probchip', self.show_each_probchip),
                ('show coverage', self.show_coverage),
                #('show each probchip', self.query_last_feature),
            ]

            #options.append(('name_interaction', self.name_interaction))
            if self.H1 is not None:
                options.append(('Toggle homog', self.toggle_homog))
            if ut.is_developer():
                options.append(('dev_reload', self.dev_reload))
                options.append(('dev_embed', self.dev_embed))
            #options.append(('cancel', lambda: print('cancel')))
            self.show_popup_menu(options, event)
            return

        if in_axis:
            key = '' if event.key is None else event.key
            print('key=%r ' % key)
            ctrl_down = key.find('control') == 0
            # Click in match axes
            if is_match_type and ctrl_down:
                # Ctrl-Click
                print('.. control click')
                return self.sv_view()
            elif is_match_type:
                if len(self.fm) == 0:
                    print('[inter] no feature matches to click')
                else:
                    # Normal Click
                    # Select nearest feature match to the click
                    kpts1 = ibs.get_annot_kpts([qaid], config2_=self.query_config2_)[0]
                    kpts2 = ibs.get_annot_kpts([aid], config2_=self.data_config2_)[0]
                    kpts1_m = kpts1[self.fm.T[0]]
                    kpts2_m = kpts2[self.fm.T[1]]
                    x2, y2, w2, h2 = xywh2_ptr[0]
                    _mx1, _dist1 = ut.nearest_point(x, y, kpts1_m)
                    _mx2, _dist2 = ut.nearest_point(x - x2, y - y2, kpts2_m)
                    mx = _mx1 if _dist1 < _dist2 else _mx2
                    (fx1, fx2) = self.fm[mx]
                    print('... clicked mx=%r' % mx)
                    print('... fx1, fx2 = %r, %r' % (fx1, fx2,))
                    self.select_ith_match(mx)
            elif viztype in ['warped', 'unwarped']:
                print('clicked at patch')
                ut.print_dict(ph.get_plotdat_dict(ax))
                hs_aid = vh.get_ibsdat(ax, 'aid', None)
                hs_fx = vh.get_ibsdat(ax, 'fx', None)
                #hs_aid = ax.__dict__.get('_hs_aid', None)
                #hs_fx = ax.__dict__.get('_hs_fx', None)
                print('hs_fx = %r' % (hs_fx,))
                print('hs_aid = %r' % (hs_aid,))
                if hs_aid is not None and viztype == 'unwarped':
                    ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=df2.next_fnum())
                elif hs_aid is not None and viztype == 'warped':
                    viz.show_keypoint_gradient_orientations(ibs, hs_aid, hs_fx,
                                                            fnum=df2.next_fnum())
            elif viztype.startswith('colorbar'):
                # Hack to get a specific scoring feature
                sortx = self.fs.argsort()
                idx = np.clip(int(np.round(y * len(sortx))), 0, len(sortx) - 1)
                mx = sortx[idx]
                (fx1, fx2) = self.fm[mx]
                (fx1, fx2) = self.fm[mx]
                print('... selected score at rank idx=%r' % (idx,))
                print('... selected score with fs=%r' % (self.fs[mx],))
                print('... resolved to mx=%r' % mx)
                print('... fx1, fx2 = %r, %r' % (fx1, fx2,))
                self.select_ith_match(mx)
            else:
                print('...Unknown viztype: %r' % viztype)
            viz.draw()