Python image help

Python image help

Anonymous
Not applicable
486 Views
0 Replies
Message 1 of 1

Python image help

Anonymous
Not applicable
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
0 Likes
487 Views
0 Replies
Replies (0)