Search code examples
pythonnuke

Grab the aperture values in .chan camera


I am writing a python script and I am trying to get the camera .chan aperture values - horizontal and vertical as I am going to use these values and transferred it into Maya camera.

However, even as I open up .chan, I am only seeing a few lines/columns/rows or numerical values in which it belongs to the frame number, translation, rotation values as well as the values of the focal length.

As such, it is not citing the values of the Aperture. Any ideas how I can grab it?


Solution

  • Chan files do not contain aperture values. They contain three translate values, three rotate values, and one (vertical) angle of view.

    However, the angle of view is really the most important number. For any angle of view, there exists a focal length and aperture which generates it. Assuming a default aperture, you can compute the focal length easily based on the angle of view.

    Nuke default cameras are 18.672mm x 24.576mm film back. So an equation given aov to get focal would be:

    focal = 18.672 / tan(aov / 2) / 2
    

    In this way no knowledge of the existing aperture is actually needed, which is precisely why it isn't included in the chan file to begin with!


    You may also consider using FBX or Alembic files. Chan files are a bit of a relic from before Nuke supported either of those more advanced formats.