本文整理汇总了Python中GafferImageTest类的典型用法代码示例。如果您正苦于以下问题:Python GafferImageTest类的具体用法?Python GafferImageTest怎么用?Python GafferImageTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GafferImageTest类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testShaderNetworkGeneratedInGlobalContext
def testShaderNetworkGeneratedInGlobalContext( self ) :
constant = GafferImage.Constant()
outLayer = GafferOSL.OSLCode()
outLayer["out"]["layer"] = GafferOSL.ClosurePlug(
direction = Gaffer.Plug.Direction.Out,
flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic
)
outLayer["code"].setValue( 'layer = outLayer( "", color( 0, 1, 0) )' )
outImage = GafferOSL.OSLShader()
outImage.loadShader( "ImageProcessing/OutImage" )
outImage["parameters"]["in0"].setInput( outLayer["out"]["layer"] )
oslImage = GafferOSL.OSLImage()
oslImage["in"].setInput( constant["out"] )
oslImage["shader"].setInput( outImage["out"] )
with Gaffer.ContextMonitor( outImage) as cm :
GafferImageTest.processTiles( oslImage["out"] )
cs = cm.combinedStatistics()
self.assertEqual( cs.numUniqueContexts(), 1 )
self.assertNotIn( "image:tileOrigin", cs.variableNames() )
self.assertNotIn( "image:channelName", cs.variableNames() )
示例2: __writeImage
def __writeImage( self, script, args ) :
import GafferImage
import GafferImageTest
image = script.descendant( args["image"].value )
if isinstance( image, Gaffer.Node ) :
image = next( ( x for x in image.children( GafferImage.ImagePlug ) ), None )
if image is None :
IECore.msg( IECore.Msg.Level.Error, "stats", "Image \"%s\" does not exist" % args["image"].value )
return
if args["preCache"].value :
GafferImageTest.processTiles( image )
memory = _Memory.maxRSS()
with _Timer() as imageTimer :
with self.__performanceMonitor or _NullContextManager(), self.__contextMonitor or _NullContextManager() :
GafferImageTest.processTiles( image )
self.__timers["Image generation"] = imageTimer
self.__memory["Image generation"] = _Memory.maxRSS() - memory
self.__memory["OIIO cache limit"] = _Memory( GafferImage.OpenImageIOReader.getCacheMemoryLimit() )
self.__memory["OIIO cache usage"] = _Memory( GafferImage.OpenImageIOReader.cacheMemoryUsage() )
items = [
( "Format", image["format"].getValue() ),
( "Data window", image["dataWindow"].getValue() ),
( "Channel names", image["channelNames"].getValue() ),
]
self.__output.write( "\nImage :\n\n" )
self.__writeItems( items )
示例3: __printImage
def __printImage( self, script, args ) :
import GafferImage
import GafferImageTest
image = script.descendant( args["image"].value )
if isinstance( image, Gaffer.Node ) :
image = next( ( x for x in image.children( GafferImage.ImagePlug ) ), None )
if image is None :
IECore.msg( IECore.Msg.Level.Error, "stats", "Image \"%s\" does not exist" % args["image"].value )
return
memory = _Memory.maxRSS()
with _Timer() as sceneTimer :
with self.__performanceMonitor or _NullContextManager() :
GafferImageTest.processTiles( image )
self.__timers["Image generation"] = sceneTimer
self.__memory["Image generation"] = _Memory.maxRSS() - memory
items = [
( "Format", image["format"].getValue() ),
( "Data window", image["dataWindow"].getValue() ),
( "Channel names", image["channelNames"].getValue() ),
]
print "\nImage :\n"
self.__printItems( items )
示例4: testCancellation
def testCancellation( self ) :
c = GafferImage.Constant()
r = GafferImage.Resample()
r["in"].setInput( c["out"] )
r["filterScale"].setValue( imath.V2f( 2000 ) )
bt = Gaffer.ParallelAlgo.callOnBackgroundThread( r["out"], lambda : GafferImageTest.processTiles( r["out"] ) )
# Give background tasks time to get into full swing
time.sleep( 0.1 )
# Check that we can cancel them in reasonable time
acceptableCancellationDelay = 0.25 if "TRAVIS" not in os.environ else 4.0
t = time.time()
bt.cancelAndWait()
self.assertLess( time.time() - t, acceptableCancellationDelay )
# Check that we can do the same when using a non-separable filter
r["filter"].setValue( "disk" )
bt = Gaffer.ParallelAlgo.callOnBackgroundThread( r["out"], lambda : GafferImageTest.processTiles( r["out"] ) )
time.sleep( 0.1 )
t = time.time()
bt.cancelAndWait()
self.assertLess( time.time() - t, acceptableCancellationDelay )
示例5: testParallelProcessEmptyDataWindow
def testParallelProcessEmptyDataWindow( self ) :
d = GafferImage.Display()
self.assertEqual( d["out"]["dataWindow"].getValue(), imath.Box2i() )
GafferImageTest.processTiles( d["out"] )
d["out"].image()
d["out"].imageHash()
示例6: testSamplerBoundsViolationCrash
def testSamplerBoundsViolationCrash( self ) :
c = GafferImage.Constant()
c["format"].setValue( GafferImage.Format( 3792, 3160 ) )
r = GafferImage.Resize()
r["in"].setInput( c["out"] )
r["format"].setValue( GafferImage.Format( 1920, 1080 ) )
r["fitMode"].setValue( r.FitMode.Vertical )
GafferImageTest.processTiles( r["out"] )
示例7: testGILManagement
def testGILManagement( self ) :
# Make a network where a Catalogue
# is merged with an image that depends
# on a python expression.
s = Gaffer.ScriptNode()
s["catalogue"] = GafferImage.Catalogue()
s["constant"] = GafferImage.Constant()
s["expression"] = Gaffer.Expression()
s["expression"].setExpression( 'parent["constant"]["color"]["r"] = context["image:tileOrigin"].x' )
s["merge"] = GafferImage.Merge()
s["merge"]["in"][0].setInput( s["catalogue"]["out"] )
s["merge"]["in"][1].setInput( s["constant"]["out"] )
# Arrange to generate the resulting image from C++
# threads whenever it is dirtied.
processTilesConnection = Gaffer.ScopedConnection( GafferImageTest.connectProcessTilesToPlugDirtiedSignal( s["merge"]["out"] ) )
# Send an image to the catalogue to demonstrate that
# we do not deadlock on the GIL.
r = GafferImage.ImageReader()
r["fileName"].setValue( "${GAFFER_ROOT}/python/GafferImageTest/images/checker.exr" )
self.sendImage( r["out"], s["catalogue"] )
示例8: testDownsizingSamplerBounds
def testDownsizingSamplerBounds( self ) :
c = GafferImage.Constant()
c["format"].setValue( GafferImage.Format( 50, 53 ) )
r = GafferImage.Resize()
r["in"].setInput( c["out"] )
r["fitMode"].setValue( r.FitMode.Distort )
# Downsize to every single size smaller than the input,
# to check for sampler bounds violations similar to those
# which motivated the test above.
for width in range( 1, 50 ) :
for height in range( 1, 53 ) :
r["format"].setValue( GafferImage.Format( width, height ) )
GafferImageTest.processTiles( r["out"] )
示例9: testNegativeDataWindowOrigin
def testNegativeDataWindowOrigin( self ) :
reader = GafferImage.ImageReader()
reader["fileName"].setValue( os.path.dirname( __file__ ) + "/images/checker.exr" )
constant = GafferImage.Constant()
constant["color"].setValue( imath.Color4f( 0.5, 0, 0, 1 ) )
offset = GafferImage.Offset()
offset["in"].setInput( constant["out"] )
offset["offset"].setValue( imath.V2i( -200, -250 ) )
vectorWarp = GafferImage.VectorWarp()
vectorWarp["in"].setInput( reader["out"] )
vectorWarp["vector"].setInput( offset["out"] )
GafferImageTest.processTiles( vectorWarp["out"] )
示例10: testCrashWithResizedInput
def testCrashWithResizedInput( self ) :
b = GafferImage.Constant()
b["format"].setValue( GafferImage.Format( 2048, 1556 ) )
bResized = GafferImage.Resize()
bResized["in"].setInput( b["out"] )
bResized["format"].setValue( GafferImage.Format( 1920, 1080 ) )
bResized["fitMode"].setValue( bResized.FitMode.Fit )
a = GafferImage.Constant()
a["format"].setValue( GafferImage.Format( 1920, 1080 ) )
merge = GafferImage.Merge()
merge["operation"].setValue( merge.Operation.Over )
merge["in"][0].setInput( bResized["out"] )
merge["in"][1].setInput( a["out"] )
GafferImageTest.processTiles( merge["out"] )
示例11: testOIIOExrRead
def testOIIOExrRead( self ) :
# call through to c++ test.
GafferImageTest.testOIIOExrRead()
示例12: computeImage
def computeImage() :
with self.__context( script, args ) as context :
for frame in self.__frames( script, args ) :
context.setFrame( frame )
GafferImageTest.processTiles( image )
示例13: processer
def processer() :
try :
GafferImageTest.processTiles( g["out"] )
except Exception, e :
exceptions.append( e )