Lens calibration data (lensfun, version 1) are not recognized by DT 4.0 automatically

I haven’t picked at the code specifically, but it seems Lensfun does a sort of parsing of whatever the software supplies as Lens Model, so things like number of spaces between things is not relevant.

Lensfun will provide correction data from its database if: 1) an equivalent entry can be found for the camera model and lens model nomenclature, and 2) if the camera model matches a crop factor for which the database has an entry. Where the data is in the collection of .xmls is not relevant. I’ve run into this with my Nikkor AF-P 70-300 FX, for which lensfun has data when I use it on the full frame Z 6 but does not when on my APS-C D7000. Thing is all the previous discussion about cropfactor applies, can’t just copy the entry and change the crop factor.

Confounding all this is that camera manufacturers don’t always supply a straightforward text name for the mounted lens in the metadata. So then, the metadata library has to do gymnastics to come up with one. Until recently, Nikkor F-mount lenses relied on a lookup table created by a fellow named Rottmerhusen where an 8-byte ID number was created from various other metadata tags and used to look up the relevant text nomenclature. You can see a copy of it in exiftool code, here:

https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/Nikon.pm#L79

To lazy to look, but I think exiv2 uses the same data. For other makes they sometimes supply a LensID number in the metadata and the software maintains a similar, less ambiguous, lookup table.

So, the answer to your question about additional data is not straightforward.

Thank you for the detailed information, Glenn! I understand that things are not straightforward, although that (Viltrox) lens’ maker and the lens designation (model) are sufficient to search the lens data in the .xml files. Those data come from Exif as confirmed by exiv2 and exiftool both. In addition, the camera model is also known. A search algorithm can handle this task very quickly.

As I correctly understood, exiv2 implemented in DT extracts camera and lens data from the raw file and DT looks for the corresponding lens correction data in the lensfun database.

It is unsatisfying for me not being able to proceed and find a solution at moment. I appreciate any hint to make a progress.

It appears from the previous discussion that lensfun does not have an APS-C version of the distortion correction for that lens. You have the option of submitting measured data following the lensfun instructions. That would be the solution. If you choose not to pursue that, then I’d say you need to figure out how to be satisfied with your choice…

Yes, it’s not the easiest thing in the world to figure out, but you would learn a bit in the process…

At first step I thought I can take lens data for Nikon Z6 and add them to lensfun database manually to see as a test whether this will function. At the second step, I would take pictures and submit them to get the right and complete lens correction data incl. vignetting compensation.

When I encounter at the first step that difficulty of the unidentified lens, how can you be sure that at second step it will function?

Those lens data from Viltrox lens for Nikon are just numbers. How can we argument that those belong to a full frame camera and DT may not recognize as a consequence.

How do you think the rest of the data in the lensfun database got there? Do the procedure, submit the data, and the repo maintainers will make sure it gets to the proper place. With that, you won’t have to worry about XML formatting and content…

1 Like

Even if you perform the calibration for the APS-C crop, the fallback string AF 85/1.8 II XF currently used by dt on the camera body in question will not be sufficient to identify this lens automatically.

What’s missing?

“Viltrox” in front. (Or any other vendor as this string as it stands might not be unique.)

Lensfun will ignore spaces and case when matching, but won’t do a partial match, I think…

Glenn, frankly I do not know what is missing in order the lense will be identified. The fact is DT does not identify the Viltrox lens automatically. I entered the data exiv2 delivered into .xml file of lensfun database as shown above.

The ~/.exiv2 file already mentioned can tell dt the correct information to pass to lensfun.

True, but only if there is a numerical LensID/LensType to perform the mapping.

The OP still hasn’t shown all the relevant Exif and MakerNote data.

I believe this would function. I am Windows user and DT runs under Windows. I could not find any reliable information what should be the contents of that file and where to locate in Windows system.

I attached a RAW file taken with Fujifilm X-S10 with attached Viltrox 85 mm lens. You can get all the information out of it.
_DSF3267.RAF (25.2 MB)

So the Fujifilm MakerNote doesn’t include the LensID/LensType numerical tag like e.g. Canon or Nikon do, so not sure how the exiv2.ini mapping would work in this case. I’ll have to take a closer look at the exiv2 and dt code when I find some time…

Thank you for your interest in trying to help me. It is not urgent. I think the key point is how DT handles the lensfun database.

I think DT should use the lens corrections embedded in metadata.

Has someone reverse engineered and posted how that metadata works?

Perhaps @agriggio ?

Sorry, what is the question exactly?

Have you reverse engineered and implemented lens correction where the correction data stored in the raw file is used?