def on_click_inside(self, event, ax): from plottool import plot_helpers as ph (x, y) = (event.xdata, event.ydata) viztype = ph.get_plotdat(ax, "viztype", "") if event.button == 3: self.show_popup_menu(self.get_popup_options(), event) return # key = '' if event.key is None else event.key # ctrl_down = key.find('control') == 0 if viztype == "matches": if len(self.fm) == 0: print("[inter] no feature matches to click") else: # Normal Click # Select nearest feature match to the click kpts1_m = self.kpts1[self.fm[:, 0]] kpts2_m = self.kpts2[self.fm[:, 1]] x2, y2, w2, h2 = self.xywh2 _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 print("... clicked mx=%r" % mx) self.select_ith_match(mx) elif viztype in ["warped", "unwarped"]: pass # 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=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()) # Click in match axes # elif viztype == 'matches' and ctrl_down: # # Ctrl-Click # print('.. control click') # return self.sv_view() 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) self.draw()
def on_click_inside(self, event, ax): from plottool import plot_helpers as ph (x, y) = (event.xdata, event.ydata) viztype = ph.get_plotdat(ax, 'viztype', '') if event.button == 3: self.show_popup_menu(self.get_popup_options(), event) return #key = '' if event.key is None else event.key #ctrl_down = key.find('control') == 0 if viztype == 'matches': if len(self.fm) == 0: print('[inter] no feature matches to click') else: # Normal Click # Select nearest feature match to the click kpts1_m = self.kpts1[self.fm[:, 0]] kpts2_m = self.kpts2[self.fm[:, 1]] x2, y2, w2, h2 = self.xywh2 _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 print('... clicked mx=%r' % mx) self.select_ith_match(mx) elif viztype in ['warped', 'unwarped']: pass #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=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()) # Click in match axes #elif viztype == 'matches' and ctrl_down: # # Ctrl-Click # print('.. control click') # return self.sv_view() 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) self.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_click_inside(self, event, ax): import plottool as pt viztype = ph.get_plotdat(ax, 'viztype', None) print('[ik] viztype=%r' % viztype) if viztype is None: pass elif viztype == 'keypoints': kpts = ph.get_plotdat(ax, 'kpts', []) if len(kpts) == 0: print('...nokpts') else: print('...nearest') x, y = event.xdata, event.ydata fx = ut.nearest_point(x, y, kpts)[0] self._select_ith_kpt(fx) elif viztype == 'warped': hs_fx = ph.get_plotdat(ax, 'fx', None) if hs_fx is not None: kp = self.kpts[hs_fx] # FIXME sift = self.vecs[hs_fx] df2.draw_keypoint_gradient_orientations(self.chip, kp, sift=sift, mode='vec', fnum=pt.next_fnum()) pt.draw() elif viztype.startswith('colorbar'): pass else: print('...unhandled') self.draw()
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_keypoints_click(event): print('[viz] clicked keypoint view') if event is None or event.xdata is None or event.inaxes is None: annote_ptr[0] = (annote_ptr[0] + 1) % 3 mode = annote_ptr[0] ell = mode == 1 pts = mode == 2 print('... default kpts view mode=%r' % mode) _viz_keypoints(fnum, ell=ell, pts=pts, **kwargs) # MAYBE: remove kwargs else: ax = event.inaxes viztype = ph.get_plotdat(ax, 'viztype', None) print('[ik] viztype=%r' % viztype) if viztype == 'keypoints': kpts = ph.get_plotdat(ax, 'kpts', []) if len(kpts) == 0: print('...nokpts') else: print('...nearest') x, y = event.xdata, event.ydata fx = ut.nearest_point(x, y, kpts)[0] _select_ith_kpt(fx) elif viztype == 'warped': hs_fx = ph.get_plotdat(ax, 'fx', None) #kpts = ph.get_plotdat(ax, 'kpts', []) if hs_fx is not None: # Ugly. Interactions should be changed to classes. kp = self.kpts[hs_fx] # FIXME sift = self.vecs[hs_fx] df2.draw_keypoint_gradient_orientations( chip, kp, sift=sift, mode='vec', fnum=df2.next_fnum()) elif viztype.startswith('colorbar'): pass # 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('...unhandled') ph.draw()
def _on_keypoints_click(event): print('[viz] clicked keypoint view') if event is None or event.xdata is None or event.inaxes is None: annote_ptr[0] = (annote_ptr[0] + 1) % 3 mode = annote_ptr[0] ell = mode == 1 pts = mode == 2 print('... default kpts view mode=%r' % mode) _viz_keypoints(fnum, ell=ell, pts=pts, **kwargs) # MAYBE: remove kwargs else: ax = event.inaxes viztype = ph.get_plotdat(ax, 'viztype', None) print('[ik] viztype=%r' % viztype) if viztype == 'keypoints': kpts = ph.get_plotdat(ax, 'kpts', []) if len(kpts) == 0: print('...nokpts') else: print('...nearest') x, y = event.xdata, event.ydata fx = ut.nearest_point(x, y, kpts)[0] _select_ith_kpt(fx) elif viztype == 'warped': hs_fx = ph.get_plotdat(ax, 'fx', None) #kpts = ph.get_plotdat(ax, 'kpts', []) if hs_fx is not None: # Ugly. Interactions should be changed to classes. kp = self.kpts[hs_fx] # FIXME sift = self.vecs[hs_fx] df2.draw_keypoint_gradient_orientations(chip, kp, sift=sift, mode='vec', fnum=df2.next_fnum()) elif viztype.startswith('colorbar'): pass # 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('...unhandled') ph.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()