matchmove组的流程涉及到syntheyes与maya,nuke交接的问题。syntheyes会生成包含去畸变节点的nuke工程 和带跟踪信息的maya工程。在nuke工程上渲染得到去畸变的序列,这是第一步。第二步就是进入maya工程替换去畸变的序列,并修改相应相机参数。

在以往流程中,第二步需要人工完成,涉及到的参数也不少,不熟悉流程的员工时常犯错,是一个流程隐患。
要解决这个问题就需要一个脚本自动完成第二步骤,相机之前的数据可以直接获取,之后的数据可以根据去畸变序列的属性进行换算,于是这个节点的思路便清晰了。
 
脚本如下,直接保存为.py文件拖到maya工具栏上即可
Talk is cheap,show you the code:
#####################################################################
 
 
import maya.cmds as maya

maya.window(title = 'MatchMove Tool  v1.3',w=500,h=170)
maya.rowColumnLayout(numberOfColumns=2,columnAttach=[1,"right",0],columnWidth=[[1,100],[2,400]])

################################################################################################################
####################################################序列路径修改################################################
################################################################################################################

maya.text(label="Input Image File",align = 'right',font = 'boldLabelFont')

file = maya.textField()

commandstr = 'filename = maya.fileDialog2(fileMode=1, caption="Import Image");\
    maya.textField(file,edit=True,w=400,fi=filename[0])'

maya.textField(file,edit=True,w=400,fi='R:/filmServe',dgc = commandstr)

maya.text(label="Frame Cahe")
cacheframe = maya.intSliderGrp(field = True, v = 100 , minValue=0 , maxValue=1000 , fieldMinValue=0 , fieldMaxValue=5000)

maya.text(label="On/Off")
maya.checkBox(l = 'Use Image Sequence',onCommand = 'maya.setAttr(thisImagePlane+".useFrameExtension",1)',\
offCommand = 'maya.setAttr(thisImagePlane+".useFrameExtension",0)')

cameralist = maya.listCameras()                                                                         #获得当前相机列表
cameralist.remove('persp');cameralist.remove('front');cameralist.remove('top');cameralist.remove('side');
cameralist.reverse()
eistr = []
for i in cameralist:
    eistr.append([cameralist.index(i),i])                                                               #获得ei字符串

cameraenum = maya.attrEnumOptionMenu(w = 100, ei = eistr)                                               #建立一个下拉框显示过滤后的camera
cameraindex = maya.attrEnumOptionMenu(cameraenum,q=1,npm=True)

for i in eistr:
    if i[0] == cameraindex:
        thisCamera = i[1]                                                                               #获得当前camera
        break

if maya.imagePlane(thisCamera,q= 1,camera=True):
    thisImagePlane = maya.imagePlane(thisCamera,q = 1,n = True)[0]                                          #获得当前plane
else:
    maya.imagePlane(thisCamera,camera=thisCamera)
    thisImagePlane = maya.imagePlane(thisCamera,q = 1,n = True)[0]                                          #获得当前plane

maya.button(label="Replace sequence",w = 100,command = 'selected_node = maya.ls(sl=1);\
file_value = maya.textField(file,q = 1,tx = 1);\
picture = maya.getFileList(folder = file_value)[1] if file_value.find(".") == -1 else "";\
maya.setAttr(thisImagePlane+".imageName",file_value + picture,type="string");\
framecache_value = maya.intSliderGrp(cacheframe,q=True,v = True);\
maya.setAttr(thisImagePlane+".frameCache",framecache_value);\
imageSizelist = maya.imagePlane(thisCamera,q=1,imageSize=1);\
maya.textField(targetsizewidth,tx = imageSizelist[0] ,w=100,edit=True,enterCommand=("maya.setFocus(\'" + targetsizeheight + "\')"));\
maya.textField(targetsizeheight,tx = imageSizelist[1] ,w=100,edit=True,enterCommand=("maya.setFocus(\'" + sourcesizewidth + "\')"));\
')

################################################################################################################
####################################################具体参数修改################################################
################################################################################################################

maya.text(label="")
maya.text(label="")
maya.text(label="")
maya.text(label="")

maya.text(label="Input Source Size",font = 'boldLabelFont')
maya.text(label="")
sourcesizewidth = maya.textField()
sourcesizeheight = maya.textField()

maya.text(label="")
maya.text(label="")

#maya.text(label="Input Source Aperture(mm)",font = 'boldLabelFont')
#maya.text(label="")
sourceApeH = maya.textField()
sourceApeV = maya.textField()

#maya.text(label="")
#maya.text(label="")

maya.text(label="Input Target Size",font = 'boldLabelFont')
maya.text(label="")
targetsizewidth = maya.textField()
targetsizeheight = maya.textField()

Rwidth = maya.getAttr("defaultResolution.width")
Rheight = maya.getAttr("defaultResolution.height")
horizontalFilmAperture = maya.getAttr(thisCamera+"Shape.horizontalFilmAperture")
verticalFilmAperture = maya.getAttr(thisCamera+"Shape.verticalFilmAperture")

#imageSizelist = maya.imagePlane(thisCamera,q=1,imageSize=1)

maya.textField(sourcesizewidth,tx=Rwidth,w=100,edit=True,enterCommand=('maya.setFocus(\"' + sourcesizeheight + '\")'))
maya.textField(sourcesizeheight,tx=Rheight,w=100,edit=True,enterCommand=('maya.setFocus(\"' + sourceApeH + '\")'))
maya.textField(sourceApeH,tx=horizontalFilmAperture,w=100,edit=True,enterCommand=('maya.setFocus(\"' + sourceApeV + '\")'))
maya.textField(sourceApeV,tx=verticalFilmAperture,w=100,edit=True,enterCommand=('maya.setFocus(\"' + targetsizewidth + '\")'))
maya.textField(targetsizewidth,tx = 'input target width' ,w=100,edit=True,enterCommand=('maya.setFocus(\"' + targetsizeheight + '\")'))
maya.textField(targetsizeheight,tx = 'input target height' ,w=100,edit=True,enterCommand=('maya.setFocus(\"' + sourcesizewidth + '\")'))

maya.button(label="Default Size",w=100,command = 'selected_node = maya.ls(sl=1);\
    sourcesizewidth_value = maya.textField(sourcesizewidth,q = 1,tx = 1);\
    sourcesizeheight_value = maya.textField(sourcesizeheight,q = 1,tx = 1);\
    maya.setAttr(thisCamera+"Shape.horizontalFilmAperture",horizontalFilmAperture);\
    maya.setAttr(thisCamera+"Shape.verticalFilmAperture",verticalFilmAperture);\
    maya.setAttr("defaultResolution.width",int(sourcesizewidth_value));\
    maya.setAttr("defaultResolution.height",int(sourcesizeheight_value));\
    maya.setAttr(thisImagePlane+".sizeX",horizontalFilmAperture);\
    maya.setAttr(thisImagePlane+".sizeY",verticalFilmAperture);\
    ')

maya.button(label="Go",w = 100,command = 'selected_node = maya.ls(sl=1);\
    sourcesizewidth_value = maya.textField(sourcesizewidth,q = 1,tx = 1);\
    sourcesizeheight_value = maya.textField(sourcesizeheight,q = 1,tx = 1);\
    targetsizewidth_value = maya.textField(targetsizewidth,q = 1,tx = 1);\
    targetsizeheight_value = maya.textField(targetsizeheight,q = 1,tx = 1);\
    maya.setAttr("defaultResolution.width",int(targetsizewidth_value));\
    maya.setAttr("defaultResolution.height",int(targetsizeheight_value));\
    agr_val = float(targetsizewidth_value)/float(sourcesizewidth_value);\
    horizon = maya.getAttr(thisCamera+"Shape.horizontalFilmAperture");\
    vertical = maya.getAttr(thisCamera+"Shape.verticalFilmAperture");\
    maya.setAttr(thisCamera+"Shape.horizontalFilmAperture",horizon*agr_val);\
    maya.setAttr(thisCamera+"Shape.verticalFilmAperture",vertical*agr_val);\
    maya.setAttr(thisImagePlane+".sizeX",horizon*agr_val);\
    maya.setAttr(thisImagePlane+".sizeY",vertical*agr_val);\
    ')

maya.text(label="")
maya.text(label="")

maya.text(label="")
maya.text(label="")

maya.text(label="InputAspectRatio",font = 'boldLabelFont')
maya.text(label="")

defaultpixelaspectratio = maya.getAttr("defaultResolution.pixelAspect")
defaultdeviceaspectratio = maya.getAttr("defaultResolution.deviceAspectRatio")

#complete the creating of maintain width/height ratio
maya.text(label="Lock Aspect")
maya.setAttr("defaultResolution.aspectLock",0)
maya.checkBox(l = 'maintain width/height ratio',onCommand = 'maya.setAttr("defaultResolution.aspectLock",1)',\
    offCommand = 'maya.setAttr("defaultResolution.aspectLock",0)')

maya.text(label="Pixel Aspect Ratio")

maya.rowColumnLayout(numberOfColumns=3,columnAttach=[1,"right",0])

PixelAspectRatio = maya.textField()

maya.button(label="SetValue",w = 60,command = 'pixelAspectvalue = maya.textField(PixelAspectRatio,q = 1,tx = 1);\
    maya.setAttr("defaultResolution.pixelAspect",float(pixelAspectvalue));\
    maya.setAttr("defaultResolution.deviceAspectRatio",defaultdeviceaspectratio*float(pixelAspectvalue)/defaultpixelaspectratio)')
maya.button(label="Restore",w = 60,command = 'maya.setAttr("defaultResolution.pixelAspect",defaultpixelaspectratio);\
    maya.setAttr("defaultResolution.deviceAspectRatio",defaultdeviceaspectratio)')

#complete the creating of pixel aspect ratio
#targetsizewidth_value = float(maya.textField(targetsizewidth,q = 1,tx = 1))
#targetsizeheight_value = float(maya.textField(targetsizeheight,q = 1,tx = 1))
#correctvalue = targetsizewidth_value/(targetsizeheight_value*float(defaultdeviceaspectratio))

maya.textField(PixelAspectRatio,tx = float(defaultpixelaspectratio),edit = True,enterCommand = 'pixelAspectvalue = maya.textField(PixelAspectRatio,q = 1,tx = 1);\
    maya.setAttr("defaultResolution.pixelAspect",float(pixelAspectvalue));\
    ')

maya.showWindow()

################################################################################################################
################################################################################################################
###################################################################################Write By Sol He##############
################################################################################################################
################################################################################################################

 

matchmove流程中修改Maya相机数据的脚本的更多相关文章

  1. oracle数据库中修改已存在数据的字段

    在oracle中,如果已经存在的数据的某些列,假如要更换类型的话,有的时候是比较麻烦的, 会出现:ORA-01439: column to be modified must be empty to c ...

  2. MySQL中修改多个数据表的字段拼接问题

    错误1: 异常:Truncated incorrect DOUBLE value: 'lili' 问题分析:我的修改sql语句是:update video set vname='汉字' and vdi ...

  3. C#程序中:如何修改xml文件中的节点(数据)

    要想在web等程序中实现动态的数据内容给新(如网页中的Flash),不会更新xml文件中的节点(数据)是远远不够的,今天在这里说一个简单的xml文件的更新,方法比较基础,很适合初学者看的,保证一看就懂 ...

  4. ResultSet遍历过程中修改自身数据,不会改变循环的过程

    ResultSet遍历过程中修改自身数据,不会改变循环的过程: import java.sql.Connection; import java.sql.PreparedStatement; impor ...

  5. 072——VUE中vuex之使用mutations修改购物车仓库数据

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. Java如何大批量从json数据源中按指定符号隔字符串,并修改、删除数据

    原文出自:https://blog.csdn.net/seesun2012 package com.seesun2012.com; /** * Java大批量修改.删除数据,按指定标识符分隔字符串 * ...

  7. oracle中修改表已有数据的某一列的字段类型的方法,数据备份

    1.在开发过程中经常会遇到表中的某一个字段数据类型不对,比如说需要保存的数据带小数,但是在最初设计的时候是给的number(10)类型,开始保存是整数的时候满足要求,后来在保存小数的时候 会发现自动四 ...

  8. 【mybatis】service层中一个方法中使用mybatis进行数据库的 多个修改操作,可能是update也可能是delete操作,但是sql语句命名执行并且在控制台打印出来了,但是数据库中未更新到数据【事务的问题】

    问题描述: service层中一个方法中使用mybatis进行数据库的 多个修改操作,可能是update也可能是delete操作,但是sql语句命名执行并且在控制台打印出来了,但是数据库中未更新到数据 ...

  9. mybatis中修改了数据,控制台显示成功,数据库没有修改

    在mybatis中遇到了修改数据时,控制台显示修改成功,但是去数据库查看并没有修改,这是因为mybatis不时自动提交事务的,所以是不会修改数据库的数据,这是我们加上一句 sqlSession.com ...

随机推荐

  1. 前端笔记 (3.JavaScript 2)

    一般来说,js代码越来越庞大的时候,最好要把它存在一个js文件中, 通过src引入即可,这样具有维护性高,可缓存(加载一次,无需加载) 方便未来拓展的特性 正确写法: <script type= ...

  2. logminer实战之生产环境写入数据字典,dg环境查询拷贝日志,测试环境进行挖掘,输出结果

    应客户需要,对某一天的日志进行挖掘,分析日均归档日志切换数量20增长至40的原因,是什么表的dml操作导致的日志量剧增,最终定位某个应用(需要客户自己进行甄别) 操作说明及介绍: 1.客户10.2.0 ...

  3. 前端解析websocket数据问题

    buf []byte //err = websocket.Message.Send(ws, buf) err = websocket.Message.Send(ws, string(buf[:])) ...

  4. ifconfig 命令,改变主机名,改DNS hosts、关闭selinux firewalld netfilter 、防火墙iptables规则

    ifconfig 命令用于查看网络相关的命令: 安装:yum install net-tools -y  ifdown  eth_name  关闭网卡  ifup  eth_name   开启网卡 配 ...

  5. 使用w uptime vmstat top sar nload 等命令查看系统负载

    1.  w 和uptime,查看cpu的使用率: 2.vmstat 命令,查看更细的物理设备使用状况: 3.top 命令: top -c  可具体查看命令及路径: top -bn1 静太显示一条命令, ...

  6. php基础-6

    类的继承和方法重写 <?php class people{ public function __construct($name, $age, $sex) { $this->age = $a ...

  7. Liunx----vi编辑器

    关于vi编辑器基本的用法总结如下: vi是linux下的一款文编编辑器. 进入vi的方法:在系统启动起来后,直接键入vi或vi 文件名: 进去后输入内容方法:输入a或i,切换到编辑模式: 退出编辑模式 ...

  8. Linux命令对应英文全称

    https://blog.csdn.net/yrc_note/article/details/72598780 拓展:https://blog.csdn.net/u010613363/article/ ...

  9. day44 数据库学习 索引 引用自egon 老师博客

    MySQL索引管理 总结 #索引是存在硬盘中的, #索引的功能, 1.可以加速查询 2.但是他会降低写入和删除的速度 所以不能乱加索引 总结二 1 最左前缀匹配原则 2设置的索引,它的字段中的内容占空 ...

  10. openresty router && template 试用

      router 是一个比较方便的 openresty 路由组件,我们可以用来编写灵活强大的 web 应用,类似的 lua-resty-route 也是很不错的,但是如果是比较简单的直接可以使用 lu ...