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. vim3

    使用vim编辑多个文件 编辑多个文件有两种形式,一种是在进入vim前使用的参数就是多个文件.另一种是在进入vim后再编辑其他文件. 1. vim 1.txt 2.txt 在命令行模式下输入:n编辑2. ...

  2. 新建oracle数据库表空间及删除表空间和用户

    进入oracle的命令控制台,按具体情况执行以下命令: sqlplus 默认数据库普通用户登录sqlplus / as sysdba 默认数据库管理员登录sqlplus username/passwo ...

  3. JavaScript条件语句-5--if语句的嵌套

    JavaScript条件语句 学习目标 1.掌握length属性的应用 2.掌握if语句的嵌套 length 语法:string.length 功能:获取string字符串的长度 返回值:number ...

  4. C++中vector容器的常用操作方法实例总结

    C++中vector容器的常用操作方法实例总结 参考 1. C++中vector容器的常用操作方法实例总结: 完

  5. Python之路,第九篇:Python入门与基础9

    python3  集合set 集合set概念 集合是可变的容器:满足数学意义上的定义,求并集交集等 集合内的数据对象都是唯一的(不能重复多次) 集合是无序的存储结构,集合中的数据没有先后关系 集合是相 ...

  6. [LeetCode&Python] Problem 563. Binary Tree Tilt

    Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the ab ...

  7. 编译Thrift支持golang

    本文已经是很久以前的文章了,也不知道新版本thrift如何 Thrift是一个跨语言的服务部署框架,Thrift通过一个中间语言(IDL, 接口定义语言)来定义RPC的接口和数据类型,然后通过一个编译 ...

  8. MySQL用户管理、常用sql语句、MySQL数据库备份恢复

    1.MySQL用户管理 给远程登陆用户授权:grant all on *.* to 'user1'@'127.0.0.1' identified by '123456' (这里的127.0.0.1是指 ...

  9. deque中的细节问题,以及reverse和max_element的使用

    deque中使用迭代器进行运算的函数都默认以.end()为结束,而实际上.end()所返回的是最后一个元素的下一个位置,所以进行数据比较时,应对其-1才是对应的最后一个数据,而函数中则是直接使用.en ...

  10. js-自加和自减

    i++ 返回的是自增之前的值    先利用再加 ++i 返回的是自增之后的值    先加再利用