예제 #1
0
	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() :
				with Gaffer.Context( script.context() ) as context :
					for frame in self.__frames( script, args ) :
						context.setFrame( frame )
						GafferImageTest.processTiles( image )

		self.__timers["Image generation"] = imageTimer
		self.__memory["Image generation"] = _Memory.maxRSS() - memory

		items = [
			( "Format", image["format"].getValue() ),
			( "Data window", image["dataWindow"].getValue() ),
			( "Channel names", image["channelNames"].getValue() ),
		]

		self.__output.write( "\nImage :\n\n" )
		self.__writeItems( items )
예제 #2
0
	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
0
	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
0
    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
0
    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"]["out"])

        with Gaffer.ContextMonitor(oslImage["__oslCode"]) 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())
예제 #6
0
    def testCancellation(self):

        c = GafferImage.Constant()

        m = GafferImage.Median()
        m["in"].setInput(c["out"])
        m["radius"].setValue(imath.V2i(2000))

        bt = Gaffer.ParallelAlgo.callOnBackgroundThread(
            m["out"], lambda: GafferImageTest.processTiles(m["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 master
        # channel.
        m["masterChannel"].setValue("R")

        bt = Gaffer.ParallelAlgo.callOnBackgroundThread(
            m["out"], lambda: GafferImageTest.processTiles(m["out"]))
        time.sleep(0.1)

        t = time.time()
        bt.cancelAndWait()
        self.assertLess(time.time() - t, acceptableCancellationDelay)
예제 #7
0
	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() )
예제 #8
0
	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 )
예제 #9
0
파일: stats-1.py 프로젝트: tws0002/gaffer
    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
        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()),
        ]

        print "\nImage :\n"
        self.__printItems(items)
예제 #10
0
	def testParallelProcessEmptyDataWindow( self ) :

		d = GafferImage.Display()
		self.assertEqual( d["out"]["dataWindow"].getValue(), imath.Box2i() )

		GafferImageTest.processTiles( d["out"] )
		d["out"].image()
		d["out"].imageHash()
예제 #11
0
	def testParallelProcessEmptyDataWindow( self ) :

		d = GafferImage.Display()
		self.assertEqual( d["out"]["dataWindow"].getValue(), IECore.Box2i() )

		GafferImageTest.processTiles( d["out"] )
		d["out"].image()
		d["out"].imageHash()
예제 #12
0
	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"] )
예제 #13
0
    def testUpsizingPerformance(self):

        checker = GafferImage.Checkerboard()
        checker["format"].setValue(GafferImage.Format(1000, 1000))

        transform = GafferImage.ImageTransform()
        transform["in"].setInput(checker["out"])
        transform["transform"]["scale"].setValue(imath.V2f(3))

        with GafferTest.TestRunner.PerformanceScope():
            GafferImageTest.processTiles(transform["out"])
예제 #14
0
    def testTranslationPerformance(self):

        checker = GafferImage.Checkerboard()
        checker["format"].setValue(GafferImage.Format(3000, 3000))

        transform = GafferImage.ImageTransform()
        transform["in"].setInput(checker["out"])
        transform["transform"]["translate"].setValue(imath.V2f(2.2))

        with GafferTest.TestRunner.PerformanceScope():
            GafferImageTest.processTiles(transform["out"])
예제 #15
0
    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"])
예제 #16
0
    def testRotationAndScalingPerformance(self):

        checker = GafferImage.Checkerboard()
        checker["format"].setValue(GafferImage.Format(3000, 3000))

        transform = GafferImage.ImageTransform()
        transform["in"].setInput(checker["out"])
        transform["transform"]["pivot"].setValue(imath.V2f(1500))
        transform["transform"]["rotate"].setValue(2.5)
        transform["transform"]["scale"].setValue(imath.V2f(0.75))

        with GafferTest.TestRunner.PerformanceScope():
            GafferImageTest.processTiles(transform["out"])
예제 #17
0
	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"] )
예제 #18
0
    def testConcatenationPerformance1(self):

        checker = GafferImage.Checkerboard()
        checker["format"].setValue(GafferImage.Format(3000, 3000))

        transform1 = GafferImage.ImageTransform("Transform1")
        transform1["in"].setInput(checker["out"])
        transform1["transform"]["pivot"].setValue(imath.V2f(1500))
        transform1["transform"]["rotate"].setValue(2.5)

        transform2 = GafferImage.ImageTransform("Transform2")
        transform2["in"].setInput(transform1["out"])
        transform2["transform"]["translate"].setValue(imath.V2f(10))

        with GafferTest.TestRunner.PerformanceScope():
            GafferImageTest.processTiles(transform2["out"])
예제 #19
0
    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"])
예제 #20
0
	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"] )
예제 #21
0
	def testNegativeDataWindowOrigin( self ) :

		reader = GafferImage.ImageReader()
		reader["fileName"].setValue( os.path.dirname( __file__ ) + "/images/checker.exr" )

		constant = GafferImage.Constant()
		constant["color"].setValue( IECore.Color4f( 0.5, 0, 0, 1 ) )

		offset = GafferImage.Offset()
		offset["in"].setInput( constant["out"] )
		offset["offset"].setValue( IECore.V2i( -200, -250 ) )

		vectorWarp = GafferImage.VectorWarp()
		vectorWarp["in"].setInput( reader["out"] )
		vectorWarp["vector"].setInput( offset["out"] )

		GafferImageTest.processTiles( vectorWarp["out"] )
예제 #22
0
    def testMonitorParallelProcessTiles(self):

        numTilesX = 50
        numTilesY = 50

        c = GafferImage.Checkerboard()
        c["format"].setValue(
            GafferImage.Format(
                numTilesX * GafferImage.ImagePlug.tileSize(),
                numTilesY * GafferImage.ImagePlug.tileSize(),
            ))

        with Gaffer.PerformanceMonitor() as m:
            GafferImageTest.processTiles(c["out"])

        self.assertEqual(
            m.plugStatistics(c["out"]["channelData"]).computeCount,
            numTilesX * numTilesY * 4)
예제 #23
0
    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"])
예제 #24
0
	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"] )
예제 #25
0
    def mergePerf(self, operation, mismatch):
        r = GafferImage.Checkerboard("Checkerboard")
        r["format"].setValue(GafferImage.Format(4096, 3112, 1.000))
        # Make the size of the checkerboard not a perfect multiple of tile size
        # in case we ever fix Checkerboard to notice when tiles are repeated
        # and return an identical hash ( which would invalidate this performance
        # test )
        r["size"].setValue(imath.V2f(64.01))

        alphaShuffle = GafferImage.Shuffle()
        alphaShuffle["in"].setInput(r["out"])
        alphaShuffle["channels"].addChild(
            GafferImage.Shuffle.ChannelPlug("A", "R"))

        transform = GafferImage.Offset()
        transform["in"].setInput(alphaShuffle["out"])
        if mismatch:
            transform["offset"].setValue(imath.V2i(4000, 3000))
        else:
            transform["offset"].setValue(imath.V2i(26, 42))

        merge = GafferImage.Merge()
        merge["operation"].setValue(operation)
        merge["in"][0].setInput(alphaShuffle["out"])
        merge["in"][1].setInput(transform["out"])

        # Precache upstream network, we're only interested in the performance of Merge
        GafferImageTest.processTiles(alphaShuffle["out"])
        GafferImageTest.processTiles(transform["out"])

        with GafferTest.TestRunner.PerformanceScope():
            GafferImageTest.processTiles(merge["out"])
예제 #26
0
		def processer() :

			try :
				GafferImageTest.processTiles( g["out"] )
			except Exception, e :
				exceptions.append( e )
예제 #27
0
파일: stats-1.py 프로젝트: wizofe/gaffer
        def computeImage():

            with self.__context(script, args) as context:
                for frame in self.__frames(script, args):
                    context.setFrame(frame)
                    GafferImageTest.processTiles(image)
예제 #28
0
		def computeImage() :

			with self.__context( script, args ) as context :
				for frame in self.__frames( script, args ) :
					context.setFrame( frame )
					GafferImageTest.processTiles( image )
예제 #29
0
        def processer():

            try:
                GafferImageTest.processTiles(g["out"])
            except Exception, e:
                exceptions.append(e)