Isotropix Forums

EXR Metadata

Discuss about expressions in Clarisse

EXR Metadata

Unread postby dane » Fri Jul 05, 2019 4:42 pm

Hey peeps,

In one of your release docs you mention:

EXR Metadata

New camera metadata is written to EXR files (world to camera matix and world to NDC matrix).


I see the 'exr/worldToCamera' in the metadata but is there documentation for this so I know what values are relating to what?

Also, is there documentation for the image metadata anywhere? Or some examples of what attributes can be used and how?

Thanks guys!

Dan
dane
 
Posts: 98
Joined: Wed Aug 29, 2018 11:50 am

Re: EXR Metadata

Unread postby anemoff » Fri Jul 05, 2019 5:16 pm

Hi,

Sorry, there's no documentation for EXR metadata usage. We'll add it in a future release.

Currently, Clarisse will write:
- worldToCamera: camera's inverse global matrix
- worldToDNC: camera's projection matrix
- comment: comment on the Image object
- custom metadata in the "Metadata" attribute of the Image or Layer (check this other topic for details: viewtopic.php?f=5&t=5703)

What do you need to do?
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: EXR Metadata

Unread postby dane » Fri Jul 05, 2019 5:22 pm

Thanks for that anemoff.

We want to create a tool for nuke that creates a camera from the exr metadata so I was expecting a matrix for positional information and possibly hapature/vapature/focal length etc for us to recreate the same FOV with a nuke camera.

Second to that we are wondering if we can take attributes, say the 'path_tracer.anti_aliasing_sample_count' and write that information into the metadata so we can display it during dailies etc

Thanks for your time
dane
 
Posts: 98
Joined: Wed Aug 29, 2018 11:50 am

Re: EXR Metadata

Unread postby desmond » Sat Jul 06, 2019 5:54 am

Not hijacking, but i am also interested in this. Is there a python way to access those like in the other topic?
thanks
User avatar
desmond
 
Posts: 54
Joined: Mon Feb 05, 2018 8:46 am

Re: EXR Metadata

Unread postby anemoff » Mon Jul 08, 2019 9:51 am

Hi,

@dane
I guess it should be possible to write attribute values from other Clarisse objects using the new expression system from 4.0, in the metadata attribute of the image.
I'll give it a try and come back to you.

@desmond
Currently, there is no C++/Python API in Clarisse to read the metadata of an input EXR file.
I think gycliao's metadata output comes from Nuke, or some other app.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: EXR Metadata

Unread postby dane » Mon Jul 08, 2019 10:23 am

Amazing, thanks anemoff, if it works and we get some nice tools out of it I'll share them back on here for the community
dane
 
Posts: 98
Joined: Wed Aug 29, 2018 11:50 am

Re: EXR Metadata

Unread postby anemoff » Tue Jul 09, 2019 10:53 am

So, there are 2 ways of proceeding.

1/ Using a Python script to edit the Image/Layer metadata value

python code

# Get path tracer attrs
pt = ix.get_item("project://scene/path_tracer")
aa = pt.get_attribute("anti_aliasing_sample_count").get_long()

# Get camera attrs
cam = ix.get_item("project://scene/camera")
cam_fov = cam.get_attribute("field_of_view").get_double()
cam_f_stop = cam.get_attribute("f_stop").get_double()
cam_focus_dist = cam.get_attribute("focus_distance").get_double()
cam_gm = cam.get_module().get_global_matrix()

# Build the metadata string
md = 'anti_aliasing_sample_count {}'.format(aa)
md += '\n'
md += 'camera_fov {}'.format(cam_fov)
md += '\n'
md += 'camera_f_stop {}'.format(cam_f_stop)
md += '\n'
md += 'camera_focus_distance {}'.format(cam_focus_dist)
md += '\n'
md += 'camera_global_matrix'
for row in range(4):
for col in range(4):
md += ' {}'.format(cam_gm.get_item(row, col))
md += '\n'
md += 'custom_string "hello world"'

# Set the metadata in the image
ix.get_item("project://scene/image.metadata").set_string(md)


2/ Using an expression in the metadata attribute

However, there are some limitations:
- we need to use an ugly workaround to add escaped characters like \n or " in a string;
- we can't access an object's Module to call functions like `get_global_matrix`

SeExpr code

# Get attribute values
aa = get_double("project://scene/path_tracer.anti_aliasing_sample_count");
cam_fov = get_double("project://scene/camera.field_of_view");
cam_f_stop = get_double("project://scene/camera.f_stop");
cam_focus_dist = get_double("project://scene/camera.focus_distance");

# Can't retrieve the Camera module needed to compute the global matrix.
# But it's possible to get the Kinematics attributes: translate, rotate, etc.

# Build the metadata string with the values
# NOTE: the eval usage is a temporary workaround to allow escaping characters.
md = "anti_aliasing_sample_count " + to_string(aa);
md += eval("\n");
md += "camera_fov " + to_string(cam_fov);
md += eval("\n");
md += "camera_f_stop " + to_string(cam_f_stop);
md += eval("\n");
md += "camera_focus_distance " + to_string(cam_focus_dist);
md += eval("\n");
md += "custom_string " + eval("\"") + "hello world" + eval("\"");

# return the string
md


Output from solution 1:
Code: Select all
anti_aliasing_sample_count 9
camera_fov 25.0
camera_f_stop 5.6
camera_focus_distance 5.0
camera_global_matrix 0.707106781187 -0.331290731025 0.624697087825 2.44030930037 0.0 0.883455093977 0.468515844905 1.8302047538 -0.707106781186 -0.331290731026 0.624697087825 2.44030930037 0.0 0.0 0.0 1.0
custom_string "hello world"


Output for the solution 2 is the same, minus the global_matrix.

Cheers,
Attachments
exr_metadata_expr.project
(39.59 KiB) Downloaded 130 times
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: EXR Metadata

Unread postby dane » Tue Jul 09, 2019 2:35 pm

Hey anemoff,

This is great! Thanks for taking the time to explore this it definitely helps to have this reference and then build on it.

A couple of questions though. To have this run per frame across a farm I guess you'd need to use the expression instead of the python script?

Second, I'm reading out a frame using your expression and clarisse is showing the correct information but when I check the metadata in Nuke the only thing that comes though is: 'custom_string: hello world' Is Nuke expecting a certain formatting for the EXR metadata?

Thanks again mate
dane
 
Posts: 98
Joined: Wed Aug 29, 2018 11:50 am

Re: EXR Metadata

Unread postby anemoff » Tue Jul 09, 2019 3:10 pm

dane wrote:A couple of questions though. To have this run per frame across a farm I guess you'd need to use the expression instead of the python script?

Yes, if you need to write values that change over time, like translate, rotate, ..., for example.

But if the metadata doesn't change over time, I would recommend using the Python approach to avoid unnecessary expression evaluations during the render. Just run the script once to setup metadata.

dane wrote:Second, I'm reading out a frame using your expression and clarisse is showing the correct information but when I check the metadata in Nuke the only thing that comes though is: 'custom_string: hello world' Is Nuke expecting a certain formatting for the EXR metadata?

I don't know. But the metadata seems OK in exrheader. I get this output:
Code: Select all
custom_string (type string): "hello world"
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: EXR Metadata

Unread postby dane » Tue Jul 09, 2019 3:24 pm

After a little digging, it seems that Nuke expects to see this as an output:

anti_aliasing_sample_count "14"
camera_fov "25"
camera_f_stop "5.6"
camera_focus_distance "5"
custom_string "hello world"

Currently we are outputting as:

anti_aliasing_sample_count 14
camera_fov 25
camera_f_stop 5.6
camera_focus_distance 5
custom_string "hello world"

I'm still not overly familiar with the language but I'll try and get the " back on the output, will let you know
dane
 
Posts: 98
Joined: Wed Aug 29, 2018 11:50 am

Next

Return to Expressions