Hi;
Is there any mechanism at all in Houdini to read EXR header attributes?
Ideally I would like to read a numeric custom attribute and do something with it. Python is appealing, but installing OpenEXR or OIIO into Hython is less so.
Thanks!
How to read EXR metadata/header attribs?
4730 8 1- dhemberg
- Member
- 207 posts
- Joined: Nov. 2015
- Offline
- jsmack
- Member
- 8041 posts
- Joined: Sept. 2011
- Offline
if you don't mind going the COPs route, you can use python copNode methods to get metadata.
copNode.getMetadataString() probably being the main one
there's also the metadata cop vop, but I'm not sure how useful that would be since it would only be able to influence pixel values.
copNode.getMetadataString() probably being the main one
there's also the metadata cop vop, but I'm not sure how useful that would be since it would only be able to influence pixel values.
Edited by jsmack - June 28, 2022 01:17:59
- mark
- Staff
- 2638 posts
- Joined: July 2005
- Offline
- dhemberg
- Member
- 207 posts
- Joined: Nov. 2015
- Offline
mark
Houdini also ships with hoiiotool(a version of OIIO tool compiled against the Houdini version of OIIO).
Awesome! I *thought* I knew houdini shipped with some version of OIIO! But, are python bindings included? If I try importing OpenImageIO in a python node, I see errors, so I assumed I was misremembering that it existed.
Edited by dhemberg - June 28, 2022 10:00:45
- gnisbet
- Member
- 32 posts
- Joined: Aug. 2011
- Offline
dhembergmark
Houdini also ships with hoiiotool(a version of OIIO tool compiled against the Houdini version of OIIO).
Awesome! I *thought* I knew houdini shipped with some version of OIIO! But, are python bindings included? If I try importing OpenImageIO in a python node, I see errors, so I assumed I was misremembering that it existed.
Did you ever manage to get anything working with this? I'm looking to embed some exr metadata in my images.
- dhemberg
- Member
- 207 posts
- Joined: Nov. 2015
- Offline
Hi; I did, though it is pretty ugly. I used the approach @jsmack offered, as I never heard back about python bindings and oiiotool in Houdini. So, here is what I do:
--I make a COP2 network (mine lives in LOPS)
--File read the image I want metadata from
--In LOPS, I make a Python node
--I use python to get the COP2 file node, then use getMetaDataString() to read the full metadata header from the COP2 node.
--this returns a dictionary, I'm interested in the metadata attribute, e.g.
then proceed accordingly. I don't like this; if I can just read the metadata directly without having to go through COPS for the image reader, that would be much better.
--I make a COP2 network (mine lives in LOPS)
--File read the image I want metadata from
--In LOPS, I make a Python node
--I use python to get the COP2 file node, then use getMetaDataString() to read the full metadata header from the COP2 node.
--this returns a dictionary, I'm interested in the metadata attribute, e.g.
then proceed accordingly. I don't like this; if I can just read the metadata directly without having to go through COPS for the image reader, that would be much better.
- gnisbet
- Member
- 32 posts
- Joined: Aug. 2011
- Offline
Ah, I could never read any of the metadata in the python script. I was trying to query the rendertime from a karma render, but:
node = hou.node("/obj/cop2net/file")
node.getMetaDataString("renderTime")
The second one never returned any metadata but I can read that string in nuke. Was that similar metadata to what you were reading?
node = hou.node("/obj/cop2net/file")
node.getMetaDataString("renderTime")
The second one never returned any metadata but I can read that string in nuke. Was that similar metadata to what you were reading?
- dhemberg
- Member
- 207 posts
- Joined: Nov. 2015
- Offline
I was querying an attribute called "whiteLuminance"; when I middle mouse on my file, I see this:
When I load a recent Karma render and middle mouse on it, I see:
Is it the case that your python should be asking for "renderTime_s" rather than "renderTime"?
EDIT: Also, here is my Python; note that I first ask for "Attributes", then parse that:
When I load a recent Karma render and middle mouse on it, I see:
Is it the case that your python should be asking for "renderTime_s" rather than "renderTime"?
EDIT: Also, here is my Python; note that I first ask for "Attributes", then parse that:
# This is a shenanigan to read the "whiteLuminance" # attribute from my hand-made IBL texture, and set the # intensity on my light accordingly. import ast this_node = hou.pwd() ibl_reader = hou.node(this_node.evalParm("ibl_cop")) #path to my COP2 file reader # The ast module casts a string as a dictionary, # which is how Houdini represents exr metadata. metadata = ast.literal_eval(ibl_reader.getMetaDataString('attributes')) # Read the attribs I'm interested in. whiteLuminance = metadata['whiteLuminance'] measuredLux = metadata['MeasuredLUX']
Edited by dhemberg - Oct. 17, 2022 10:44:01
- gnisbet
- Member
- 32 posts
- Joined: Aug. 2011
- Offline
Ah, fantastic, thanks so much!
I was trying to directly read the MetaData name, but the name on the node is attributes.
I was trying to directly read the MetaData name, but the name on the node is attributes.
import ast # path to file node node = hou.node("../render_file") # convert string to dict attrs = ast.literal_eval(node.getMetaDataString("attributes")) # Print peak memory and render time print(attrs["info:peakMemory_s"], attrs["renderTime_s"])
-
- Quick Links