本文整理汇总了Python中pyTuttle.tuttle.core函数的典型用法代码示例。如果您正苦于以下问题:Python core函数的具体用法?Python core怎么用?Python core使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了core函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateThumbnail
def generateThumbnail(imgFile):
from pyTuttle import tuttle
tuttle.core().preload(False)
tuttle.compute([
tuttle.NodeInit( "tuttle.pngreader", filename=imgFile),
tuttle.NodeInit( "tuttle.resize", width=256, keepRatio=1),
tuttle.NodeInit( "tuttle.pngwriter", filename=imgFile + "-thumbnail"),
])
示例2: configLocalPluginPath
def configLocalPluginPath(ofxPluginPaths):
tuttle.core().getPluginCache().addDirectoryToPath(globalOfxPluginPath)
for ofxPluginPath in ofxPluginPaths:
logging.info("ofxPluginPath:" + str(ofxPluginPath))
tuttle.core().getPluginCache().addDirectoryToPath(str(ofxPluginPath))
pluginCache = tuttle.core().getPluginCache()
tuttle.core().getFormatter().setLogLevel_int(5)
tuttle.core().preload(False)
logging.debug('Number of Plugins:' + str(len(pluginCache.getPlugins())))
示例3: testSimpleProcessGraph
def testSimpleProcessGraph():
graph = tuttle.Graph()
n = [
tuttle.NodeInit( "tuttle.exrreader", filename="TuttleOFX-data/image/openexr/DisplayWindow/t##.exr" ),
tuttle.NodeInit( "tuttle.invert" ),
tuttle.NodeInit( "tuttle.gamma", master=.5 ),
tuttle.NodeInit( "tuttle.jpegwriter", filename=".tests/fromExr/output-####.jpg" ),
]
nodes = graph.addConnectedNodes(n)
procOptions = tuttle.ComputeOptions()
procGraph = tuttle.ProcessGraph(procOptions, graph, [], tuttle.core().getMemoryCache())
print("before compute")
outputCache = tuttle.MemoryCache()
timeRange = tuttle.TimeRange(1, 16, 10)
print("setup")
procGraph.setup()
print("beginSequence")
procGraph.beginSequence(timeRange)
for time in range(timeRange._begin, timeRange._end, timeRange._step):
print("time:", time)
procGraph.setupAtTime(time)
procGraph.processAtTime(outputCache, time)
print("endSequence")
procGraph.endSequence()
print("after compute")
示例4: testBrowsePlugins
def testBrowsePlugins():
pluginCache = tuttle.core().getPluginCache()
pluginPath = pluginCache.getPluginPath()
print([p for p in pluginPath])
# print([p for p in pluginCache.getPluginPath()]) # BUG binding: TODO
print([p.getIdentifier() for p in pluginCache.getPlugins()])
示例5: _displayFileFormats
def _displayFileFormats(self):
"""
Display all supported input/output file formats.
"""
def getListOfSupportedExtension(ofxhImageEffectNodeDescriptor):
"""
Return list of supported extension from a given plugin descriptor.
"""
propSupportedExtension = ofxhImageEffectNodeDescriptor.getParamSetProps().fetchProperty('TuttleOfxImageEffectPropSupportedExtensions')
return samUtils.getListValues(propSupportedExtension)
supportedExtensions = {'r': [], 'w': []}
for plugin in tuttle.core().getImageEffectPluginCache().getPlugins():
try:
plugin.loadAndDescribeActions()
if plugin.supportsContext('OfxImageEffectContextReader'):
pluginDescriptor = plugin.getDescriptorInContext('OfxImageEffectContextReader')
if pluginDescriptor.getParamSetProps().hasProperty('TuttleOfxImageEffectPropSupportedExtensions'):
supportedExtensions['r'].extend(getListOfSupportedExtension(pluginDescriptor))
elif plugin.supportsContext('OfxImageEffectContextWriter'):
pluginDescriptor = plugin.getDescriptorInContext('OfxImageEffectContextWriter')
if pluginDescriptor.getParamSetProps().hasProperty('TuttleOfxImageEffectPropSupportedExtensions'):
supportedExtensions['w'].extend(getListOfSupportedExtension(pluginDescriptor))
except Exception as e:
self.logger.warning('Cannot load and describe plugin "' + plugin.getIdentifier() + '".')
self.logger.debug(e)
for key, extensions in supportedExtensions.items():
if key == 'r':
self._displayTitle('SUPPORTED INPUT FILE FORMATS')
elif key == 'w':
self._displayTitle('SUPPORTED OUTPUT FILE FORMATS')
puts(', '.join(sorted(set(extensions))))
示例6: testBrowseIEPlugins
def testBrowseIEPlugins():
pluginCache = tuttle.core().getImageEffectPluginCache()
print([p.getDescriptor().getShortLabel() for p in pluginCache.getPlugins()])
print([p.getDescriptor().getLabel() for p in pluginCache.getPlugins()])
print([p.getDescriptor().getLongLabel() for p in pluginCache.getPlugins()])
print([p.getDescriptor().getPluginGrouping() for p in pluginCache.getPlugins()])
示例7: _displayPlugins
def _displayPlugins(self):
"""
Display all available plugins (in alphabetical order), with their versions (v[major].[minor]).
"""
plugins = []
for plugin in tuttle.core().getPlugins():
plugins.append(plugin.getIdentifier().ljust(30) + ' (v' + str(plugin.getVersionMajor()) + '.' + str(plugin.getVersionMinor()) + ')')
for plugin in sorted(set(plugins)):
puts(plugin)
示例8: samDoCompleter
def samDoCompleter(prefix, parsed_args, **kwargs):
"""
Custom Completer to manage auto competion when looking for openFX nodes.
@warning The autocompletion works only for TuttleOFX plugins.
"""
# preload OFX plugins (to have auto completion of plugins name, their parameters...)
tuttle.core().preload(True)
# get plugins
pluginsId = tuttle.core().getImageEffectPluginCache().getPluginsByID()
pluginsStr = [str(id).replace('tuttle.', '') for id in pluginsId]
# check last input in command line
if len(parsed_args.inputs):
lastInput = parsed_args.inputs[-1]
# if last input is a plugin, return its parameters
if lastInput in pluginsStr:
graph = tuttle.Graph()
node = graph.createNode('tuttle.'+lastInput)
params = node.getParams()
paramsStr = [str(param.getScriptName()) for param in params]
return paramsStr
elif lastInput == '//':
return pluginsStr
else:
for input in reversed(parsed_args.inputs):
# if an input is a plugin, get its parameters
if input in pluginsStr:
graph = tuttle.Graph()
node = graph.createNode('tuttle.'+input)
params = node.getParams()
paramsStr = [str(param.getScriptName()) for param in params]
# if last input is one of its parameters, return its choices
if lastInput in paramsStr:
param = node.getParam(lastInput)
if param.getProperties().hasProperty('OfxParamPropChoiceOption'):
propChoiceOption = param.getProperties().fetchProperty('OfxParamPropChoiceOption')
choicesStr = samUtils.getListValues(propChoiceOption)
return choicesStr
# else, return its parameters
else:
return paramsStr
# else return available plugins
return pluginsStr
示例9: analyse
def analyse(pluginPath):
'''
Analyse the bundle an return a description for each plugin.
'''
pluginCache = tuttle.core().getPluginCache()
pluginCache.addDirectoryToPath(str(pluginPath))
tuttle.core().getFormatter().setLogLevel_int(5)
tuttle.core().preload(False)
plugins = pluginCache.getPlugins()
logging.warning('pluginCache: %s' % pluginCache)
logging.warning('Analyse plugins: %s' % pluginPath)
logging.warning('Nb plugins: %s' % len(plugins))
pluginsDescription = {'plugins':[], 'total': len(plugins)}
for currentPlugin in plugins:
logging.warning(currentPlugin.getRawIdentifier())
p = Plugin.Plugin(currentPlugin)
pluginsDescription['plugins'].append(p.__dict__)
return pluginsDescription
示例10: testPluginDescProps
def testPluginDescProps():
"""
Test the 'SupportedExtensions' and 'Evaluation' properties of plugins pluginTurboJpeg and pluginImageMagick.
"""
# test evaluation for pluginTurboJpeg
turboJpeg_plugin = tuttle.core().getImageEffectPluginCache().getPluginByLabel("TuttleTurboJpegReader")
turboJpeg_plugin.loadAndDescribeActions()
turboJpeg_desc = turboJpeg_plugin.getDescriptor()
assert turboJpeg_desc.getProperties().hasProperty("TuttleOfxImageEffectPropSupportedExtensions", True)
assert turboJpeg_desc.getProperties().hasProperty("TuttleOfxImageEffectPropEvaluation", True)
turboJpeg_evaluation = turboJpeg_desc.getProperties().getDoubleProperty("TuttleOfxImageEffectPropEvaluation")
assert_equal(turboJpeg_evaluation, 90)
# test evaluation for pluginImageMagick
imageMagick_plugin = tuttle.core().getImageEffectPluginCache().getPluginByLabel("TuttleImageMagickReader")
imageMagick_plugin.loadAndDescribeActions()
imageMagick_desc = imageMagick_plugin.getDescriptor()
assert imageMagick_desc.getProperties().hasProperty("TuttleOfxImageEffectPropSupportedExtensions", True)
assert imageMagick_desc.getProperties().hasProperty("TuttleOfxImageEffectPropEvaluation", True)
imageMagick_evaluation = imageMagick_desc.getProperties().getDoubleProperty("TuttleOfxImageEffectPropEvaluation")
assert_equal(imageMagick_evaluation, 0)
示例11: getPluginName
def getPluginName(self, logger):
"""
Return complete node name from the pluginId and its arguments.
Plugin's arguments can be used to get best reader/writer.
@note Get best reader if the given name is 'r'.
@note Get best writer if the given name is 'w'.
@exception if cannot find the plugin name which corresponds to the plugin id
"""
if self.isGenericReader() or self.isGenericWriter():
if len(self._arguments) == 0:
logger.warning('Cannot guess the best reader/writer node without any filename specified.')
# get filename
filename = self._arguments[0][1]
# return best reader
if self.isGenericReader():
bestReader = tuttle.getBestReader(filename)
logger.info('Use "' + bestReader + '" to read "' + filename + '".')
return bestReader
# return best writer
elif self.isGenericWriter():
bestWriter = tuttle.getBestWriter(filename)
logger.info('Use "' + bestWriter + '" to write "' + filename + '".')
return bestWriter
else:
pluginsMap = tuttle.core().getImageEffectPluginCache().getPluginsByID()
# get plugins name which match with the given id
pluginNames = []
for pluginName in pluginsMap:
# if the given id exactly matches the plugin id
# plugin id = plugin name without its group
if self._pluginId == pluginName[pluginName.rfind('.') + 1:]:
return pluginName
# else if the given id is contains in the plugin name
elif self._pluginId in pluginName:
pluginNames.append(pluginName)
# one plugin matches
if len(pluginNames) == 1:
return pluginNames[0]
# more than one matches
elif len(pluginNames) > 1:
logger.warning('Cannot guess the best match for plugin name "' + self._pluginId +'".')
logger.warning('Possible choices are: "' + ', '.join(pluginNames) +'".')
# cannot find a best reader/writer or no plugin name matches with the id
raise RuntimeError('Plugin with id "' + self._pluginId + '" not found.')
示例12: setUp
def setUp():
tuttle.core().preload(False)
示例13: getImage
from pyTuttle import tuttle
import numpy
import Image
# This is called by Tuttle as an input of the graph
def getImage(time):
img = numpy.asarray( Image.open("data/input.jpg") )
img = numpy.flipud(img)
return (img.tostring(), img.shape[1], img.shape[0], img.strides[0])
tuttle.core().preload()
g = tuttle.Graph()
ib = g.createInputBuffer()
ib.setComponents( tuttle.InputBufferWrapper.ePixelComponentRGB );
ib.setBitDepth( tuttle.InputBufferWrapper.eBitDepthUByte );
ib.setOrientation( tuttle.InputBufferWrapper.eImageOrientationFromTopToBottom );
ib.setPyCallback( getImage )
w = g.createNode("tuttle.pngwriter", filename="foo.png")
g.connect( ib.getNode(), w )
g.compute( w )
示例14: setUp
def setUp():
print "testComputeTime setUp"
tuttle.core().preload(False)
示例15: getPluginsIdentifiersAsDictionary
def getPluginsIdentifiersAsDictionary():
"""
Returns a dictionary of what we need to display the menu of the node creation.
For each level in the menu we need to have the list of items of the submenu
When the items are plugins, we need to know their label to display, and their identifier to be able to create the node.
So this dictionary returns a tuple :
- if it's a plugin, the tuple is : (pluginLabel, pluginIdentifier)
- if i's a category of plugins, the tuple is : (categoryLabel, "")
The keys of this dictionary are the "paths" of each element of the menu.
Example :
pluginsIdentifiersAsDictionary["buttle/tuttle/"] = ['image', 'param']
pluginsIdentifiersAsDictionary["buttle/tuttle/image/"] = ['io', 'process', 'generator', 'display', 'tool']
pluginsIdentifiersAsDictionary["buttle/tuttle/image/tool/"] = ['tuttle.dummy']
"""
# root label : parent of all plugins
buttleLabel = "buttle/"
# list of all Tuttle's plugins
pluginCache = tuttle.core().getImageEffectPluginCache()
plugins = pluginCache.getPlugins()
# Creation of the dictionary
pluginsIdentifiersAsDictionary = dict()
# if no plugin found we just add the "buttle" key with a message for the user
if len(plugins) == 0:
pluginsIdentifiersAsDictionary[buttleLabel] = []
pluginsIdentifiersAsDictionary[buttleLabel].append(('Error : no plugin found...', False))
return pluginsIdentifiersAsDictionary
for plugin in plugins:
pluginId = plugin.getIdentifier()
# All plugin labels in Tuttle are preceded by 'Tuttle', so we can delete 'Tuttle' from the beginning of the word. It doesn't affect other plugins, not preceded by 'Tuttle'.
pluginLabel = plugin.getDescriptor().getLabel().replace('Tuttle', '', 1)
# We take the path of the plugin's parents (ex: 'tuttle/image/process/')
fullPath = plugin.getDescriptor().getPluginGrouping()
# We split this path to have a list of parents
parentList = None
if fullPath.startswith(' '):
parentList = fullPath[1:].split(' ')
else:
parentList = fullPath.split('/')
# parentLabel is the parentPath of each element of this nex list of parents
parentLabel = buttleLabel
# We browse this list of parents. For each element, we want to create a new entry in the dictionary.
for i in range(len(parentList) + 1):
# only if this parentLabel is not yet in the dictionary, we create a new list for this entry in the dictionary.
if parentLabel not in pluginsIdentifiersAsDictionary:
# if we are not yet at the end of the parentList, then we append the next parent
if i < len(parentList):
pluginsIdentifiersAsDictionary[parentLabel] = []
pluginsIdentifiersAsDictionary[parentLabel].append((parentList[i], ""))
# but if we are at the end of the parentList, then the child is the plugin itself, so we add its identifier.
else:
pluginsIdentifiersAsDictionary[parentLabel] = []
pluginsIdentifiersAsDictionary[parentLabel].append((pluginLabel, pluginId))
# same reasoning, but here the parentLabel is already in the dictionary, we just append the child and not create a new list.
else:
if i < len(parentList):
if parentList[i] not in [p[0] for p in pluginsIdentifiersAsDictionary[parentLabel]]:
pluginsIdentifiersAsDictionary[parentLabel].append((parentList[i], ""))
else:
if pluginId not in [p[1] for p in pluginsIdentifiersAsDictionary[parentLabel]]:
pluginsIdentifiersAsDictionary[parentLabel].append((pluginLabel, pluginId))
# We have created the right entry for this element, and we want to create a new one at the next iteration. So we update the parentLabel for this entry.
if i < len(parentList):
parentLabel = parentLabel + parentList[i] + "/"
# Here we are !
return pluginsIdentifiersAsDictionary