I struggle to understand how focal length is handled when a cine camera has a LENS component added. I use custom calibration procedure with the openCV grid, so I bypass the calibration tools of the engine itself.
The camera itself has the Filmback group with sensor width, height physical size. This can be filled in correctly, no problem with it: even though opencv uses pixels to measure focal length.
The camera component itself has (legacy) fields for sensor’s horizontal+vertical offset and finally Current focal length in millimeters - even with the Lens component added to the camera, these fields are active and affect the rendered image.
The lens component allows one to enter values from opencv calibration directly:
Optical axis, to my understanding, shall be cx,cy values (pixels) from the opencv calibration divided by resolution of the camera, i.e. cx/resX, cy/resY.
Focal length is likely the same story - opencv generates fx,fy in pixels, so one has to enter fx/resX, fy/resY
(please can You confirm this cx/resX, cy/resY and fx/resX, fy/resY - is my assumption correct?)
The problem: original camera component’s Sensor offset and Current focal length fields remain active, and the Lens component’s cx,cy,fx,fy as well! I can’t quite understand this -- we now have two independent parameter sets for the optical axis and focal length. One would think the Lens component’s fields might e.g. overload legacy cine camera’s ones, but no, all these values interfere.
How to ensure the cine camera ultimately respects cx,cy,fx,fy values of the Lens component and ignores values in the Camera component itself to exactly replicate the opencv calibration?
Thank You in advance,
Stepan
[ EDIT ]
Also worth asking is - openCV uses 0,0 coordinate for the top left of the frame. In the UE Lens component: does cy parameter shift the optical center the same way as openCV?
i.e. increasing opencv cy makes identical changes as increasing cy in this Lens component?
Isn’t it necessary to enter 1.0-openCV_cy instead in case the Lens component assumes 0,0 in the bottom left corner?
Your assumption cx/resX, cy/resY and fx/resX, fy/resY -
Using a Lens file component you need to have a FIZ source added to the camera component.
On the Lens component make sure under distortion source check on “apply distortion”.
Now when you change focus distance you will see the focal length change on the camera component to match the value on the lens file. The distortion on the Lens component will change based on the lens file as well.
There is also on the Lens component a film back over ride. Choose Lens file and it will use the film back set in the Lens file and over ride the values on the camera component.
If the feed is a crop of what was used in the Lens file, choose cropped filmback settings and set the cropped film back. This will override the film back on the camera component.
What is confusing is on the Lens component you can choose do not override on the lens film back override and then set the film back on the actual camera component.
For anyone interested - at this time, I think one really MUST generate the lens file.
Despite holding identical values one can manually type in the property sheet of the LENS component, the file has the ability to overload and lock these entries. When used, just set the size of the cine camera’s sensor to sensible values such as xRes/100.0, yRes/100.0 (x,yRes being target framebuffer’s resolution in pixels - be sure to keep aspect ratio of the real camera here). When the lens file gets loaded and activated, the camera component actually auto calculates the Current focal length field and locks it against any manual changes: which is exactly what Epic forgot to do when these values get entered in distortion fields of the property sheet of the Lens component manually.
I.e - for my use case: by using the lens file, one gets nothing extra aside of the cine camera’s current focal length field locked against editing and auto calculated to correct value -- at least this is what I can see so far.
Seems like you have what you want. For other users heee is some more information
If you are using a Lens file then add your values to the lens file and not to the Lens Component. Suggest even if you are only adding these values at a single focus distance to still use the Lens file. All of this will be applied and easier to use than putting in by hand on the Lens Component Distortion state.
Image of the Distortion state properties which are greyed out when the distortion source is set to Lens file.
Change distortion source to manual and these fields will no longer get greyed out. Can enter by hand. However as soon as you change to another distortion source the values will be re set to zero.
The Lens file passes the calculated focal length to the camera component when the Lens file is being used.
Distortion, optical center and calculated focal length should be calibrated at different focus distances. These values will change as focus distance changes. This calibration can be done with the lens file calibration process or these can be input by hand with values created outside of Unreal.
Image of distortion values input by hand in the lens file at two different focus distances.