darktable
darktable copied to clipboard
Exif.NikonLd4.LensID favoured to Exif.Photo.LensModel, even if latter is defined in db and former is not
Is there an existing issue for this?
- [x] I checked and did not find my issue in the already reported ones
Describe the bug
I created the lensfun calibration data for a 3rd-party lens, then I added that information in Darktable's share\lensfun\version_1\misc.xml file, but Darktable doesn't automatically recognize the lens when I open NEF raw files shot with that lens.
In the lens correction module, I see "253" as default (unknown) model, but the name corresponding to the model I've added is present in the drop-down list.
So I have either to select it manually for each photograph, or I can add the data in a .exiv2 (Linux) / exiv2.ini (Windows) file in my home folder. In that file, I have to put "253" (the LensIDNumber value) or "0" (the LensID value):
[nikon]
253=35mm f/2
If I convert the NEF into DNG, using the Adobe DNG Converter, Darktable automatically recognizes the model without requiring the .exiv2/exiv2.ini file, and it correctly shows the model in the Image Information panel, too.
I finally discovered that this strange behaviour was due to the way Darktable determines the lens model:
- If it finds the
Exif.NikonLd4.LensID(orLensIDNumber, that isn't clear) tag in the metadata, it uses the number as identifier, even if the model is defined inExif.Photo.LensModel. - In the NEF, both tags are present, so Darktable takes
Exif.NikonLd4.LensIDand ignoresExif.Photo.LensModel. However, it doesn't find the numbers of the former, "0" or "253", in the database, so it gives up. - In the DNG, only
Exif.Photo.LensModelis present, and the value is35mm f/2. That's the model I added in the misc.xml file above, so it's automatically detected.
My problem with that, once the data on this 3rd-party lens in integrated into lensfun database and ultimately in a next version of Darktable, is that no other user will benefit from the detection. They'll either think it's not supported or will have to manually create the .exiv2 file (if they even know about it). More likely, they'll find it in the Voigtländer models and decide to select it manually each time.
Another problem is that it's impossible to distinguish a series of models using "0" and "253", like the 35 mm and 50 mm models from Voigtländer. Only Exif.Photo.LensModel can tell them apart.
=> Why doesn't Darktable falls back on Exif.Photo.LensModel if Exif.NikonLd4.LensID isn't in any database? Unless there's a way to link both data for all the impacted lenses and for everyone (without asking them to add files manually)? Perhaps if that value is "0", or if Exif.NikonLd4.LensIDNumber is "253", then it should look at the Exif.Photo.LensModel value?
XML content of the calibrated lens
<lens>
<maker>Voigtländer</maker>
<model>35mm f/2</model>
<model lang="en">APO-LANTHAR 35mm F2 Aspherical II</model>
<mount>Nikon Z</mount>
<cropfactor>1</cropfactor>
<calibration>
<!-- Taken with Nikon Z6III -->
<distortion model="ptlens" focal="35" a="0.00726" b="-0.01914" c="0.0101"/>
<tca model="poly3" focal="35.0" vr="1.0000325" vb="0.9999729" />
<vignetting model="pa" focal="35.0" aperture="2.0" distance="0.27" k1="-1.7274801" k2="1.4821616" k3="-0.5357087" />
<vignetting model="pa" focal="35.0" aperture="2.0" distance="0.54" k1="-2.1529816" k2="2.1936554" k3="-0.8936036" />
<vignetting model="pa" focal="35.0" aperture="2.0" distance="1.62" k1="-2.3381563" k2="2.5067040" k3="-1.0497600" />
<vignetting model="pa" focal="35.0" aperture="2.0" distance="1000" k1="-2.4054764" k2="2.6108750" k3="-1.0973622" />
<vignetting model="pa" focal="35.0" aperture="2.8" distance="0.27" k1="-0.4931862" k2="-0.3903400" k3="0.2860779" />
<vignetting model="pa" focal="35.0" aperture="2.8" distance="0.54" k1="-0.5818163" k2="-0.5645652" k3="0.4422908" />
<vignetting model="pa" focal="35.0" aperture="2.8" distance="1.62" k1="-0.6329567" k2="-0.6647739" k3="0.5480756" />
<vignetting model="pa" focal="35.0" aperture="2.8" distance="1000" k1="-0.6536585" k2="-0.7188463" k3="0.6043772" />
<vignetting model="pa" focal="35.0" aperture="4.0" distance="0.27" k1="-0.5839239" k2="0.0348811" k3="0.0656375" />
<vignetting model="pa" focal="35.0" aperture="4.0" distance="0.54" k1="-0.7391125" k2="0.1372117" k3="0.0234026" />
<vignetting model="pa" focal="35.0" aperture="4.0" distance="1.62" k1="-0.8256081" k2="0.2102259" k3="-0.0122386" />
<vignetting model="pa" focal="35.0" aperture="4.0" distance="1000" k1="-0.8589557" k2="0.2228163" k3="-0.0119729" />
<vignetting model="pa" focal="35.0" aperture="5.6" distance="0.27" k1="-0.5812536" k2="0.0279456" k3="0.0705040" />
<vignetting model="pa" focal="35.0" aperture="5.6" distance="0.54" k1="-0.7175983" k2="0.0628979" k3="0.0875625" />
<vignetting model="pa" focal="35.0" aperture="5.6" distance="1.62" k1="-0.7939760" k2="0.0946543" k3="0.0903589" />
<vignetting model="pa" focal="35.0" aperture="5.6" distance="1000" k1="-0.8303944" k2="0.1121402" k3="0.0904709" />
<vignetting model="pa" focal="35.0" aperture="16.0" distance="0.27" k1="-0.6030442" k2="0.0509183" k3="0.0586593" />
<vignetting model="pa" focal="35.0" aperture="16.0" distance="0.54" k1="-0.7165359" k2="0.0224849" k3="0.1161671" />
<vignetting model="pa" focal="35.0" aperture="16.0" distance="1.62" k1="-0.7985310" k2="0.0598960" k3="0.1186587" />
<vignetting model="pa" focal="35.0" aperture="16.0" distance="1000" k1="-0.8312505" k2="0.0598966" k3="0.1325040" />
</calibration>
</lens>
Sample image
I can't upload it here, so I temporarily hosted it here.
Exiv2 information
DSC_1956.NEF:
Exif.NikonLd4.LensID Short 1 0
Exif.Photo.LensModel Ascii 65 35mm f/2
DSC_1956.DNG:
Exif.Photo.LensModel Ascii 9 35mm f/2
Steps to reproduce
-
Remove any information related to the lens model from the .exiv2 / exiv2.ini file in the home directory
-
Add the information about the lens model into Darktable's share\lensfun\version_1\misc.xml file
-
Load a NEF photo taken with that model lens => Darktable fails to recognize the model automatically
-
Convert the NEF to DNG
-
Load the DNG => Darktable successfully recognizes the model automatically
-
Extract the exiv2
Exif.NikonLd4.LensIDinformation from the NEF file (orExif.NikonLd4.LensIDNumber) -
Add the information into the .exiv2 / exiv2.ini file
-
Refresh the metadata EXIF information in Darktable lighttable mode
-
Try step 3 again=> Darktable successfully recognizes the model automatically
Expected behavior
No response
Logfile | Screenshot | Screencast
No response
Commit
No response
Where did you obtain darktable from?
darktable.org / GitHub release
darktable version
5.0.1
What OS are you using?
Windows
What is the version of your OS?
Windows 10 x64 22H2
Describe your system
No response
Are you using OpenCL GPU in darktable?
Yes
If yes, what is the GPU card and driver?
No response
Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip
No response
Confirmed.
I have 2 voightlanders (35/50mm f/2.0 APO-Lanthar aspherical, Z-Mount). Both used to be found and correctly shown in darktable 4.X. This is no longer the case in 5.X
dt 4.2.1:
lens: 35mm f/2 lens: 50mm f/2
dt 5.0.1
lens: 253 lens: 253
Probably not relevant, but just in case: running on Linux/Debian
@jade-nl Interesting that you get the same number for both lenses.
I found that data by extracting the EXIF with exiv2:
Exif.NikonLd4.LensIDNumber Byte 1 253
That means this value is unreliable. Maybe Voigtländer doesn't provide the same set of metadata as other vendors, or the camera provides those tags even when the model is unknown. Sadly, I don't have other 3rd-party lenses to check that (preferably from other vendors).
Yes, I just double checked and the Exif.NikonLd4.LensIDNumber field for both is 253
The Exif.Nikon3.Lens field shows this:
Exif.Nikon3.Lens 35mm F2
Exif.Nikon3.Lens 50mm F2
An the Exif.Photo.LensModel (a none nikon specific field) this:
Exif.Photo.LensModel 35mm f/2
Exif.Photo.LensModel 50mm f/2
Here's a relevant part of the code that someone else had spotted when I discussed that issue on pixls.us:
else if(Exiv2::testVersion(0,27,4)
&& FIND_EXIF_TAG("Exif.NikonLd4.LensID") && pos->toLong() == 0)
{
// Z body w/ FTZ adapter or recent F body (e.g. D780, D6) detected.
// Prioritize the legacy ID lookup instead of Exif.Photo.LensModel included
// in the default Exiv2::lensName() search below.
if(FIND_EXIF_TAG("Exif.NikonLd4.LensIDNumber"))
_strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
}
else if((pos = Exiv2::lensName(exifData)) != exifData.end() && pos->size())
{
_strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
}
// Check if an "Unknown Lens (xxx)" was returned by using regex,
// and retry Exif.Photo.LensModel as last resort
GMatchInfo *match_info;
GRegex *regex = g_regex_new("\\(\\d+\\)$",
(GRegexCompileFlags) 0,
(GRegexMatchFlags) 0,
NULL);
g_regex_match_full(regex,
img->exif_lens,
-1,
0,
(GRegexMatchFlags) 0,
&match_info,
NULL);
const int match_count = g_match_info_get_match_count(match_info);
if(match_count > 0
&& FIND_EXIF_TAG("Exif.Photo.LensModel"))
{
_strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
}
With the unfortunate use of a macro #define FIND_EXIF_TAG(key) _exif_read_exif_tag(exifData, &pos, key), so the code is a bit of a hack, but it seems to mean
- take "Exif.NikonLd4.LensID" if present
- else take "Exif.NikonLd4.LensIDNumber"
- if what has been found so far has a number between parentheses, take "Exif.Photo.LensModel"
PS: This part definitely needs rewriting; it's ugly. And why does it show the value of "Exif.NikonLd4.LensIDNumber" instead of "1 0", then?
In comparison, Rawtherapee does like this:
if (!make.compare(0, 5, "NIKON")) {
if (find_exif_tag("Exif.NikonLd4.LensID")) {
if (!to_long(pos)) { // No data, look in LensIDNumber.
const auto p = pos;
if (!find_exif_tag("Exif.NikonLd4.LensIDNumber")) {
pos = p; // Tag not found, so reset pos.
}
}
lens = pos->print(&exif);
if (lens == std::to_string(to_long(pos))) { // Not known to Exiv2.
lens.clear();
} else {
lens = validateUft8(lens);
}
}
}
where find_exif_tag captures pos and exif and modifies pos, so that code is also a bit murky, but it seems to keep "Exif.NikonLd4.LensID" if it finds a value and only looks "Exif.NikonLd4.LensIDNumber" if it doesn't (same idea as before).
That doesn't explain why it recognizes the lens since it doesn't have the link from "1 0". I suppose that "Exif.Photo.LensModel" is taken first and I missed it (I only had a glance at the code). @jade-nl, by the way, I see you reported a similar problem with that software with F-mount lenses on a Z body, so that doesn't seem to be fullproof either.
It's apparently difficult to determine the model, but all I can say is that it doesn't work in this case for Darktable, while it does for Rawtherapee (and Affinity Photo 2, whose code isn't public).
Firstly, one should be using exiv2 -Pkvt to check both the original value (v) of the tag, and the internally translated (t) one by Exiv2.
Secondly, there are potentially more tags at play
Exif.Nikon3.LensType 0 (0)
Exif.Nikon3.Lens 350/10 350/10 200/100 200/100 35mm F2
Exif.Nikon3.LensFStops 0 1 12 0 0
Exif.NikonLd4.LensIDNumber 253 253
Exif.NikonLd4.LensFStops 0 F0.0
Exif.NikonLd4.LensID 0 0
Exif.Photo.LensSpecification 350/10 350/10 200/100 200/100 35mm F2
Exif.Photo.LensMake
Exif.Photo.LensModel 35mm f/2 35mm f/2
Exif.Photo.LensSerialNumber
As mentioned, from the dt code, Exif.NikonLd4.LensID is checked first for Z mount lenses, and then Exif.NikonLd4.LensIDNumber for legacy F mount lenses (note that other 3rd party lenses like Laowa, Sigma, and Tamron do use the native Z Exif.NikonLd4.LensID, so this is just poor implementation by Voigtlander; not to mention that strings like "35mm f/2" are not exactly unambigous).
Finally, one should actually be putting 253=foo in the .exiv2/exiv2.ini for the workaround. (Thank Voigtlander for using the same ID for more than one lens.)
What's perhaps interesting is that the "translated" Exif.NikonLd4.LensIDNumber value should've ideally come back as "Unknown Lens (253)", and then the dt code should've fallen back to Exif.Photo.LensModel a bit further below indeed.
One could try 253=Unknown Lens (253) via .exiv2/exiv2.ini to force this...?
So, good luck further debugging to whoever has an itch to scratch here. Could as well be related to a change in exiv2 (0.27.x vs 0.28.x), not necessarily in dt code only...
I don't understand any more.
Now, not only using .exiv2 in my home directory doesn't work any more, but I have to put either "253" or "0". I'm sure that yesterday I did several tests by using / removing that file, and only "1 0" worked, which doesn't make sense (and I did relaunch Darktable each time, but I wasn't resetting the EXIF in lighttable mode).
I'll update the bug description, but I'm baffled. From the Exiv2 description, the exiv2.ini (in Windows) should use the "LensIDNumber" value, so "253". I suppose it also checks "LensID". What a mess.
The conclusion remains the same: Darktable needs to check "Exif.Photo.LensModel" to differentiate the models in this case (but how to determine "this case" is another matter).
Good luck indeed. I agree that Voigtländer could have put more useful metadata.
The "1 0" you had was nonsense for .exiv2 - the "1" came from the count of values in a tag (i.e. the "c" option in the default -Pkyct output); only the value is relevant obviously.
From the Exiv2 description, the exiv2.ini (in Windows) should use the "LensIDNumber" value, so "253". I suppose it also checks "LensID".
Nope. It only overrides LensIDNumber when it comes to Nikons. LensID is a more recent Z series tag and thankfully behaves more predictably (or at least it seems to so far).
What a mess.
It is indeed. Thank all the camera and lens vendors for cooking up all their custom and inconsistent metadata schemes over the decades.
The conclusion remains the same: Darktable needs to check "Exif.Photo.LensModel" to differentiate the models in this case
It does. I suggested the workaround via 253=Unknown Lens (253).
The "1 0" you had was nonsense for .exiv2 - the "1" came from the count of values in a tag (i.e. the "c" option in the default -Pkyct output); only the value is relevant obviously.
Indeed. I don't know how it worked for me yesterday. It must have been a remnant of something else that wasn't properly refreshed in Darktable. Sorry for that!
Nope. It only overrides LensIDNumber when it comes to Nikons. LensID is a more recent Z series tag and thankfully behaves more predictably (or at least it seems to so far).
I only meant that it's what I saw in the exiv2 manual, though the explanation is pretty vague. I didn't check the code, but I believe you.
Yes, the workaround is a good idea if someone has several different models. I'm trusting you on that; I haven't tested it (and from the code, it should indeed work).
Finally, I guess one could add these "253" lenses in the Exiv2 internal translation tables for legacy F mount, like they are in Exiftool (253 is FD in hex). But then you would get a result like "Voigtlander APO-Lanthar 35mm F2" prioritized over "35mm f/2" that would then have a knock-on effect on Lensfun and possibly other apps... Damned if you do, damned if you don't sort of thing. 😮
@kmilos
The 35mm f/2 and 50mm f/2 strings might be unambiguous but they were a string that could be used to trigger rules (dt 4.x), at the moment (dt 5.x) there is no way to do this.
This issue is mainly caused by the info that Voigtländer (and probably other third party lenses) do not provide for their lenses. I personally wouldn't mind if darktable does not want to use unambiguous info to determine something, but I do want the possibility to be able to trigger a self made rule (I certainly know what lens I'm using, no guesswork there).
For me it isn't "just" lensfun and its data, I also have individual body/lens profiles made for the white balance module (true 6502K camera references entries) and no way to auto-trigger them in 5.X.
This is, all in all, a nice issue.
I don't think much has changed re Nikon lens detection between dt 4.8 and 5.0, so someone will have to actually pinpoint to what the problem actually is here, if there is one specific to dt.
Having the possibility to use a "free/open" field and its trigger in the rule making section would make things much easier (and is not limited to this specific issue).
As far as I can remember you have always been limited to: model, make, lens and ISO (and some minor fields). An option to manually set a known metadata field name (for example: Exif.Photo.LensModel) and a specific trigger for that field would be a nice to have. No intricate existence check or fault detection needed: the responsibility lies entirely with the user if this "open" field and trigger option is used).
Just a thought.
When I see the list of models just in the case of Nikon, in the exiv2 project... I wonder if there's a simple exiv2 command to print out those columns for a new lens.
@kmilos Wouldn't it make sense to drop this issue here and that I make a request for a new Voigtländer lens in the exiv2 project, with a sample file? Could that translate the tags we discussed as desired and with more accuracy?
You're welcome to make a PR in exiv2, however there is no timeline/guarantee to when the next release will happen.
The best thing to do here in the meantime is I guess to ensure the Exif.Photo.LensModel fallback still happens w/o the need for a .exiv2 workaround: either add yet another corner case inside the Nikon block or another regex later alongside the existing one... PRs are welcome 😉
The best thing to do here in the meantime is I guess to ensure the
Exif.Photo.LensModelfallback still happens w/o the need for a .exiv2 workaround: either add yet another corner case inside the Nikon block or another regex later alongside the existing one... PRs are welcome 😉
That's what I meant to propose as a change in exiv2 instead, to avoid even more convoluted code in Darktable—and what about the other software?
The idea would be to translate Exif.NikonLd4.LensIDNumber to Unknown lens (253) when a Voigtländer has been recognized (if they all have 253, otherwise put the appropriate value). If that's feasible, of course.
Besides, wouldn't it be awkward to try and determine a fallback in Darktable that doesn't break other lenses?
Optionally, it would also prepend "Voigtlander [etc...]" to Exif.Photo.LensModel.
The idea would be to translate
Exif.NikonLd4.LensIDNumbertoUnknown lens (253)when a Voigtländer has been recognized (if they all have 253, otherwise put the appropriate value). If that's feasible, of course.
I don't think it's exiv2's job to handle specific corner cases like this - it either is able to translate the ID to a pretty string if it has it in its table, or just provides the untranslated ID. There needs to be a general approach. Who says 253 is special? There is a Sigma lens in the Exiftool table that started w/ a 253 as well... There are dozens of other cases where the first ID number is identical across different vendors...
So it seems just the parentheses are missing in exix2's output for Nikons (they're there for Canons for example) and that's worth considering as a way of indicating this is an "untranslated" value (i.e. pretty printing failed). Again, even if that is changed in exiv2, there is no timeline/guarantee when the next release will happen (and it takes time for distros to ship it on top), so a kludgy fix in dt for the next version is better than nothing if you want other users to have this w/o .exiv2 intervention...
Optionally, it would also prepend "Voigtlander [etc...]" to Exif.Photo.LensModel
Currently I don't see how this is possible as that ID 253 is not unique to Voigtlander. Also, there are a few Voigtlander lenses w/ ID 0.
I don't think it's exiv2's job to handle specific corner cases like this - it either is able to translate the ID to a pretty string if it has it in its table, or just provides the untranslated ID.
You know better since you're active in both projects, but I saw this in the contribution doc:
- Contributing Lens Data
In order for the Exiv2 project to support a new lens we need an example image containing the Exif metadata of that lens. This is a good way for non-programmers to contribute to the project and example images can be submitted using the following procedure:
- Create a new Issue by pressing the New issue button here: https://github.com/Exiv2/exiv2/issues,
- In the new Issue, enter/add the lens mount and full lens name for each lens,
- Take a (small) .jpg image (with the lens cap on) with each lens and transfer the .jpg file(s) to disk without processing it in a desktop or server software (this is important to preserve the exif metadata in the file),
- Attach the .jpg image(s) to the Issue (one can just drag-and-drop the image(s) or paste it/them from the clipboard).
Note that we are not only interested in non-supported lenses since we also look for example images to expand and improve the Exiv2 code tests.
And if you look at the code here, everything is already in place, including for a series of Voigtländer lenses: https://github.com/Exiv2/exiv2/blob/v0.27.5-RC1/src/nikonmn_int.cpp#L1898 (and the code below that calculates those values). That's what makes me think it'd be much more efficient to add a couple of models there and fix everything without hack; the Darktable code is barely readable as it is.
As for the respective delays, I don't know if that's a factor. Z-mount Voigtländer lenses have been around for years.
If that had to be fixed in Darktable, perhaps the best would be to use a similar identification system based on a set of "hashed" tag values, but I don't know if anyone has the EXIF information on enough lenses to make sure there's no collision (while that could be checked if the change was made in exiv2).
A shame some of those vendors don't seem aware of the problem.
It's indeed relatively easy to add another line to an Exiv2 lens translation table, and please do feel free to contribute a PR there. But I'm afraid you won't see the effect of it for a while as I explained (those tables are actually in the source code for better or worse and require a new Exiv2 release, it's not like the Lensfun XML database that can be updated independently and continuously)...
I understand.
I just don't see how to fix it on this side, retrospectively (meaning that now I know enough to realize I don't know enough 😉). Perhaps I'll just let this PR run for a little while and see if someone can tackle it.
Many thanks for your inputs, by the way.
A thought...
We might be able to fix/workaround this using lua scripting. We have post-import events and a darktable-image-loaded event that we could trigger on to check that lens information exists.
If the information doesn't exist we could (preferably) use a lookup table to get the information or resort to external tools such as exiftool
Advantages:
- Not tied to a release cycle so it can "keep up"
- Doesn't require any code changes in master
- Capable of complex logic (if this camera, if this model, if this lens code, etc.)
Disadvantages:
- script prejudice (it's a script therefore its [not any good|a hack|etc]
- you have to turn it on :-)
- you may have to update parameters to get it to recognize your specific setup
What am i missing?
As mentioned above I should create an .exiv2 file and add 253=Unknown Lens (253), which i did:
$ exiv2 --verbose --version --grep config_path
exiv2 0.27.6
config_path=/home/druuna/.exiv2
$ cat /home/druuna/.exiv2
[nikon]
253=Unknown Lens (253)
$
What do i need to do now? Because both my 50mm and 35mm voigtlanders are still shown as 253, and are not picked up by lensfun and i also cannot use 253 to trigger either of them (in general or individually).
What do i need to do now?
First verify this works using exiv2 standalone, w/o darktable in the picture? I.e. share output of exiv2 -Pkvt foo.NEF | grep Lens.
For me (exiv2 0.28.5 on Windows) and the file OP shared above I get
$ exiv2 -Pkvt DSC_2409.NEF | grep Lens
Exif.Nikon3.LensType 0 (0)
Exif.Nikon3.Lens 350/10 350/10 200/100 200/100 35mm F2
Exif.Nikon3.LensFStops 0 1 12 0 0
Exif.NikonLd4.LensIDNumber 253 Unknown Lens (253)
Exif.NikonLd4.LensFStops 0 F0.0
Exif.NikonLd4.LensID 0 0
Exif.Photo.LensSpecification 350/10 350/10 200/100 200/100 35mm F2
Exif.Photo.LensMake
Exif.Photo.LensModel 35mm f/2 35mm f/2
Exif.Photo.LensSerialNumber
What do i need to do now? Because both my 50mm and 35mm voigtlanders are still shown as 253, and are not picked up by lensfun and i also cannot use 253 to trigger either of them (in general or individually).
Keep your modification, and for the rest, it depends on which version of Darktable you have, and which version of the 35 and 50 mm you own. In the lensfun file (here, misc.xml), it will recognize the lens based on the <model> tag. For example, the 35 mm f/2 aspherical model II has "35mm f/2" (the same as the first model, unfortunately). So the software should recognize your lens automatically.
I see there's also an "APO-LANTHAR 50mm F2 Aspherical" in the database, but unfortunately with the wrong <model> tag: the author seems to have used <model> instead of <model lang="en">, the latter being for the user's convenience only; e.g. shown in menus, and so on, not to recognize the lens, which is done with the former.
Darktable 5.1 has the 50 mm only, but I think 5.2 now includes my data for the 35 mm.
So, if you have 5.1, add the data in the first post above for the 35 mm (if you own the same model). After that, you could correct the data of the 50 mm (if you own the same model): instead of
<lens>
<maker>Voigtländer</maker>
<model>APO-LANTHAR 50mm F2 Aspherical</model>
you should have
<lens>
<maker>Voigtländer</maker>
<model>50mm f/2</model>
<model lang="en">APO-LANTHAR 50mm F2 Aspherical</model>
I'm assuming here that "50mm f/2" is the correct tag for that lens, but you should check the metadata in a shot to confirm. If you'd rather not modify that entry, you'll simply have to select the lens manually in Darktable.
Make a backup in case you update Darktable in the future.
PS: Affinity Photo 2, which also uses lensfun, has a bug, unless it's been fixed. There, you must invert what's in <model> and in <model lang="en">, and put the correct one first (IIRC, the latter which identifies the tag).
I forgot that you already said which lenses you had. I don't think there's much difference between models I and II, so that should be fine.
Normally, you just have to check that the misc.xml file has your lens for the same <model> as your Exif.Photo.LensModel metadata ("50mm f/2" or "35mm f/2").
The Exif.NikonLd4.LensIDNumber field has changed from 253 253 to 253 Unknown Lens (253) with the .exiv2 file in place:
@kmilos: yeah, i get the same results.
Output for the 50mm:
$ exiv2 -Pkvt /mnt/Downloads/Temp/nikon\ z\ 6_2.50.f2.0.1.nef | grep Lens
Exif.Nikon3.LensType 0 (0)
Exif.Nikon3.Lens 500/10 500/10 200/100 200/100 50mm F2
Exif.Nikon3.LensFStops 0 1 12 0 0
Exif.NikonLd4.LensIDNumber 253 Unknown Lens (253)
Exif.NikonLd4.LensFStops 0 F0.0
Exif.NikonLd4.LensID 0 0
Exif.Photo.LensSpecification 500/10 500/10 200/100 200/100 500/10 500/10 200/100 200/100
Exif.Photo.LensMake
Exif.Photo.LensModel 50mm f/2 50mm f/2
Exif.Photo.LensSerialNumber
And the same for the 35mm:
Exif.Nikon3.LensType 0 (0)
Exif.Nikon3.Lens 350/10 350/10 200/100 200/100 35mm F2
Exif.Nikon3.LensFStops 0 1 12 0 0
Exif.NikonLd4.LensIDNumber 253 Unknown Lens (253)
Exif.NikonLd4.LensFStops 0 F0.0
Exif.NikonLd4.LensID 0 0
Exif.Photo.LensSpecification 350/10 350/10 200/100 200/100 350/10 350/10 200/100 200/100
Exif.Photo.LensMake
Exif.Photo.LensModel 35mm f/2 35mm f/2
Exif.Photo.LensSerialNumber
And, for completeness, the same info without the .exiv2 file:
Exif.Nikon3.LensType 0 (0)
Exif.Nikon3.Lens 350/10 350/10 200/100 200/100 35mm F2
Exif.Nikon3.LensFStops 0 1 12 0 0
Exif.NikonLd4.LensIDNumber 253 253
Exif.NikonLd4.LensFStops 0 F0.0
Exif.NikonLd4.LensID 0 0
Exif.Photo.LensSpecification 350/10 350/10 200/100 200/100 350/10 350/10 200/100 200/100
Exif.Photo.LensMake
Exif.Photo.LensModel 35mm f/2 35mm f/2
Exif.Photo.LensSerialNumber
Exif.Nikon3.LensType 0 (0)
Exif.Nikon3.Lens 500/10 500/10 200/100 200/100 50mm F2
Exif.Nikon3.LensFStops 0 1 12 0 0
Exif.NikonLd4.LensIDNumber 253 253
Exif.NikonLd4.LensFStops 0 F0.0
Exif.NikonLd4.LensID 0 0
Exif.Photo.LensSpecification 500/10 500/10 200/100 200/100 500/10 500/10 200/100 200/100
Exif.Photo.LensMake
Exif.Photo.LensModel 50mm f/2 50mm f/2
Exif.Photo.LensSerialNumber
This is in my misc.xml, which works in darktable v4.X. I'm going to be playing around with the
<lensdatabase>
<lens>
<maker>Voigtländer</maker>
<model>APO-Lanthar 35mm F2 Aspherical</model>
<mount>Nikon Z</mount>
<cropfactor>1.0</cropfactor>
<calibration>
<distortion model="ptlens" focal="35" a="0.00563" b="-0.01645" c="0.00563"/>
<tca model="poly3" focal="35.0" vr="1.0000388" cr="0.0000000" br="-0.0000000" vb="0.9999885" cb="0.0000000" bb="-0.0000000"/>
<vignetting model="pa" focal="35.0" aperture="2.0" distance="10" k1="-0.8726607" k2="-0.1841082" k3="0.3184114"/>
<vignetting model="pa" focal="35.0" aperture="2.0" distance="1000" k1="-0.8726607" k2="-0.1841082" k3="0.3184114"/>
<vignetting model="pa" focal="35.0" aperture="2.8" distance="10" k1="-0.0736904" k2="-0.8451773" k3="0.3679690"/>
<vignetting model="pa" focal="35.0" aperture="2.8" distance="1000" k1="-0.0736904" k2="-0.8451773" k3="0.3679690"/>
<vignetting model="pa" focal="35.0" aperture="4.0" distance="10" k1="-0.2806880" k2="-0.1365354" k3="0.0162612"/>
<vignetting model="pa" focal="35.0" aperture="4.0" distance="1000" k1="-0.2806880" k2="-0.1365354" k3="0.0162612"/>
<vignetting model="pa" focal="35.0" aperture="5.6" distance="10" k1="-0.2373954" k2="-0.2652380" k3="0.1310018"/>
<vignetting model="pa" focal="35.0" aperture="5.6" distance="1000" k1="-0.2373954" k2="-0.2652380" k3="0.1310018"/>
<vignetting model="pa" focal="35.0" aperture="16.0" distance="10" k1="-0.2668197" k2="-0.2786494" k3="0.1465434"/>
<vignetting model="pa" focal="35.0" aperture="16.0" distance="1000" k1="-0.2668197" k2="-0.2786494" k3="0.1465434"/>
</calibration>
</lens>
<lens>
<maker>Voigtländer</maker>
<model>APO-Lanthar 50mm F2 Aspherical</model>
<mount>Nikon Z</mount>
<cropfactor>1.0</cropfactor>
<calibration>
<distortion model="ptlens" focal="50" a="0.00016" b="0.00378" c="-0.00504"/>
<tca model="poly3" focal="50.0" vr="0.9999437" cr="0.0000000" br="-0.0000000" vb="1.0000851" cb="0.0000000" bb="-0.0000000"/>
<vignetting model="pa" focal="50.0" aperture="2.0" distance="10" k1="-0.6228579" k2="-0.3771856" k3="0.3346092"/>
<vignetting model="pa" focal="50.0" aperture="2.0" distance="1000" k1="-0.6228579" k2="-0.3771856" k3="0.3346092"/>
<vignetting model="pa" focal="50.0" aperture="2.8" distance="10" k1="-0.0521756" k2="-0.8002566" k3="0.3449060"/>
<vignetting model="pa" focal="50.0" aperture="2.8" distance="1000" k1="-0.0521756" k2="-0.8002566" k3="0.3449060"/>
<vignetting model="pa" focal="50.0" aperture="4.0" distance="10" k1="-0.2445206" k2="-0.0301234" k3="-0.0612894"/>
<vignetting model="pa" focal="50.0" aperture="4.0" distance="1000" k1="-0.2445206" k2="-0.0301234" k3="-0.0612894"/>
<vignetting model="pa" focal="50.0" aperture="5.6" distance="10" k1="-0.2184369" k2="-0.1646013" k3="0.0785398"/>
<vignetting model="pa" focal="50.0" aperture="5.6" distance="1000" k1="-0.2184369" k2="-0.1646013" k3="0.0785398"/>
<vignetting model="pa" focal="50.0" aperture="16.0" distance="10" k1="-0.1852867" k2="-0.1636803" k3="0.0726456"/>
<vignetting model="pa" focal="50.0" aperture="16.0" distance="1000" k1="-0.1852867" k2="-0.1636803" k3="0.0726456"/>
</calibration>
</lens>
</lensdatabase>
Thanks for the help thus far!
@jade-nl Ok. Next, in dt you need to force refresh of the metadata (or worst case remove the images from the database and import them anew). This should give you finally "35mm f/2" and "50mm f/2".
OK, took me some time but I have it working.
On top of ~/.exiv2 shown earlier I added the above xml snippet to the bottom of the misc.xml file and changed the headers to:
<lens>
<maker>Voigtländer</maker>
<model>35mm f/2</model>
<model lang="en">APO-Lanthar 35mm F2 Aspherical</model>
<mount>Nikon Z</mount>
.
.
.
<lens>
<maker>Voigtländer</maker>
<model>50mm f/2</model>
<model lang="en">APO-Lanthar 50mm F2 Aspherical</model>
<mount>Nikon Z</mount>
.
.
.
Had to remove and re-import the test files to get it to work. That is no problem for me, a full, clean import when I actually switch to 5.2 might even be a healthy thing to do :-)
Anyway: Thanks @kmilos and @blueglyph for the patience and help!
PS: Tested with 5.2 and development 5.3 versions.