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

I purchased Viltrox 85 mm f/1.8 lens for Fujifilm X-Mount (camera X-S10). At first step I tried to copy and paste lens correction data of the same lens (Viltrox 85mm) available for Nikon Z6 for Fujifilm X. But, darktable 4.0 does not identify the lens automatically. I applied following steps:

The … original entry in misc.xml was as following:

Viltrox Viltrox AF 85mm f/1.8 Z Nikon Z 1
  1. I ran exiftool.exe via ExiftoolGUI and got the lens data from .RAF file:

Exif_lens-data

Exiv2 delivers the same lens specification:

  1. Accordingly I edited the above data and adapted for Viltrox Fujifilm X-mount:
VILTROX AF 85/1.8 II XF Fujifilm X 1.53
  1. I included the above lines first in misc.xml and later I appended them into mil-fujifilm.xml. When I open a RAF file in Darktable 4.0 that lens cannot be identified automatically. I have to choose it from the pop-up menu → VILTROX → AF 85/1.8 II XF. Then it works. Distortion and TCA corrections will be applied.

Lens model name starts with two blank characters as shown above in the screenshot. I removed them alternatively, but no influence.

Maybe I have overseen some important issue. I appreciate any help.

Regards,

Mustafa

I noticed after sending the message the code has suddenly disappeared. I could succeed to enter them correctly. First original The <lens> ... </lens> data are as follows:

<lens>
<maker>Viltrox</maker>
<model>Viltrox AF 85mm f/1.8 Z</model>
<mount>Nikon Z</mount>
<cropfactor>1</cropfactor>
<calibration>
<!-- Taken with Nikon Z 6 -->
<distortion model="ptlens" focal="85" a="0" b="0.00846" c="0"/>
<tca model="poly3" focal="85" vr="0.9998219" vb="0.9999488"/>
</calibration>
</lens>

At step 2 the lens data of Viltrox 85 mm I adapted for Fujifilm look as follows:

<lens>
<maker>VILTROX</maker>
<model> AF 85/1.8 II XF</model>
<focal value="85" />
<aperture min="1.8" max="16" />
<mount>Fujifilm X</mount>
<cropfactor>1.53</cropfactor>
<calibration>
<!-- Taken with Nikon Z 6 -->
<distortion model="ptlens" focal="85" a="0" b="0.00846" c="0"/>
<tca model="poly3" focal="85" vr="0.9998219" vb="0.9999488"/>
</calibration>
</lens>

Sorry for inconvenience!

I would not assume the a lens for Fuji x (apsc sensor) and Nikon z6 (full frame sensor) are the same lens and have the same corrections.

I read somewhere that Viltrox 85 mm for Fuji is in fact a lens for full frame. But, your answer does not help me to solve my problem. :wink:

Well good luck then. No need to be rude about it.

What is the model name shown in darktable in the left info menu?

I assume you are asking the “image information” at the left menu of DT. It does not show the lens maker:
DT-Image_Information

At the right menu of darkroom the error shown is as follows:

DT-lens_correction

When I select manually the right lens from pop-up menu (Viltrox → AF…), then the correct lens data will be loaded:

DT-lens_correction-manual-select

The distortion measured across the full-frame sensor surface is different than it would be across the APS-C surface. Whether its a significant difference depends on how bad off is the lens. Use your fix, but be aware it may not produce acceptable results.

In the exiv2 screenshot there appears to be two spaces at the beginning of LensModel, but your XML has only one - this could be the issue. Try changing to either two spaces (so it matches exactly) or zero (in case the spaces get stripped during the lens matching.)

you can see that the lens isn’t identified (first screenshot) as it’s needed for lensfun (second screenshot)
The two blanks are completely meaningless in this context as you can see comparing both strings.

So the proper way is helping exiv2 to return a proper lens identification that is consistent with the lensfun lens identification.
See User's portal · darktable-org/darktable Wiki · GitHub

1 Like

That’s why there is a crop factor in lensfunDB. You can thus use a correction done with a full-frame sensor for a cropped sensor. The inverse is obviously not true.

Thank you all for your interest in my problem and your help. First I thought I did not enter the two blanks correctly. I tested with two blanks and without them, no difference.

I strongly guess that the problem is related to the wrong identification of the lens by exiv2 as Martin stated. I must first study how to interact with the output of exiv2 within darktable.

Hi Martin,
I am not a Lunix user and all explanations in Internet to create exiv2 file are based on a Lunix system. Do you have any hint where on a Windows system that file to be added? Many thanks in advance!

have a look at exiv2 manual Exiv2 - Image metadata library and tools section configuration file

I looked at the exiv2 manual. On Windows an exiv2.ini under %USERPROFILE% has to be created.

In fact, exiv2 delivers lens maker’s name correctly:

Exif.Photo.LensSpecification                 Rational    4  8500/100 8500/100 180/100 180/100
Exif.Photo.LensMake                          Ascii      13  VILTROX 
Exif.Photo.LensModel                         Ascii      64    AF 85/1.8 II XF
Exif.Photo.LensSerialNumber                  Ascii      11  00000002

Frankly speaking, I have not understand the key issue of confusion happening in DT.

lenstype is the relevant value as described in the GitHub link I posted

As dt doesn’t seem to find it through LensID/LensType, it falls back to LensModel you see here.

For comparison purpose I extracted the lens data included in the RAW file of my Fujifilm camera with a Fuji lens using exiv2. The result is as follows:

Exif.Photo.LensSpecification                 Rational    4  3500/100 3500/100 200/100 200/100
Exif.Photo.LensMake                          Ascii      13  FUJIFILM
Exif.Photo.LensModel                         Ascii      64  XC35mmF2
Exif.Photo.LensSerialNumber                  Ascii      11  0AA15948

There is also no entry of lens type, but DT identifies the lens correctly. The difference to Viltrox lens is that lens maker is Fujifilm in that case. I do not think the serial number will be evaluated in DT.

For Fujifilm cameras and lenses there is a lensfun file mil-fujifilm.xml. For various lenses and cameras there is a file called misc.xml. The lens entry of Viltrox 85 mm for Nikon Z6 was stored in misc.xml. Since I do not have any Nikon picture taken with Viltrox 85 mm, I cannot see whether that Viltrox lens is correctly identified in DT.

First point and my understanding is, it is irrelevant whether the lens entry/data is stored in mil-fujifilm.xml or misc.xml. Is that correct?

Second point, what additional data of the lens is needed to identify the lens and camera definitely?

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.