Skip to main content
 首页 » 编程设计

python之Foundry Nuke 的 Reformat 节点问题

2024年10月01日8lexus

我想跟踪我的镜头并将 CG 元素添加到它作为我的核弹项目的一部分。为此,我对素材进行了无失真处理并将其写入磁盘以加快处理速度。然而,当我试图重新扭曲书面镜头时(如附图所示),它没有给我原始镜头。我发现 Reformat5 和 Reformat7 没有给我相同的边界框尺寸,即使两个节点相同也是如此。

我的原始素材大小是 1920*1080。去畸变后变成1928*1085。

因此我放置了一个尺寸为 1928*1085 的 Reformat4 节点并将其写入磁盘。在左侧,我再次放置重新格式化节点以将未失真的素材大小调整回 1920*1080,并保留大小为 1928*1085 的边界框,以便执行镜头失真以恢复我的原始素材。

它在左侧工作正常,但如果我在我的书面素材上做同样的事情,边界框尺寸就不一样了。

Reformat7 给出大小为 1924*1083 而不是 1928*1085 的边界框。我在这里错过了什么?我在网上搜索但找不到任何解决方案。请阐明这个问题。

我的核弹脚本如下:

set cut_paste_input [stack 0] 
version 10.0 v3 
push $cut_paste_input 
LensDistortion { 
 serializeKnob "" 
 serialiseKnob "22 serialization::archive 9 0 0 0 0 0 0 0 0 0 0 0 0" 
 distortion1 -0.007498324849 
 distortion2 0.0008674863493 
 distortionCenter {-0.002916968195 -0.001372990897} 
 invertDistortion true 
 cardScale {1.006676197 1.006676197 1} 
 a 0.001508030226 
 b -0.006750627421 
 c -0.002457624534 
 analysisStart 1 
 analysisStop 329 
 name LensDistortion2 
 selected true 
 xpos -451 
 ypos 651 
} 
Reformat { 
 format "1928 1085 0 0 1928 1085 1 undistortedFormat2" 
 resize none 
 name Reformat4 
 selected true 
 xpos -451 
 ypos 684 
} 
set N6eafc00 [stack 0] 
Reformat { 
 resize none 
 pbb true 
 name Reformat5 
 selected true 
 xpos -451 
 ypos 745 
} 
LensDistortion { 
 serializeKnob "" 
 serialiseKnob "22 serialization::archive 9 0 0 0 0 0 0 0 0 0 0 0 0" 
 distortion1 -0.007498324849 
 distortion2 0.0008674863493 
 distortionCenter {-0.002916968195 -0.001372990897} 
 cardScale {0.9934444427 0.9934444427 1} 
 a -0.0004114751064 
 b 0.004895505495 
 c 0.002436506096 
 analysisStart 1 
 analysisStop 329 
 name LensDistortion3 
 selected true 
 xpos -451 
 ypos 782 
} 
push $N6eafc00 
Write { 
 file F:/Assignments/Nuke/CGComp/footages/undistortedFootage1080p/undistortedFootage1080p.####.exr 
 file_type exr 
 name Write7 
 selected true 
 xpos -269 
 ypos 684 
} 
Reformat { 
 resize none 
 pbb true 
 name Reformat7 
 selected true 
 xpos -269 
 ypos 747 
} 
LensDistortion { 
 serializeKnob "" 
 serialiseKnob "22 serialization::archive 9 0 0 0 0 0 0 0 0 0 0 0 0" 
 distortion1 -0.007498324849 
 distortion2 0.0008674863493 
 distortionCenter {-0.002916968195 -0.001372990897} 
 cardScale {0.9934444427 0.9934444427 1} 
 a -0.0004114751064 
 b 0.004895505495 
 c 0.002436506096 
 analysisStart 1 
 analysisStop 329 
 name LensDistortion5 
 selected true 
 xpos -269 
 ypos 783 
} 

请您参考如下方法:

您需要使用CopyBBox 节点来解决您的问题。此 Python 命令创建连接的 CopyBBox 节点:

import nuke 
nuke.createNode("CopyBBox") 

或者您可以使用此命令创建一个与其他节点断开连接的节点:

nuke.nodes.CopyBBox() 

CopyBBox 将边界框从 A 输入复制到 B 流。边界框定义了 Nuke 认为具有有效图像数据的帧区域。边界框越大,Nuke 处理和渲染图像所需的时间就越长。

某些 NUKE 操作,例如 Merge、Blur 或 LensDistortion 可能会导致边界框区域扩大或缩小,因为 NUKE不知道额外的区域将是黑色或其他常量颜色。通常,您可以通过将边界框从输入之一复制到生成的图像来解决此问题,从而切断额外的区域。

nuke.nodes.Transform(scale=1.005, filter="Mitchell") 

如果您在右边距处有“拉伸(stretch)像素效果”,请在 Transform 节点中使用 scale=1.005 参数(就在您的 LensDistortion5 节点)。另外,不要忘记使用过滤算法。