# -*- coding: utf-8 -*- import utool as ut ut.noinject(__name__, '[wbia.gui.__init__]', DEBUG=False)
# flake8: noqa from __future__ import absolute_import, division, print_function __version__ = '1.0.1.dev1' import utool as ut ut.noinject(__name__, '[guitool.__init__]') #try: # # try seeing if importing plottool before any guitool things helps # import plottool #except Exception as ex: # import utool as ut # ut.printex(ex, 'tried to import plottool to solve win crash') # raise # #pass #print('__guitool__1') from guitool import __PYQT__ #print('__guitool__2') from guitool import api_item_model from guitool import api_table_view from guitool import api_tree_view from guitool import api_item_widget from guitool import stripe_proxy_model from guitool import guitool_tables from guitool import guitool_dialogs from guitool import guitool_decorators
""" CommandLine: rm -rf /media/raid/work/PZ_MTEST/_ibsdb/_ibeis_cache/match_thumbs/ python -m ibeis.gui.inspect_gui --test-test_inspect_matches --show --verbose-thumb """ from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtGui, QtCore #import cv2 # NOQA #import numpy as np #import time #from six.moves import zip import vtool as vt from os.path import exists from vtool import geometry import utool as ut ut.noinject(__name__, '[APIThumbDelegate]') VERBOSE_QT = ut.get_argflag(('--verbose-qt', '--verbqt')) VERBOSE_THUMB = ut.VERBOSE or ut.get_argflag(('--verbose-thumb', '--verbthumb')) or VERBOSE_QT MAX_NUM_THUMB_THREADS = 1 def read_thumb_size(thumb_path): if VERBOSE_THUMB: print('[ThumbDelegate] Reading thumb size') npimg = vt.imread(thumb_path, delete_if_corrupted=True) (height, width) = npimg.shape[0:2] del npimg
# flake8: noqa from __future__ import absolute_import, division, print_function __version__ = '1.0.0.dev1' import utool as ut ut.noinject(__name__, '[pyrf.__init__]') from ._pyrf import *
# -*- coding: utf-8 -*- # flake8: noqa from __future__ import absolute_import, division, print_function, unicode_literals import utool as ut ut.noinject(__name__, '[ibeis.algo.preproc.__init__]', DEBUG=False) from ibeis.algo.preproc import preproc_chip from ibeis.algo.preproc import preproc_detectimg from ibeis.algo.preproc import preproc_encounter from ibeis.algo.preproc import preproc_feat from ibeis.algo.preproc import preproc_featweight from ibeis.algo.preproc import preproc_image from ibeis.algo.preproc import preproc_probchip from ibeis.algo.preproc import preproc_residual from ibeis.algo.preproc import preproc_rvec import utool print, print_, printDBG, rrr, profile = utool.inject( __name__, '[ibeis.algo.preproc]') def reload_subs(verbose=True): """ Reloads ibeis.algo.preproc and submodules """ rrr(verbose=verbose) def fbrrr(*args, **kwargs): """ fallback reload """ pass #getattr(preproc_annot, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_chip, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_detectimg, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_encounter, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_feat, 'rrr', fbrrr)(verbose=verbose)
""" Dependencies: flask, tornado """ from __future__ import absolute_import, division, print_function, unicode_literals from ibeis.control import accessor_decors, controller_inject from ibeis.algo.hots import pipeline from flask import url_for, request, current_app # NOQA from os.path import join, dirname, abspath import numpy as np # NOQA import utool as ut #import vtool as vt #import cv2 # NOQA import dtool from ibeis.web import appfuncs as appf ut.noinject('[apis_query]') CLASS_INJECT_KEY, register_ibs_method = ( controller_inject.make_ibs_register_decorator(__name__)) register_api = controller_inject.get_ibeis_flask_api(__name__) register_route = controller_inject.get_ibeis_flask_route(__name__) @register_ibs_method @accessor_decors.default_decorator @register_api('/api/query/recognition_query_aids/', methods=['GET']) def get_recognition_query_aids(ibs, is_known, species=None): """ DEPCIRATE RESTful:
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import utool as ut ut.noinject(__name__, "[ibeis.tests.__init__]", DEBUG=False)
# -*- coding: utf-8 -*- """ This module defines all of the menu items in the main GUI as well as their callbacks in guiback """ from __future__ import absolute_import, division, print_function import utool as ut import functools from ibeis import constants as const import guitool as gt ut.noinject(__name__, '[guimenus]') class DummyBack(object): def __init__(self): print('using dummy back') pass def __getattr__(self, name): #print(name) if name.startswith('_'): return self.__dict__[name] import mock mock.Mock() return mock.Mock() def setup_dummy_menus(): r""" CommandLine: python -m ibeis.gui.guimenus --test-setup_dummy_menus
CommandLine: python -m plottool.draw_func2 --exec-imshow --show --mplbe=GTKAgg python -m plottool.draw_func2 --exec-imshow --show --mplbe=TkAgg python -m plottool.draw_func2 --exec-imshow --show --mplbe=WxAgg python -m plottool.draw_func2 --exec-imshow --show --mplbe=WebAgg python -m plottool.draw_func2 --exec-imshow --show --mplbe=gdk python -m plottool.draw_func2 --exec-imshow --show --mplbe=cairo """ from __future__ import absolute_import, division, print_function, unicode_literals import sys import os import utool as ut ut.noinject(__name__, '[plottool.__MPL_INIT__]') __IS_INITIALIZED__ = False __WHO_INITIALIZED__ = None VERBOSE_MPLINIT = ut.get_argflag(('--verb-mpl', '--verbose')) TARGET_BACKEND = ut.get_argval(('--mpl-backend', '--mplbe'), type_=str, default=None) FALLBACK_BACKEND = ut.get_argval(('--mpl-fallback-backend', '--mplfbbe'), type_=str, default='agg') def print_all_backends(): import matplotlib.rcsetup as rcsetup print(rcsetup.all_backends) valid_backends = [u'GTK', u'GTKAgg', u'GTKCairo', u'MacOSX', u'Qt4Agg',
from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtGui, QtCore # NOQA from guitool.__PYQT__.QtCore import Qt import utool utool.noinject(__name__, '[APIItemView]', DEBUG=False) #BASE_CLASS = QtGui.QAbstractProxyModel BASE_CLASS = QtGui.QSortFilterProxyModel # BASE_CLASS = QtGui.QIdentityProxyModel class FilterProxyModel(BASE_CLASS): __metaclass__ = utool.makeForwardingMetaclass( lambda self: self.sourceModel(), ['_set_context_id', '_get_context_id', '_set_changeblocked', '_get_changeblocked', '_about_to_change', '_change', '_update', '_rows_updated', 'name', 'get_header_name'], base_class=BASE_CLASS) def __init__(self, parent=None): BASE_CLASS.__init__(self, parent=parent) self.filter_dict = {} def proxy_to_source(self, row, col, parent=QtCore.QModelIndex()): r2, c2, p2 = row, col, parent return r2, c2, p2 def source_to_proxy(self, row, col, parent=QtCore.QModelIndex()): r2, c2, p2 = row, col, parent return r2, c2, p2
# -*- coding: utf-8 -*- """ Dependencies: flask, tornado """ from __future__ import absolute_import, division, print_function, unicode_literals from ibeis.control import accessor_decors, controller_inject from ibeis.algo.hots import pipeline from flask import url_for, request, current_app # NOQA from os.path import join, dirname, abspath import numpy as np # NOQA import utool as ut #import vtool as vt #import cv2 # NOQA import dtool from ibeis.web import appfuncs as appf ut.noinject('[apis_query]') CLASS_INJECT_KEY, register_ibs_method = ( controller_inject.make_ibs_register_decorator(__name__)) register_api = controller_inject.get_ibeis_flask_api(__name__) register_route = controller_inject.get_ibeis_flask_route(__name__) @register_ibs_method @accessor_decors.default_decorator @register_api('/api/query/recognition_query_aids/', methods=['GET']) def get_recognition_query_aids(ibs, is_known, species=None): """ DEPCIRATE
from __future__ import absolute_import, division, print_function from six.moves import range, zip, map # NOQA from plottool import custom_constants # NOQA import colorsys import numpy as np # NOQA import utool as ut #from plottool import colormaps as cmaps2 #(print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[colorfuncs]', DEBUG=False) ut.noinject(__name__, '[colorfuncs]') def _test_base01(channels): tests01 = { 'is_float': all([ut.is_float(c) for c in channels]), 'is_01': all([c >= 0.0 and c <= 1.0 for c in channels]), } return tests01 def _test_base255(channels): tests255 = { #'is_int': all([ut.is_int(c) for c in channels]), 'is_255': all([c >= 0.0 and c <= 255.0 for c in channels]), } return tests255 def is_base01(channels): """ check if a color is in base 01 """ return all(_test_base01(channels).values())
from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtCore, QtGui import utool as ut ut.noinject(__name__, '[guitool.delegates]', DEBUG=False) class APIDelegate(QtGui.QItemDelegate): is_persistant_editable = True def __init__(self, parent): QtGui.QItemDelegate.__init__(self, parent) def sizeHint(option, qindex): # QStyleOptionViewItem option return QtCore.QSize(50, 50) class ImageDelegate(QtGui.QStyledItemDelegate): def __init__(self, parent): print(dir(self)) QtGui.QStyledItemDelegate.__init__(self, parent) def paint(self, painter, option, index): painter.fillRect(option.rect, QtGui.QColor(191, 222, 185)) # path = "path\to\my\image.jpg" self.path = "image.bmp" image = QtGui.QImage(str(self.path)) pixmap = QtGui.QPixmap.fromImage(image) pixmap.scaled(50, 40, QtCore.Qt.KeepAspectRatio)
TODO: LAZY IMPORTS? http://code.activestate.com/recipes/473888-lazy-module-imports/ """ # flake8: noqa from __future__ import absolute_import, division, print_function, unicode_literals try: import utool as ut import dtool except ImportError as ex: print('[ibeis !!!] ERROR: Unable to load all core utility modules.') print('[ibeis !!!] Perhaps try super_setup.py pull') raise ut.noinject(__name__, '[ibeis.__init__]') if ut.VERBOSE: print('[ibeis] importing ibeis __init__') if ut.is_developer(): standard_visualization_functions = [ 'show_image', 'show_chip', 'show_chipmatch', 'show_chipmatches', 'show_vocabulary', #'show_vocabulary', ] # If we dont initialize plottool before <something>
#import matplotlib.image as mpimg from plottool import viz_image2 from plottool import interact_annotations from plottool import draw_func2 as df2 from plottool import plot_helpers as ph from plottool import interact_helpers as ih from plottool import abstract_interaction from matplotlib.widgets import Button # NOQA import matplotlib.pyplot as plt # NOQA import matplotlib as mpl # NOQA import six import vtool as vt #import utool import utool as ut ut.noinject(__name__, '[pt.interact_multiimage]') BASE_CLASS = abstract_interaction.AbstractInteraction #BASE_CLASS = object class MultiImageInteraction(BASE_CLASS): """ CommandLine: python -m plottool.interact_multi_image --exec-MultiImageInteraction --show Example: >>> # ENABLE_DOCTEST >>> from plottool.interact_multi_image import * # NOQA
from guitool.__PYQT__ import QtCore, QtGui, QVariantHack from guitool.__PYQT__.QtCore import Qt from guitool import qtype from guitool.guitool_decorators import checks_qt_error, signal_ # NOQA from six.moves import zip # builtins # NOQA #from utool._internal.meta_util_six import get_funcname import functools import utool as ut #from .api_thumb_delegate import APIThumbDelegate import numpy as np #profile = lambda func: func #printDBG = lambda *args: None # UTOOL PRINT STATEMENTS CAUSE RACE CONDITIONS IN QT THAT CAN LEAD TO SEGFAULTS # DO NOT INJECT THEM IN GUITOOL #(print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[APIItemModel]', DEBUG=False) ut.noinject(__name__, '[APIItemModel]', DEBUG=False) #raise ImportError('refused to import guitool') profile = ut.profile API_MODEL_BASE = QtCore.QAbstractItemModel VERBOSE = ut.VERBOSE or ut.get_argflag(('--verbose-qt', '--verbqt')) try: # TODO Cyth should take care of this stuff # also, it should be a function level import not module? #if not ut.get_argflag('--nocyth'): if ut.get_argflag('--cyth'):
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals import six import utool as ut from ibeis import constants as const # NOQA from plottool import interact_helpers as ih import plottool as pt from ibeis.viz.interact import interact_matches # NOQA # from ibeis.gui import guiback from functools import partial import guitool from ibeis.viz import viz_chip from ibeis.viz import viz_matches from plottool.abstract_interaction import AbstractInteraction ut.noinject(__name__, '[interact_query_decision]') #(print, print_, printDBG, rrr, profile) = ut.inject(__name__, # '[interact_query_decision]', DEBUG=False) #========================== # query interaction #========================== NUM_TOP = 3 class QueryVerificationInteraction(AbstractInteraction): """ CommandLine: python -m ibeis.viz.interact.interact_query_decision --test-QueryVerificationInteraction --show python -m ibeis --imgsetid 2 --inc-query --yes
# -*- coding: utf-8 -*- """ It is better to use constant variables instead of hoping you spell the same string correctly every time you use it. (Also it makes it much easier if a string name changes) """ from __future__ import absolute_import, division, print_function, unicode_literals import six import numpy as np import math import utool as ut from collections import OrderedDict from os.path import join ut.noinject('[const]') CONTAINERIZED = ut.get_argflag('--containerized') PRODUCTION = ut.get_argflag('--production') PI = math.pi TAU = 2.0 * PI VIEWTEXT_TO_YAW_RADIANS = OrderedDict([ ( 'right', 0.000 * TAU, ), ( 'frontright', 0.125 * TAU, ), (
from __future__ import absolute_import, division, print_function from six.moves import zip, map import utool import plottool.draw_func2 as df2 from plottool import custom_constants #(print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[viz_img2]', DEBUG=False) utool.noinject(__name__, '[viz_img2]') def draw_chip_overlay(ax, bbox, theta, text, is_sel): """ Draw an annotation around a chip in the image """ lbl_alpha = .75 if is_sel else .6 bbox_alpha = .95 if is_sel else .6 lbl_color = custom_constants.BLACK * lbl_alpha bbox_color = (custom_constants.ORANGE if is_sel else custom_constants.DARK_ORANGE) * bbox_alpha df2.draw_bbox(bbox, text, bbox_color, lbl_color, theta=theta, ax=ax) def draw_image_overlay(ax, bbox_list=[], theta_list=None, text_list=None, sel_list=None, draw_lbls=True): if not draw_lbls: text_list = [''] * len(bbox_list) if theta_list is None: theta_list = [0] * len(bbox_list) if text_list is None: text_list = list(map(str, range(len(bbox_list)))) if sel_list is None: sel_list = [False] * len(bbox_list) # Draw all bboxes on top on image annotation_iter = zip(bbox_list, theta_list, text_list, sel_list) for bbox, theta, text, is_sel in annotation_iter:
from __future__ import absolute_import, division, print_function # Standard from itertools import product as iprod from six.moves import zip, range # Science import numpy as np # Matplotlib import matplotlib as mpl import utool as ut from plottool import color_funcs as color_fns # NOQA ut.noinject(__name__, '[pt.mpl_sift]') TAU = 2 * np.pi # References: tauday.com BLACK = np.array((0.0, 0.0, 0.0, 1.0)) RED = np.array((1.0, 0.0, 0.0, 1.0)) def testdata_sifts(): # make random sifts randstate = np.random.RandomState(1) sifts_float = randstate.rand(1, 128) sifts_float = sifts_float / np.linalg.norm(sifts_float) sifts_float[sifts_float > .2] = .2 sifts_float = sifts_float / np.linalg.norm(sifts_float) sifts = (sifts_float * 512).astype(np.uint8) return sifts def _cirlce_rad2xy(radians, mag): return np.cos(radians) * mag, np.sin(radians) * mag
from __future__ import absolute_import, division, print_function # Python # import atexit import sys from guitool.__PYQT__ import QtCore, QtGui from guitool.__PYQT__.QtCore import pyqtRemoveInputHook import utool # print, print_, printDBG, rrr, profile = utool.inject(__name__, '[guitool]', DEBUG=False) import utool as ut ut.noinject(__name__, "[guitool.main]", DEBUG=False) IS_ROOT_WINDOW = False QAPP = None VERBOSE = "--verbose" in sys.argv QUIET = "--quiet" in sys.argv def get_qtapp(): global QAPP return QAPP class GuitoolApplication(QtGui.QApplication): """ http://codeprogress.com/python/libraries/pyqt/showPyQTExample.php?index=378&key=QApplicationKeyPressGlobally """
# -*- coding: utf-8 -*- """ VTool - Computer vision tools """ # flake8: noqa from __future__ import absolute_import, division, print_function, unicode_literals __version__ = '1.0.1.dev1' import utool as ut ut.noinject(__name__, '[vtool]') """ python -c "import vtool" --dump-vtool-init python -c "import vtool" --update-vtool-init """ # TODO finish utoolifying this this IMPORT_TUPLES = [ ('image', None), ('histogram', None), ('image', None), ('exif', None), ('keypoint', None), ('features', None), ('linalg', None), ('patch', None), ('chip', None), ('spatial_verification', None), ('trig', None), ('math', None), ('matching', None), ('geometry', None),
#import sys #from ibeis.algo.hots import automated_oracle as ao #from ibeis.algo.hots import automated_helpers as ah #from ibeis.algo.hots import special_query * """ from __future__ import absolute_import, division, print_function import six from six.moves import builtins # NOQA import utool as ut from guitool.__PYQT__ import QtCore import guitool from ibeis.algo.hots import automated_matcher as automatch from ibeis.algo.hots import automated_helpers as ah # Can't inject print into this module otherwise bad things happen # with qt signals and slots ut.noinject(__name__, '[qtinc]') #print, print_, printDBG, rrr, profile = ut.inject(__name__, '[qtinc]') INC_LOOP_BASE = guitool.__PYQT__.QtCore.QObject def test_inc_query(ibs_gt, num_initial=0): """ entry point for interactive query tests test_interactive_incremental_queries Args: ibs (list) : IBEISController object qaid_list (list) : list of annotation-ids to query
from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtCore, QtGui import utool as ut ut.noinject(__name__, '[guitool.delegates]', DEBUG=False) class APIDelegate(QtGui.QItemDelegate): is_persistant_editable = True def __init__(self, parent): QtGui.QItemDelegate.__init__(self, parent) def sizeHint(option, qindex): # QStyleOptionViewItem option return QtCore.QSize(50, 50) class ImageDelegate(QtGui.QStyledItemDelegate): def __init__(self, parent): print(dir(self)) QtGui.QStyledItemDelegate.__init__(self, parent) def paint(self, painter, option, index): painter.fillRect(option.rect, QtGui.QColor(191, 222, 185)) # path = "path\to\my\image.jpg" self.path = "image.bmp" image = QtGui.QImage(str(self.path)) pixmap = QtGui.QPixmap.fromImage(image)
""" Known Interactions that use AbstractInteraction: pt.MatchInteraction2 pt.MultiImageInteraction ibeis.NameInteraction """ from __future__ import absolute_import, division, print_function from plottool import plot_helpers as ph from plottool import interact_helpers as ih import six import re import utool as ut import plottool.draw_func2 as df2 from plottool import fig_presenter import matplotlib as mpl ut.noinject(__name__, '[abstract_iteract]') #(print, print_, printDBG, rrr, profile) = utool.inject(__name__, #'[abstract_iteract]') DEBUG = ut.get_argflag('--debug-interact') # for scoping __REGISTERED_INTERACTIONS__ = [] def register_interaction(self): global __REGISTERED_INTERACTIONS__ if ut.VERBOSE: print('Registering intearction: self=%r' % (self,))
# -*- coding: utf-8 -*- from six.moves import zip from wbia.plottool import mpl_sift import numpy as np import matplotlib as mpl import utool as ut ut.noinject(__name__, '[pt.mpl_keypoint]') # TOOD: move to util def pass_props(dict1, dict2, *args): # Passes props from one kwargs dict to the next for key in args: if key in dict1: dict2[key] = dict1[key] def _draw_patches(ax, patch_list, color, alpha, lw, fcolor='none'): # creates a collection from a patch list and sets properties # print('new collecitn') # print(alpha) coll = mpl.collections.PatchCollection(patch_list) coll.set_facecolor(fcolor) coll.set_alpha(alpha) coll.set_linewidth(lw) coll.set_edgecolor(color) # coll.set_transform(ax.transData) ax.add_collection(coll)
from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtCore, QtGui from guitool.__PYQT__.QtCore import Qt import math import utool import six utool.noinject(__name__, "[StripProxyModel]", DEBUG=False) # STRIPE_PROXY_BASE = QtGui.QAbstractProxyModel # STRIPE_PROXY_BASE = QtGui.QSortFilterProxyModel STRIPE_PROXY_BASE = QtGui.QIdentityProxyModel STRIP_PROXY_META_CLASS = utool.makeForwardingMetaclass( lambda self: self.sourceModel(), [ "_set_context_id", "_get_context_id", "_set_changeblocked", "_get_changeblocked", "_about_to_change", "_change", "_update", "_rows_updated", "name", ], base_class=STRIPE_PROXY_BASE, ) STRIP_PROXY_SIX_BASE = six.with_metaclass(STRIP_PROXY_META_CLASS, STRIPE_PROXY_BASE)
# I'm not quite sure how to organize these functions yet from __future__ import absolute_import, division, print_function # Standard from six.moves import zip # Science import numpy as np import cv2 # Matplotlib import matplotlib.pyplot as plt # VTool import vtool.histogram as htool import utool as ut ut.noinject(__name__, '[pt.other]') def color_orimag(gori, gmag): # Turn a 0 to 1 orienation map into hsv colors gori_01 = (gori - gori.min()) / (gori.max() - gori.min()) cmap_ = plt.get_cmap('hsv') flat_rgb = np.array(cmap_(gori_01.flatten()), dtype=np.float32) rgb_ori_alpha = flat_rgb.reshape(np.hstack((gori.shape, [4]))) rgb_ori = cv2.cvtColor(rgb_ori_alpha, cv2.COLOR_RGBA2RGB) hsv_ori = cv2.cvtColor(rgb_ori, cv2.COLOR_RGB2HSV) # Desaturate colors based on magnitude hsv_ori[:, :, 1] = (gmag / 255.0) hsv_ori[:, :, 2] = (gmag / 255.0) # Convert back to bgr bgr_ori = cv2.cvtColor(hsv_ori, cv2.COLOR_HSV2RGB) return bgr_ori
#============================ # Python Interface #============================ from __future__ import absolute_import, division, print_function from os.path import join, realpath, dirname import cv2 import random import numpy as np import ctypes as C import sys import detecttools.ctypes_interface as ctypes_interface import utool as ut ut.noinject(__name__, '[pyrf_helpers]') def ensure_bytes_strings(str_list): # converts python3 strings into bytes if sys.hexversion > 0x03000000: return [str_ if not isinstance(str_, str) else bytes(str_, 'utf-8') for str_ in str_list] else: return str_list def _cast_list_to_c(py_list, dtype): """ Converts a python list of strings into a c array of strings References: http://stackoverflow.com/questions/3494598/passing-a-list-of-strings-to-from-python-ctypes-to-c-function-expecting-char Avi's code
# -*- coding: utf-8 -*- from wbia.guitool.__PYQT__ import QtCore from wbia.guitool.__PYQT__ import QtGui as QtWidgets # from wbia.guitool import guitool_components # (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[APIButtonWidget]', DEBUG=False) import utool as ut ut.noinject(__name__, '[api_timestamp_delegate]', DEBUG=False) DELEGATE_BASE = QtWidgets.QItemDelegate # DELEGATE_BASE = QtWidgets.QStyledItemDelegate class APITimestampDelegate(DELEGATE_BASE): def __init__(dgt, parent=None): assert parent is not None, 'parent must be a view' DELEGATE_BASE.__init__(dgt, parent) def paint(dgt, painter, option, qtindex): painter.save() data = qtindex.model().data(qtindex, QtCore.Qt.DisplayRole) print(data) painter.restore() # def editorEvent(dgt, event, model, option, qtindex): # event_type = event.type() # if event_type == QtCore.QEvent.MouseButtonPress: # # store the position that is clicked # dgt._pressed = (qtindex.row(), qtindex.column())
""" old code ported from utool """ from __future__ import absolute_import, division, print_function import sys import six import traceback from utool.Preferences import Pref, PrefNode, PrefChoice from guitool.__PYQT__ import QtCore, QtGui from guitool.__PYQT__ import QVariantHack from guitool.__PYQT__.QtCore import Qt, QAbstractItemModel, QModelIndex, QObject, pyqtSlot from guitool.__PYQT__.QtGui import QWidget from guitool import qtype import utool as ut from utool import util_type ut.noinject(__name__, '[PreferenceWidget]', DEBUG=False) VERBOSE_PREF = ut.get_argflag('--verbpref') def report_thread_error(fn): """ Decorator to help catch errors that QT wont report """ def report_thread_error_wrapper(*args, **kwargs): try: ret = fn(*args, **kwargs) return ret except Exception as ex: print('\n\n *!!* Thread Raised Exception: ' + str(ex)) print('\n\n *!!* Thread Exception Traceback: \n\n' + traceback.format_exc()) sys.stdout.flush() et, ei, tb = sys.exc_info()
# -*- coding: utf-8 -*- """ custom sqlite3 module that supports numpy types """ from __future__ import absolute_import, division, print_function import sys import six import io import uuid import numpy as np #from utool.util_inject import inject_print_functions #print, print_, printDBG = inject_print_functions(__name__, '[SQLITE3]', DEBUG=False) import utool as ut ut.noinject(__name__, '[ibeis.control.__SQLITE3__]', DEBUG=False) VERBOSE_SQL = '--veryverbose' in sys.argv or '--verbose' in sys.argv or '--verbsql' in sys.argv TRY_NEW_SQLITE3 = False # SQL This should be the only file which imports sqlite3 if not TRY_NEW_SQLITE3: from sqlite3 import * # NOQA #try: # # Try to import the correct version of sqlite3 # if VERBOSE_SQL: # from pysqlite2 import dbapi2 # import sqlite3 # print('dbapi2.sqlite_version = %r' % dbapi2.sqlite_version) # print('sqlite3.sqlite_version = %r' % sqlite3.sqlite_version) # print('using dbapi2 as lite')
# flake8: noqa from __future__ import absolute_import, print_function, division __version__ = '1.2' import utool as ut ut.noinject(__name__, '[pyhesaff.__init__]') from pyhesaff import ctypes_interface from pyhesaff import _pyhesaff from pyhesaff._pyhesaff import (DESC_DIM, HESAFF_CLIB, HESAFF_PARAM_DICT, HESAFF_PARAM_TYPES, HESAFF_TYPED_PARAMS, KPTS_DIM, adapt_scale, alloc_kpts, alloc_patches, alloc_vecs, argparse_hesaff_params, detect_feats, detect_feats2, detect_feats_in_image, detect_feats_list, detect_num_feats_in_image, extract_desc_from_patches, extract_patches, extract_vecs, get_cpp_version, get_hesaff_default_params, get_is_debug_mode, hesaff_kwargs_docstr_block, img32_dtype, test_rot_invar, vtool_adapt_rotation,) #from pyhesaff._pyhesaff import (extract_vecs, detect_feats, detect_feats_list, # adapt_scale, vtool_adapt_rotation, kpts_dtype, vecs_dtype, # get_hesaff_default_params, extract_desc_from_patches,
# flake8: noqa try: from wbia._version import __version__ except ImportError: __version__ = '0.0.0' try: import utool as ut from wbia import dtool except ImportError as ex: print('[wbia !!!] ERROR: Unable to load all core utility modules.') print('[wbia !!!] Perhaps try super_setup.py pull') raise ut.noinject(__name__, '[wbia.__init__]') if ut.VERBOSE: print('[wbia] importing wbia __init__') if ut.is_developer(): standard_visualization_functions = [ 'show_image', 'show_chip', 'show_chipmatch', 'show_chipmatches', 'show_vocabulary', #'show_vocabulary', ] # If we dont initialize plottool before <something> # then it causes a crash in windows. Its so freaking weird.
# -*- coding: utf-8 -*- # flake8:noqa # Wrapper around PyQt4/5 import utool as ut ut.noinject(__name__, '[__PYQT__.QtWidgets]') from . import _internal if _internal.GUITOOL_PYQT_VERSION == 4: # just a clone of QtGui in PyQt4 from PyQt4.QtGui import * else: from PyQt5.QtWidgets import *
# -*- coding: utf-8 -*- import functools from wbia.guitool.__PYQT__ import QtCore, QtGui # NOQA from wbia.guitool.__PYQT__.QtCore import Qt # NOQA import utool as ut from utool._internal import meta_util_six ut.noinject(__name__, '[guitool.decorators]', DEBUG=False) DEBUG = False signal_ = QtCore.pyqtSignal # SLOT DECORATOR def slot_(*types): # This is called at wrap time to get args """ wrapper around pyqtslot decorator keep original function info """ def pyqtSlotWrapper(func): # printDBG('[GUITOOL._SLOT] Wrapping: %r' % func.__name__) funcname = meta_util_six.get_funcname(func) @QtCore.pyqtSlot(*types, name=funcname) @ut.ignores_exc_tb def slot_wrapper(self, *args, **kwargs): result = func(self, *args, **kwargs) return result
import sys import textwrap import time #import warnings import utool as ut # maptlotlib import matplotlib as mpl #import matplotlib.pyplot as plt # Science from plottool.custom_figure import get_fig #from .custom_constants import golden_wh SLEEP_TIME = .05 __QT4_WINDOW_LIST__ = [] ut.noinject(__name__, '[fig_presenter]') VERBOSE = ut.get_argflag(('--verbose-fig', '--verbfig', '--verb-pt')) #(print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[fig_presenter]', DEBUG=True) def unregister_qt4_win(win): global __QT4_WINDOW_LIST__ if win == 'all': __QT4_WINDOW_LIST__ = [] else: try: #index = __QT4_WINDOW_LIST__.index(win) __QT4_WINDOW_LIST__.remove(win) except ValueError: pass
from __future__ import absolute_import, division, print_function import functools from guitool.__PYQT__ import QtCore, QtGui # NOQA from guitool.__PYQT__.QtCore import Qt # NOQA import utool as ut from utool._internal import meta_util_six ut.noinject(__name__, '[guitool.decorators]', DEBUG=False) DEBUG = False signal_ = QtCore.pyqtSignal # SLOT DECORATOR def slot_(*types): # This is called at wrap time to get args """ wrapper around pyqtslot decorator *args = types """ def pyqtSlotWrapper(func): #printDBG('[GUITOOL._SLOT] Wrapping: %r' % func.__name__) funcname = meta_util_six.get_funcname(func) @QtCore.pyqtSlot(*types, name=funcname) @ut.ignores_exc_tb def slot_wrapper(self, *args, **kwargs): result = func(self, *args, **kwargs) return result slot_wrapper = functools.update_wrapper(slot_wrapper, func) return slot_wrapper return pyqtSlotWrapper
# -*- coding: utf-8 -*- from wbia.guitool.__PYQT__ import QtGui, QtCore # NOQA from wbia.guitool.__PYQT__.QtCore import Qt import utool utool.noinject(__name__, '[APIItemView]', DEBUG=False) # BASE_CLASS = QtGui.QAbstractProxyModel try: BASE_CLASS = QtGui.QSortFilterProxyModel except Exception: BASE_CLASS = QtCore.QIdentityProxyModel # BASE_CLASS = QtGui.QIdentityProxyModel class FilterProxyModel(BASE_CLASS): __metaclass__ = utool.makeForwardingMetaclass( lambda self: self.sourceModel(), [ '_set_context_id', '_get_context_id', '_set_changeblocked', '_get_changeblocked', '_about_to_change', '_change', '_update', '_rows_updated', 'name', 'get_header_name', ], base_class=BASE_CLASS,
# -*- coding: utf-8 -*- from wbia.guitool.__PYQT__ import QtCore, QtGui from wbia.guitool.__PYQT__ import QtWidgets # NOQA import six import utool import sys import logging from six.moves import range from wbia.guitool.guitool_decorators import slot_ from wbia.guitool import guitool_main import utool as ut ut.noinject(__name__) # For some reason QtCore.Qt.ALT doesn't work right ALT_KEY = 16777251 def make_option_dict(options, shortcuts=True): """ helper for popup menu callbacks """ keys = ut.take_column(options, 0) values = ut.take_column(options, 1) if shortcuts: shortcut_keys = [ key[key.find('&') + 1] if '&' in key else None for key in keys ] try: ut.assert_unique(shortcut_keys, name='shortcut_keys', ignore=[None]) except AssertionError:
# -*- coding: utf-8 -*- from wbia.guitool.__PYQT__ import QtCore, QtGui from wbia.guitool.__PYQT__ import QtWidgets # NOQA from wbia.guitool.__PYQT__.QtCore import Qt import math import utool import six utool.noinject(__name__, '[StripProxyModel]', DEBUG=False) # STRIPE_PROXY_BASE = QtGui.QAbstractProxyModel # STRIPE_PROXY_BASE = QtGui.QSortFilterProxyModel try: STRIPE_PROXY_BASE = QtGui.QIdentityProxyModel except Exception: STRIPE_PROXY_BASE = QtCore.QIdentityProxyModel STRIP_PROXY_META_CLASS = utool.makeForwardingMetaclass( lambda self: self.sourceModel(), [ '_set_context_id', '_get_context_id', '_set_changeblocked', '_get_changeblocked', '_about_to_change', '_change', '_update', '_rows_updated', 'name', ],
# -*- coding: utf-8 -*- import utool as ut import six # import itertools from . import draw_func2 as df2 from wbia.plottool import plot_helpers as ph from wbia.plottool import custom_constants from wbia.plottool import custom_figure # (print, print_, printDBG, rrr, profile) = ut.inject( # __name__, '[viz_featrow]', DEBUG=False) ut.noinject(__name__, '[viz_featrow]') def precisionstr(c='E', pr=2): return '%.' + str(pr) + c def formatdist(val): pr = 3 if val > 1000: return precisionstr('E', pr) % val elif val > 0.01 or val == 0: return precisionstr('f', pr) % val else: return precisionstr('e', pr) % val # @ut.indent_func def draw_feat_row(chip,
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function #import utool #print, print_, printDBG, rrr, profile = utool.inject(__name__, '[hsexcept]', DEBUG=False) import utool as ut ut.noinject(__name__, '[hsecept]', DEBUG=False) class QueryException(Exception): def __init__(self, msg): super(QueryException, self).__init__(msg) def NoDescriptorsException(ibs, qaid): msg = ('QUERY ERROR IN %s: qaid=%r has no descriptors!' + 'Please delete it.') % (ibs.get_dbname(), qaid) ex = QueryException(msg) return ex class HotsCacheMissError(Exception): pass class HotsNeedsRecomputeError(Exception): pass
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import utool as ut ut.noinject(__name__, '[guiexcept]') class NeedsUserInput(Exception): def __init__(self, *args): super(Exception, self).__init__(*args) class UserCancel(Exception): def __init__(self, *args): super(Exception, self).__init__(*args) class InvalidRequest(Exception): def __init__(self, *args): super(Exception, self).__init__(*args)
# -*- coding: utf-8 -*- from wbia.guitool.__PYQT__ import QtGui, QtCore # NOQA from wbia.guitool.__PYQT__ import QtWidgets # NOQA from wbia.guitool import guitool_components import utool # (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[APIButtonWidget]', DEBUG=False) import utool as ut ut.noinject(__name__, '[api_button_delegate]', DEBUG=False) # DELEGATE_BASE = QtWidgets.QItemDelegate DELEGATE_BASE = QtWidgets.QStyledItemDelegate def rgb_to_qcolor(rgb): return QtGui.QColor(*rgb[0:3]) def rgb_to_qbrush(rgb): return QtGui.QBrush(rgb_to_qcolor(rgb)) def paint_button( painter, option, text='button', pressed=True, bgcolor=None, fgcolor=None, clicked=None,
* Remove self matches. * New SIFT parameters for pyhesaff (root, powerlaw, meanwhatever, output_dtype) TODO: This needs to be less constant when using non-sift descriptors Issues: * 10GB are in use when performing query on Oxford 5K * errors when there is a word without any database vectors. currently a weight of zero is hacked in """ from __future__ import absolute_import, division, print_function import numpy as np import utool as ut ut.noinject('[hstypes]') #INTEGER_TYPE = np.int32 #INDEX_TYPE = np.int32 #INDEX_TYPE = np.int64 # The index type should be the native sytem int, otherwise np.take will fail # due to the safe constraint. INDEX_TYPE = np.int_ #INTEGER_TYPE = np.int64 #INTEGER_TYPE = np.int32 INTEGER_TYPE = np.int64 #FLOAT_TYPE = np.float64 FLOAT_TYPE = np.float64 #FLOAT_TYPE = np.float32
# -*- coding: utf-8 -*- ### __init__.py ### # flake8: noqa import logging import utool as ut ut.noinject(__name__, '[wbia.control.__init__]', DEBUG=False) from wbia.control import DB_SCHEMA from wbia.control import IBEISControl from wbia.control import _sql_helpers from wbia.control import accessor_decors from wbia.control import controller_inject from wbia.control import docker_control import utool print, rrr, profile = utool.inject2(__name__) logger = logging.getLogger('wbia') def reload_subs(verbose=True): """ Reloads wbia.control and submodules """ rrr(verbose=verbose) getattr(DB_SCHEMA, 'rrr', lambda verbose: None)(verbose=verbose) getattr(IBEISControl, 'rrr', lambda verbose: None)(verbose=verbose) getattr(_sql_helpers, 'rrr', lambda verbose: None)(verbose=verbose) getattr(accessor_decors, 'rrr', lambda verbose: None)(verbose=verbose) getattr(controller_inject, 'rrr', lambda verbose: None)(verbose=verbose) getattr(docker_control, 'rrr', lambda verbose: None)(verbose=verbose)
# -*- coding: utf-8 -*- # flake8:noqa # Wrapper around PyQt4/5 import utool as ut ut.noinject(__name__, '[__PYQT__.QtTest]') from . import _internal if _internal.GUITOOL_PYQT_VERSION == 4: from PyQt4.QtTest import * else: from PyQt5.QtTest import *
from __future__ import absolute_import, division, print_function from six.moves import map from guitool.__PYQT__ import QtCore, QtGui # NOQA from guitool.__PYQT__.QtCore import Qt import os from os.path import dirname import platform from utool import util_cache, util_path import utool as ut ut.noinject(__name__, '[guitool.dialogs]', DEBUG=False) SELDIR_CACHEID = 'guitool_selected_directory' def _guitool_cache_write(key, val): """ Writes to global IBEIS cache """ util_cache.global_cache_write(key, val, appname='ibeis') # HACK, user should specify appname def _guitool_cache_read(key, **kwargs): """ Reads from global IBEIS cache """ return util_cache.global_cache_read(key, appname='ibeis', **kwargs) # HACK, user should specify appname def are_you_sure(parent=None, msg=None, title='Confirmation', default=None): """ Prompt user for conformation before changing something """ msg = 'Are you sure?' if msg is None else msg print('[gt] Asking User if sure') print('[gt] title = %s' % (title,)) print('[gt] msg =\n%s' % (msg,))
CommandLine: python -m wbia.plottool.draw_func2 --exec-imshow --show --mplbe=GTKAgg python -m wbia.plottool.draw_func2 --exec-imshow --show --mplbe=TkAgg python -m wbia.plottool.draw_func2 --exec-imshow --show --mplbe=WxAgg python -m wbia.plottool.draw_func2 --exec-imshow --show --mplbe=WebAgg python -m wbia.plottool.draw_func2 --exec-imshow --show --mplbe=gdk python -m wbia.plottool.draw_func2 --exec-imshow --show --mplbe=cairo """ import sys import os import utool as ut from six.moves import builtins ut.noinject(__name__, '[plottool.__MPL_INIT__]') try: profile = getattr(builtins, 'profile') except AttributeError: def profile(func): return func __IS_INITIALIZED__ = False __WHO_INITIALIZED__ = None VERBOSE_MPLINIT = ut.get_argflag(('--verb-mpl', '--verbose')) TARGET_BACKEND = ut.get_argval(
# -*- coding: utf-8 -*- from six.moves import map from wbia.guitool.__PYQT__ import QtCore, QtGui # NOQA from wbia.guitool.__PYQT__ import QtWidgets # NOQA from wbia.guitool.__PYQT__.QtCore import Qt import os from os.path import dirname import platform from utool import util_cache, util_path import utool as ut ut.noinject(__name__, '[guitool.dialogs]', DEBUG=False) SELDIR_CACHEID = 'guitool_selected_directory' def _guitool_cache_write(key, val): """ Writes to global IBEIS cache """ util_cache.global_cache_write( key, val, appname='wbia' ) # HACK, user should specify appname def _guitool_cache_read(key, **kwargs): """ Reads from global IBEIS cache """ return util_cache.global_cache_read( key, appname='wbia', **kwargs ) # HACK, user should specify appname
# flake8: noqa from __future__ import absolute_import, division, print_function import sys import utool as ut ut.noinject(__name__, '[cyth.__init__]') __version__ = '1.0.0.dev1' from cyth.cyth_args import WITH_CYTH, CYTH_WRITE, DYNAMIC from cyth.cyth_importer import import_cyth_execstr from cyth.cyth_script import translate, translate_all from cyth.cyth_decorators import macro from cyth import cyth_helpers from cyth import cyth_importer from cyth import cyth_decorators from cyth import cyth_macros ''' Cyth: * Create Cyth, to cythonize the code, make it faster annotate variable names with types in a scoped comment then type the variable names * Cythonize spatial verification and other parts of vtool * Cythonize matching_functions Cyth Technical Description:
# -*- coding: utf-8 -*- ### __init__.py ### # flake8: noqa from __future__ import absolute_import, division, print_function import utool as ut ut.noinject(__name__, "[ibeis.control.__init__]", DEBUG=False) from ibeis.control import DB_SCHEMA from ibeis.control import IBEISControl from ibeis.control import _sql_helpers from ibeis.control import accessor_decors import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, "[ibeis.control]") def reload_subs(verbose=True): """ Reloads ibeis.control and submodules """ rrr(verbose=verbose) getattr(DB_SCHEMA, "rrr", lambda verbose: None)(verbose=verbose) getattr(IBEISControl, "rrr", lambda verbose: None)(verbose=verbose) getattr(SQLDatabaseControl, "rrr", lambda verbose: None)(verbose=verbose) getattr(_sql_helpers, "rrr", lambda verbose: None)(verbose=verbose) getattr(accessor_decors, "rrr", lambda verbose: None)(verbose=verbose) rrr(verbose=verbose) rrrr = reload_subs
### __init__.py ### # flake8: noqa from __future__ import absolute_import, division, print_function import utool as ut ut.noinject(__name__, '[ibeis_cnn.__init__]') from ibeis_cnn import __THEANO__ from ibeis_cnn import __LASAGNE__ from ibeis_cnn import models from ibeis_cnn import process from ibeis_cnn import netrun from ibeis_cnn import utils from ibeis_cnn import theano_ext #from ibeis_cnn import _plugin print, print_, profile = ut.inject2(__name__, '[ibeis_cnn]') __version__ = '1.0.0.dev1' def reassign_submodule_attributes(verbose=True): """ why reloading all the modules doesnt do this I don't know """ import sys if verbose and '--quiet' not in sys.argv: print('dev reimport') # Self import import ibeis_cnn # Implicit reassignment. seen_ = set([]) for tup in IMPORT_TUPLES: if len(tup) > 2 and tup[2]:
from __future__ import absolute_import, division, print_function from plottool import custom_figure import utool as ut #(print, print_, printDBG, rrr, profile) = utool.inject(__name__, # '[interact_helpers]', # DEBUG=False) ut.noinject(__name__, '[interact_helpers]') #========================== # HELPERS #========================== # RCOS TODO: We should change the fnum, pnum figure layout into one managed by # gridspec. def detect_keypress(fig): def on_key_press(event): if event.key == 'shift': shift_is_held = True # NOQA def on_key_release(event): if event.key == 'shift': shift_is_held = False # NOQA fig.canvas.mpl_connect('key_press_event', on_key_press) fig.canvas.mpl_connect('key_release_event', on_key_release) def clicked_inside_axis(event): in_axis = event is not None and (event.inaxes is not None
from __future__ import absolute_import, division, print_function import numpy as np import plottool.draw_func2 as df2 from plottool import fig_presenter #from plottool import custom_figure #from plottool import custom_constants #from os.path import join import utool as ut ut.noinject(__name__, '[plot_helpers]') #(print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[plot_helpers]', DEBUG=False) SIFT_OR_VECFIELD = ut.get_argval('--vecfield', type_=bool) def draw(): df2.adjust_subplots_safe() fig_presenter.draw() #def dump_figure(dumpdir, subdir=None, quality=False, overwrite=False, verbose=2, # reset=True): # """ Dumps figure to disk based on the figurename """ # if quality is True: # custom_constants.FIGSIZE = custom_constants.golden_wh2(14) # #custom_constants.DPI = 120 # custom_constants.DPI = 120 # #custom_constants.FIGSIZE = custom_constants.golden_wh2(12) # #custom_constants.DPI = 120 # custom_constants.FONTS.figtitle = custom_constants.FONTS.small # elif quality is False: