当前位置: 首页>>代码示例>>Python>>正文


Python utool.noinject函数代码示例

本文整理汇总了Python中utool.noinject函数的典型用法代码示例。如果您正苦于以下问题:Python noinject函数的具体用法?Python noinject怎么用?Python noinject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了noinject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: color_orimag

# 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

开发者ID:Erotemic,项目名称:plottool,代码行数:29,代码来源:other.py

示例2: read_thumb_size

"""
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
开发者ID:Erotemic,项目名称:guitool,代码行数:31,代码来源:api_thumb_delegate.py

示例3:

# 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 *
开发者ID:WildbookOrg,项目名称:pyrf,代码行数:10,代码来源:__init__.py

示例4: slot_

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
开发者ID:Erotemic,项目名称:guitool,代码行数:31,代码来源:guitool_decorators.py

示例5: testdata_sifts

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
开发者ID:Erotemic,项目名称:plottool,代码行数:31,代码来源:mpl_sift.py

示例6:

# 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:
开发者ID:aweinstock314,项目名称:cyth,代码行数:30,代码来源:__init__.py

示例7: inject_print_functions

# -*- 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')
开发者ID:Erotemic,项目名称:ibeis,代码行数:31,代码来源:__SQLITE3__.py

示例8:

# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

import utool as ut

ut.noinject(__name__, "[ibeis.tests.__init__]", DEBUG=False)
开发者ID:Erotemic,项目名称:ibeis,代码行数:6,代码来源:__init__.py

示例9: MultiImageInteraction

#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
开发者ID:Erotemic,项目名称:plottool,代码行数:31,代码来源:interact_multi_image.py

示例10: print_all_backends


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',
开发者ID:Erotemic,项目名称:plottool,代码行数:29,代码来源:__MPL_INIT__.py

示例11: FilterProxyModel

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
开发者ID:Erotemic,项目名称:guitool,代码行数:31,代码来源:filter_proxy_model.py

示例12: get_recognition_query_aids

# -*- 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
开发者ID:Erotemic,项目名称:ibeis,代码行数:30,代码来源:apis_query.py

示例13: _test_base01

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())
开发者ID:Erotemic,项目名称:plottool,代码行数:30,代码来源:color_funcs.py

示例14: APIDelegate

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)
开发者ID:Erotemic,项目名称:guitool,代码行数:31,代码来源:guitool_delegates.py

示例15: report_thread_error

"""
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()
开发者ID:Erotemic,项目名称:guitool,代码行数:31,代码来源:PreferenceWidget.py


注:本文中的utool.noinject函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。