def testCompute():

    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, [])

    print "before compute"

    outputCache = tuttle.MemoryCache()
    timeRange = tuttle.TimeRange(1, 16, 10)
    print "setup"
    procGraph.setup()
    print "beginSequence"
    procGraph.beginSequence(timeRange)
    for time in xrange(timeRange._begin, timeRange._end, timeRange._step):
        print "time:", time
        procGraph.setupAtTime(time)
        procGraph.processAtTime(outputCache, time)
    print "endSequence"
    procGraph.endSequence()

    print "after compute"
Exemple #2
0
    def computeNode(self, node, frame):
        """
            Computes the node (displayed in the viewer) at the frame indicated.
        """
        buttleData = ButtleDataSingleton().get()
        graphTuttle = buttleData.getGraph().getGraphTuttle()

        #Get the output where we save the result
        self._tuttleImageCache = tuttle.MemoryCache()

        if buttleData.getVideoIsPlaying():  # if a video is playing
            processGraph = buttleData.getProcessGraph()
            processGraph.setupAtTime(frame)
            processGraph.processAtTime(self._tuttleImageCache, frame)
        else:  # if it's an image only
            processOptions = tuttle.ComputeOptions(int(frame))
            processGraph = tuttle.ProcessGraph(processOptions, graphTuttle,
                                               [node])
            processGraph.setup()
            timeRange = tuttle.TimeRange(frame, frame,
                                         1)  # buttleData.getTimeRange()
            processGraph.beginSequence(timeRange)
            processGraph.setupAtTime(frame)
            processGraph.processAtTime(self._tuttleImageCache, frame)
            processGraph.endSequence()

        self._computedImage = self._tuttleImageCache.get(0)

        #Add the computedImage to the map
        hashMap = tuttle.NodeHashContainer()
        graphTuttle.computeGlobalHashAtTime(hashMap, frame)
        hasCode = hashMap.getHash(node, frame)
        #Max 15 computedImages saved in memory
        if hasCode not in buttleData._mapNodeNameToComputedImage.keys(
        ) and len(buttleData._mapNodeNameToComputedImage) < 15:
            buttleData._mapNodeNameToComputedImage.update(
                {hasCode: self._computedImage})
        elif hasCode not in buttleData._mapNodeNameToComputedImage.keys(
        ) and len(buttleData._mapNodeNameToComputedImage) >= 15:
            #Delete a computed image from the memory (random)
            buttleData._mapNodeNameToComputedImage.popitem()
            buttleData._mapNodeNameToComputedImage.update(
                {hasCode: self._computedImage})

        return self._computedImage
Exemple #3
0
    def launchProcessGraph(self):
        buttleData = ButtleDataSingleton().get()
        #Get the name of the currentNode of the viewer
        node = buttleData.getCurrentViewerNodeName()
        # initialization of the process graph
        graph = buttleData.getGraph().getGraphTuttle()

        # timeRange between the frames of beginning and end (first frame, last frame, step)
        timeRange = tuttle.TimeRange(self._frame, self._nbFrames, 1)
        self._processOptions = tuttle.ComputeOptions(self._frame,
                                                     self._nbFrames, 1)
        processGraph = tuttle.ProcessGraph(self._processOptions, graph, [node])
        processGraph.setup()
        processGraph.beginSequence(timeRange)
        # communicate processGraph to buttleData
        buttleData.setProcessGraph(processGraph)

        buttleData.setVideoIsPlaying(True)