Difference between revisions of "Node"

From Silhouette Wiki
Jump to navigation Jump to search
(Created page with "The Node object generates output (usually an image) based on a set of inputs (image data and properties). ''Base Class: Object'' === Attributes === ''Attributes are rea...")
 
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
''Base Class: [[Object]]''
 
''Base Class: [[Object]]''
 +
 +
=== Creation ===
 +
Nodes are created with the <tt>Node(type)</tt> constructor, where type is the "node type id". A list of available nodes can be queried with the global <tt>fx.nodes</tt> attribute.
 +
 +
Note that internal nodes have names like RotoNode and PaintNode. Most of the rest of the stock Silhouette nodes are implemented using OFX, and have node IDs such as com.digitalfilmtools.ofx.silhouette.sfx_composite and com.digitalfilmtools.ofx.silhouette.blur.
 +
 +
Nodes can be connected to other nodes using [[Pipe|Pipes]] and [[Port|Ports]]. Ports have specific types (usuallying image or data) and can only be connected to other ports with the same type. Output ports can have multiple pipes connected to them but input ports may only have one.
 +
 +
<syntaxhighlight lang="python">
 +
roto = Node("RotoNode")
 +
activeSession().addNode(roto)
 +
 +
slapComp = Node("com.digitalfilmtools.ofx.silhouette.slapComp")
 +
activeSession().addNode(slapComp)
 +
 +
roto.port("output").connect(slapComp.port("input"))
 +
</syntaxhighlight>
  
 
=== Attributes ===
 
=== Attributes ===
Line 9: Line 26:
 
! scope="col" | Name
 
! scope="col" | Name
 
! scope="col" class="unsortable" | Description
 
! scope="col" class="unsortable" | Description
 +
! scope="col" | Added
 
|-
 
|-
 
|active
 
|active
Line 30: Line 48:
 
|worldToImageTransform
 
|worldToImageTransform
 
|the [[Matrix]] used to transform from ''world coordinates'' to ''image coordinates''
 
|the [[Matrix]] used to transform from ''world coordinates'' to ''image coordinates''
 +
|-
 +
|outputMask
 +
|the output streams it can produce.
 +
|6.0
 +
|-
 +
|state
 +
|a dictionary of any extra node-specific state
 +
|6.0
 +
|-
 +
|connectedInputs
 +
|list of connected input [[Port|Ports]]
 +
|6.0
 +
|-
 +
|connectedOutputs
 +
|list of connected output [[Port|Ports]]
 +
|6.0
 +
|-
 +
|pipes
 +
|list of connected pipes [[Pipe|Pipes]]
 +
|6.0
 +
|-
 +
|ports
 +
|list of all [[Port|Ports]]
 +
|6.0
 +
|-
 +
|matte
 +
|the "obey matte" input [[Port]], or None if the node does not have one
 +
|6.0
 
|}
 
|}
  
Line 37: Line 83:
 
! scope="col" | Name
 
! scope="col" | Name
 
! scope="col" class="unsortable" | Description
 
! scope="col" class="unsortable" | Description
 +
! scope="col" | Added
 +
|-
 +
|render(frame, stream=[[Silhouette Module Reference#Stream Type Constants|Stream_Left]], channels=Channel_RGBA, depth=None, resolution=Proxy_FullRes, roi=None, port=None)
 +
|render at the desired frame and returns a [[Raster]] with the result. <tt>depth</tt> and <tt>roi</tt> default to the Session's depth and ROI, respectively. If <tt>port</tt> is omitted, the first output [[Port]] will be used.
 +
|-
 +
|metadata(frame)
 +
|returns a metadata dictionary derived from up-stream Sources for the specified frame
 +
|6.0
 +
|-
 +
|setState(key, value)
 +
|sets the node state for key to value
 +
|6.0
 +
|-
 +
|disconnect(port)
 +
|disconnect the [[Port]]
 +
|6.0
 +
|-
 +
|port(name)
 +
|return the [[Port]] with the given name
 +
|6.0
 +
|-
 +
|getInput(index=0)
 +
|return the input [[Port]] at <tt>index</tt>
 +
|6.0
 
|-
 
|-
|render(frame, stream=[[Silhouette Module Reference#Stream Type Constants|Stream_Left)
+
|getOutput(index=0)
|render at the desired frame and returns a [[Raster]] with the result
+
|return the output [[Port]] at <tt>index</tt>
 +
|6.0
 
|}
 
|}

Latest revision as of 22:00, 25 July 2018

The Node object generates output (usually an image) based on a set of inputs (image data and properties).

Base Class: Object

Creation

Nodes are created with the Node(type) constructor, where type is the "node type id". A list of available nodes can be queried with the global fx.nodes attribute.

Note that internal nodes have names like RotoNode and PaintNode. Most of the rest of the stock Silhouette nodes are implemented using OFX, and have node IDs such as com.digitalfilmtools.ofx.silhouette.sfx_composite and com.digitalfilmtools.ofx.silhouette.blur.

Nodes can be connected to other nodes using Pipes and Ports. Ports have specific types (usuallying image or data) and can only be connected to other ports with the same type. Output ports can have multiple pipes connected to them but input ports may only have one.

roto = Node("RotoNode")
activeSession().addNode(roto)

slapComp = Node("com.digitalfilmtools.ofx.silhouette.slapComp")
activeSession().addNode(slapComp)

roto.port("output").connect(slapComp.port("input"))

Attributes

Attributes are read-only except where noted.

Name Description Added
active True if the active node
enabled True if enabled (read/write)
imageToWorldTransform the Matrix used to transform from image coordinates to world coordinates
inputs List of input Ports
outputs List of output Ports
session the Session the node is in (same as parent)
worldToImageTransform the Matrix used to transform from world coordinates to image coordinates
outputMask the output streams it can produce. 6.0
state a dictionary of any extra node-specific state 6.0
connectedInputs list of connected input Ports 6.0
connectedOutputs list of connected output Ports 6.0
pipes list of connected pipes Pipes 6.0
ports list of all Ports 6.0
matte the "obey matte" input Port, or None if the node does not have one 6.0

Methods

Name Description Added
render(frame, stream=Stream_Left, channels=Channel_RGBA, depth=None, resolution=Proxy_FullRes, roi=None, port=None) render at the desired frame and returns a Raster with the result. depth and roi default to the Session's depth and ROI, respectively. If port is omitted, the first output Port will be used.
metadata(frame) returns a metadata dictionary derived from up-stream Sources for the specified frame 6.0
setState(key, value) sets the node state for key to value 6.0
disconnect(port) disconnect the Port 6.0
port(name) return the Port with the given name 6.0
getInput(index=0) return the input Port at index 6.0
getOutput(index=0) return the output Port at index 6.0