PDA

View Full Version : Python - Image Help Please


dieLocke
11-28-2012, 02:07 PM
Hey Community,

Iím trying to develop a script in python that will allow me to save eight different camera views in one single big picture. This picture should display them so that I can import them into the stereoscopic player. Iím just getting into the matter and donít have much experience in python, but Iím pretty sure that there must be some way to solve this.

My code


import maya.cmds as cmds
import maya.mel as mm
import maya.OpenMaya as api
import maya.OpenMayaUI as apiUI
import ctypes

# read the color buffer from the view, and save the MImage to disk

view = apiUI.M3dView.active3dView()
wrapper = api.MImage()

view.readColorBuffer(viewImage, True)
scriptUtilw = api.MScriptUtil()
scriptUtilh = api.MScriptUtil()
wPtr = scriptUtilw.asUintPtr()
hPtr = scriptUtilh.asUintPtr()
viewImage.getSize(wPtr, hPtr)
twidth = scriptUtilw.getUint(wPtr)
theight = scriptUtilh.getUint(hPtr)
print (twidth)
print (theight)
wrapper.create (twidth*4,theight*2)
wrapper.writeToFile('C:/wrapper.jpg', 'jpg')
I call the size of the viewpoint and set the picture 4 times as wide as twice as tall so I can display four camera views in a row.
I tried, after creating the picture, to put the views on their designated spot or implement them as a texture. But so far I canít find a function to do so, neither in python nor inside the Maya API. I thought about using writeColorBuffer to save the color-information from the camera onto the wrapper picture but that didnít work.

I hope you might be able to help me figure out hot to transfer the views on the big picture. I go with any solution as long as the performance desnít break in too much.

Thanks in advance

CGTalk Moderation
11-28-2012, 02:07 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.