def _on_image_click(event): printDBG('[inter] clicked image') if ih.clicked_outside_axis(event): # Toggle draw lbls kwargs['draw_lbls'] = not kwargs.get('draw_lbls', True) _image_view(**kwargs) else: ax = event.inaxes viztype = vh.get_ibsdat(ax, 'viztype') annotation_centers = vh.get_ibsdat(ax, 'annotation_centers', default=[]) printDBG(' annotation_centers=%r' % annotation_centers) printDBG(' viztype=%r' % viztype) if len(annotation_centers) == 0: print(' ...no chips exist to click') return x, y = event.xdata, event.ydata # Find ANNOTATION center nearest to the clicked point aid_list = vh.get_ibsdat(ax, 'aid_list', default=[]) centx, _dist = ut.nearest_point(x, y, annotation_centers) aid = aid_list[centx] print(' ...clicked aid=%r' % aid) if select_callback is not None: # HACK, should just implement this correctly here select_callback(gid, sel_aids=[aid], fnum=self.fnum) else: _image_view(sel_aids=[aid]) viz.draw()
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 figure_clicked(self, event=None): #print_('[inter] clicked name') ax = event.inaxes if ih.clicked_inside_axis(event): viztype = vh.get_ibsdat(ax, 'viztype') print_(' viztype=%r' % viztype) if viztype == 'chip': aid = vh.get_ibsdat(ax, 'aid') #print('... aid=%r' % aid) if event.button == 3: # right-click #import guitool #height = self.fig.canvas.geometry().height() #qpoint = guitool.newQPoint(event.x, height - event.y) #ibs = self.ibs #is_exemplar = ibs.get_annot_exemplar_flags(aid) #def context_func(): # ibs.set_annot_exemplar_flags(aid, not is_exemplar) # self.show_page() #guitool.popup_menu(self.fig.canvas, pt, [ # ('unset as exemplar' if is_exemplar else 'set as exemplar', context_func), #]) # TODO USE ABSTRACT INTERACTION from ibeis.viz.interact import interact_chip options = interact_chip.build_annot_context_options(self.ibs, aid, refresh_func=self.show_page) self.show_popup_menu(options, event) #interact_chip.show_annot_context_menu( # self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page) #ibs.print_annotation_table() #print(ut.dict_str(event.__dict__)) elif viztype == 'matches': self.cm.ishow_single_annotmatch(self.qreq_, self.aid2, fnum=None, mode=0)
def _on_name_click(event): ax = event.inaxes if ih.clicked_inside_axis(event): viztype = vh.get_ibsdat(ax, 'viztype') if viztype == 'chip': aid = vh.get_ibsdat(ax, 'aid') print('... aid=%r' % aid) 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 = functools.partial(viz.show_name, ibs, nid, fnum=fnum, sel_aids=sel_aids) interact_chip.show_annot_context_menu( ibs, aid, fig.canvas, qpoint, refresh_func=refresh_func, with_interact_name=False) else: viz.show_name(ibs, nid, fnum=fnum, sel_aids=[aid], in_image=True) if select_aid_callback is not None: select_aid_callback(aid) viz.draw()
def figure_clicked(self, event=None): from ibeis.viz import viz_helpers as vh ax = event.inaxes if ih.clicked_inside_axis(event): viztype = vh.get_ibsdat(ax, 'viztype') if viztype == 'chip': aid = vh.get_ibsdat(ax, 'aid') print('... aid=%r' % aid) if event.button == 3: # right-click from ibeis.viz.interact import interact_chip import guitool height = self.fig.canvas.geometry().height() qpoint = guitool.newQPoint(event.x, height - event.y) if self.qreq_ is None: config2_ = None else: if aid in self.qreq_.qaids: config2_ = self.qreq_.query_config2_ else: config2_ = self.qreq_.data_config2_ callback_list = interact_chip.build_annot_context_options( self.ibs, aid, refresh_func=self.show_page, config2_=config2_) guitool.popup_menu(self.fig.canvas, qpoint, callback_list) #interact_chip.show_annot_context_menu( # self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page) #self.show_page() #ibs.print_annotation_table() print(ut.dict_str(event.__dict__))
def figure_clicked(self, event=None): ax = event.inaxes if ih.clicked_inside_axis(event): viztype = vh.get_ibsdat(ax, 'viztype') if viztype == 'chip': aid = vh.get_ibsdat(ax, 'aid') #print('... aid=%r' % aid) if event.button == 3: # right-click #import guitool #height = self.fig.canvas.geometry().height() #qpoint = guitool.newQPoint(event.x, height - event.y) #ibs = self.ibs #is_exemplar = ibs.get_annot_exemplar_flags(aid) #def context_func(): # ibs.set_annot_exemplar_flags(aid, not is_exemplar) # self.show_page() #guitool.popup_menu(self.fig.canvas, pt, [ # ('unset as exemplar' if is_exemplar else 'set as exemplar', context_func), #]) # TODO USE ABSTRACT INTERACTION from ibeis.viz.interact import interact_chip options = interact_chip.build_annot_context_options( self.ibs, aid, refresh_func=self.show_page) self.show_popup_menu(options, event) #interact_chip.show_annot_context_menu( # self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page) #ibs.print_annotation_table() #print(ut.repr2(event.__dict__)) elif viztype == 'matches': self.cm.ishow_single_annotmatch(self.qreq_, self.aid2, fnum=None, mode=0)
def _on_image_click(event): printDBG('[inter] clicked image') if ih.clicked_outside_axis(event): # Toggle draw lbls kwargs['draw_lbls'] = not kwargs.get('draw_lbls', True) _image_view(**kwargs) else: ax = event.inaxes viztype = vh.get_ibsdat(ax, 'viztype') annotation_centers = vh.get_ibsdat(ax, 'annotation_centers', default=[]) printDBG(' annotation_centers=%r' % annotation_centers) printDBG(' viztype=%r' % viztype) if len(annotation_centers) == 0: print(' ...no chips exist to click') return x, y = event.xdata, event.ydata # Find ANNOTATION center nearest to the clicked point aid_list = vh.get_ibsdat(ax, 'aid_list', default=[]) import vtool_ibeis as vt centx, _dist = vt.nearest_point(x, y, annotation_centers) aid = aid_list[centx] print(' ...clicked aid=%r' % aid) if select_callback is not None: # HACK, should just implement this correctly here select_callback(gid, sel_aids=[aid], fnum=self.fnum) else: _image_view(sel_aids=[aid]) viz.draw()
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()
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()
def figure_clicked(self, event=None): from ibeis.viz import viz_helpers as vh ax = event.inaxes if ih.clicked_inside_axis(event): viztype = vh.get_ibsdat(ax, 'viztype') if viztype == 'chip': aid = vh.get_ibsdat(ax, 'aid') print('... aid=%r' % aid) if event.button == 3: # right-click from ibeis.viz.interact import interact_chip height = self.fig.canvas.geometry().height() qpoint = guitool.newQPoint(event.x, height - event.y) interact_chip.show_annot_context_menu( self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page) #self.show_page() #ibs.print_annotation_table() print(ut.dict_str(event.__dict__))
def _on_name_click(event): print_('[inter] clicked name') ax = event.inaxes if ih.clicked_inside_axis(event): viztype = vh.get_ibsdat(ax, 'viztype') print_(' viztype=%r' % viztype) if viztype == 'chip': aid = vh.get_ibsdat(ax, 'aid') print('... aid=%r' % aid) 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 = functools.partial(viz.show_name, ibs, nid, fnum=fnum, sel_aids=sel_aids) interact_chip.show_annot_context_menu( ibs, aid, fig.canvas, qpoint, refresh_func=refresh_func, with_interact_name=False) else: viz.show_name(ibs, nid, fnum=fnum, sel_aids=[aid], in_image=True) if select_aid_callback is not None: select_aid_callback(aid) viz.draw()
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()
def _on_sv_click(event): ax = event.inaxes if ih.clicked_outside_axis(event): print('... out of axis') mode_ptr[0] = (mode_ptr[0] + 1) % 3 kwargs['show_kpts'] = mode_ptr[0] == 2 kwargs['show_lines'] = mode_ptr[0] >= 1 _sv_view(**kwargs) else: viztype = vh.get_ibsdat(ax, 'viztype') if viztype in ['homogblend', 'affblend', 'source', 'dest']: pass else: print('...Unknown viztype: %r' % viztype) viz.draw()
def _on_sv_click(event): print_('[inter] clicked sv') ax = event.inaxes if ih.clicked_outside_axis(event): print('... out of axis') mode_ptr[0] = (mode_ptr[0] + 1) % 3 kwargs['show_kpts'] = mode_ptr[0] == 2 kwargs['show_lines'] = mode_ptr[0] >= 1 _sv_view(**kwargs) else: viztype = vh.get_ibsdat(ax, 'viztype') print_('[ic] viztype=%r' % viztype) if viztype in ['homogblend', 'affblend', 'source', 'dest']: pass 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()
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()