|
hello,
i would like be abble to read a 32bits iff file with a python script to get the z range on the sequence i’ve rendered.
I tried to read it with the command open(file.iff,"rb") but i don’t know the iff’structure.
I tried also to use the maya python api image or else but i don’t know how to implement an api…
Is there someone that have done this and could help me?
Thanks
Nicolas Pastrana
|
|
|
|
I know this is kind of old, but may still be of some use:
import maya.OpenMaya as OpenMaya
import os.path
lFileName = r'd:\zdepthtest.iff'
def getDepthMapRange(pImageName):
# The image
lImage = OpenMaya.MImage()
lImage.readFromFile(pImageName)
if not lImage.haveDepth():
print 'No Z-Depth map channel found'
return
# Calculate the size of the dmap
widthPtr = OpenMaya.MScriptUtil().asUintPtr()
heightPtr = OpenMaya.MScriptUtil().asUintPtr()
lImage.getDepthMapSize(widthPtr, heightPtr)
# Get the width and height of the image in pixels
width = OpenMaya.MScriptUtil().getUint(widthPtr)
height = OpenMaya.MScriptUtil().getUint(heightPtr)
numPixels = (width*height)
# Pixels object, we use this to read the values
lPixels = lImage.depthMap()
lHighValue = -1.0
lLowValue = 0.0
# Use this script util to read the values
lPixelUtil = OpenMaya.MScriptUtil()
for i in range(numPixels):
depthValue = lPixelUtil.getFloatArrayItem(lPixels, i)
if depthValue < lLowValue:
lLowValue = depthValue
# Ignore zero values
if cmp(0.0, depthValue) and depthValue > lHighValue:
lHighValue = depthValue
print('Z Range: %f to %f' % (lLowValue, lHighValue))
if os.path.isfile(lFileName):
getDepthMapRange(lFileName)
Stev
|
|
|