The process of the Matchmove group involves the handover of Syntheyes and Maya,nuke. The syntheyes generates a nuke project with a de-distortion node and a Maya project with tracking information. It is the first step to render a sequence of distortions in the nuke project. The second step is to enter the Maya project to replace the distorted sequence and modify the corresponding camera parameters.
In the previous process, the second step requires manual completion, involving a lot of parameters, not familiar with the process of staff often make mistakes, is a process hidden trouble. To solve this problem requires a script to automatically complete the second step, the camera before the data can be directly obtained, after the data can be converted according to the properties of the distortion sequence, so the idea of this node is clear.The script is as follows and is saved directly as a. py file onto the Maya toolbar
Talk was 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 = +, 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 = +, ei = eistr) #建立一个下拉框显示过滤后的came Ra
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##############
############################################################################################################### #
############################################################################################################### #
Script to modify Maya camera data in the Matchmove process