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()
def on_click_inside(self, event, ax): ax = event.inaxes viztype = ph.get_plotdat(ax, 'viztype', '') #if verbose: # print(str(event.__dict__)) print('viztype=%r' % viztype) # Clicked a specific matches print('plodat_dict = ' + ut.repr2(ph.get_plotdat_dict(ax))) if viztype.startswith('chip'): from ibeis.viz.interact import interact_chip options = interact_chip.build_annot_context_options( self.ibs, self.cm.qaid, refresh_func=self._analysis_view, with_interact_chip=False) self.show_popup_menu(options, event) if viztype.startswith('matches') or viztype == 'multi_match': # why startswith? aid2 = ph.get_plotdat(ax, 'aid2', None) aid_list = ph.get_plotdat(ax, 'aid_list', None) if event.button == 3: # right-click # TODO; this functionality should be in viz.interact from ibeis.gui import inspect_gui print('right click') print('qreq_ = %r' % (self.qreq_,)) options = inspect_gui.get_aidpair_context_menu_options( self.ibs, self.cm.qaid, aid2, self.cm, qreq_=self.qreq_, update_callback=self.show_page, backend_callback=None, aid_list=aid_list) self.show_popup_menu(options, event) else: # Ctrl-Click key = '' if event.key is None else event.key print('key = %r' % key) if key.find('control') == 0: print('[viz] result control clicked') self.show_sver_process_to_aid(aid2) # Left-Click else: print('[viz] result clicked') self.show_matches_to_aid(aid2) self.draw()
def on_click_inside(self, event, ax): ax = event.inaxes viztype = ph.get_plotdat(ax, 'viztype', '') #if verbose: # print(str(event.__dict__)) print('viztype=%r' % viztype) # Clicked a specific matches print('plodat_dict = ' + ut.dict_str(ph.get_plotdat_dict(ax))) if viztype.startswith('chip'): from ibeis.viz.interact import interact_chip options = interact_chip.build_annot_context_options( self.ibs, self.cm.qaid, refresh_func=self._analysis_view, with_interact_chip=False) self.show_popup_menu(options, event) if viztype.startswith('matches') or viztype == 'multi_match': # why startswith? aid2 = ph.get_plotdat(ax, 'aid2', None) aid_list = ph.get_plotdat(ax, 'aid_list', None) if event.button == 3: # right-click # TODO; this functionality should be in viz.interact from ibeis.gui import inspect_gui print('right click') print('qreq_ = %r' % (self.qreq_,)) options = inspect_gui.get_aidpair_context_menu_options( self.ibs, self.cm.qaid, aid2, self.cm, qreq_=self.qreq_, update_callback=self.show_page, backend_callback=None, aid_list=aid_list) self.show_popup_menu(options, event) else: # Ctrl-Click key = '' if event.key is None else event.key print('key = %r' % key) if key.find('control') == 0: print('[viz] result control clicked') self.show_sver_process_to_aid(aid2) # Left-Click else: print('[viz] result clicked') self.show_matches_to_aid(aid2) self.draw()
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()
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()