Lens Correcting not detecting correct focal length and aperture

Hi guys,

no matter which camera or lense I use: the Lens Correction module detects the right camera and lens but literally never the correct focal length and aperture. This is happening in different darktable versions between 4.4.0 and 5.0.0 on Linux and MacOS, so it’s rather nothing specific to the lensfun database or darktable version. I’ve seen a few video tutorials on Lens Correction, where both values were detected correctly, so on one hand this seems to be the planned behaviour, on the other hand I can’t see any sense in setting auto presets for different lenses when I have to manually adjust two of the most important values for each image.

I honestly don’t know where to start and it is of course absolutely possible that the problem is sitting in front of the computer. Could someone please confirm the described behaviour or present any hints how to solve that slightly annoying issue?

please provide a sample image and the xmp with your settings so someone can try to reproduce. It doesn’t help to count those having issues without samples that fails …

If you have made some preset that specifies some settings, you should not do that. The only settings stored for a preset or style for Lens correction should be to it on. When you store specific settings, the module no longer uses auto detection.

It sounds like Mica is correct and just turning on the module will let it automatically detect the lens and zoom setting. No need to use a preset to activate this module.

This is often the case when I have a DT problem.

It wasn’t 100% clear that this is what OP is doing, but it sounded plausible.

I have an auto preset and that still allows detection of focal length.

1 Like

Here it is:
lens_lens correction on.dtpreset (1011 Bytes)

@MStraeten Thanks for your reply. Here are two sample images with XMPs. 9983 has no lens correction, 9985 uses a preset named ‘Fujfilm 18-55’. In this case Lens Correction falsely identifies the camera as ‘Fujifilm X-E2S’, while ‘~XE3’ would be the correct model (I use both of them) and neither focal length nor aperture are detected correctly.

sample_9985.raf.xmp (8.9 KB)
sample_9985.raf (48.2 MB)
sample_9983.raf.xmp (7.0 KB)
sample_9983.raf (48.3 MB)

An here ist the mentioned preset (I am allowed only 4 uploads, sorry).

lens_Fujifilm 18-55.dtpreset (1.1 KB)

@paperdigits @Terry Thanks a lot for your hints regarding the preset. As far as I can see my use of lens presets is pretty basic (see the example screenshot). I use presets for seven or eight different Fujifilm and Nikon lenses, none of them somehow exotic. In rare cases the auto preset by matching lens names fails completely, while focal length and aperture are always wrong (apart from random matches).

setting_fujifilm1855

@kofa Of course I thank you too – it seems to be impossible to address more than 2 contributors in one post (strange rule btw).

Addendum: Meanwhile I examined your preset. Main difference to mine is the missing lens relation, so you seem to rely on the auto detection of the lens, while my presets define to use lens preset X when lens name is Y. I would prefer to do it your way, but as far as I remember, lenses were often not detected correctly in the past although they existed in the lensfun database. Anyway: I will try to disable all lens presets and do it your way, maybe that helps.

Addendum 2: I deleted all Lens Correction presets and set a new one following your approach. Indeed, everything works absolutely fine then as long as the lens can be identified. Some do (eg. the mentioned Fujifilm 18–55) some don’t (eg. Nikon 28-105, Tokina 100 Macro). All ‘unknown’ lenses can easily be selected in the lens fun dropdown, but the process is a bit tedious, as it has to be done for each image. And as soon as I set a second preset like 'Use ‘Tokina 100’ when ‘Lense’ is ‘100.0 mm f/2.8’ the main problem with wrong focal length and aperture is back. Even more: Having a generic ‘Always on’ and a second ‘Use when X’ leaves me with two instances of the Lens Correction module where the generic instance laments as it cannot find the lens while the specific one obviously considers focal length and aperture values as part of the preset. At least the latter seems counterproductive, even prime lenses will at least vary their aperture values, so I can hardly imagine that this happens by design.

ad addendum2:
if the lens isn’t properly identified, then have a look at: User's portal · darktable-org/darktable Wiki · GitHub.
So you can override the exiv2 lens identification by an identification compatible to lensfun database.

I opened image 9985 and saw your preset using your xmp file. I then tried resetting to default values and the correction method was set to “embedded metadata” and did no correction that I could see. However, if I then changed the correction method to “Lensfun database” it appears to me that the correct camera and zoom setting were identified. This method adds an extra click or two to the work process but doesn’t seem too much trouble to me. I am not sure if a reliable preset can be made for this. I am also not sure if this would work with all your lenses especially if an adaptor is used to attach a nikon lens to your Fujifilm camera.

EDIT: I just checked other Fujifilm images I have downloaded from this forum and notice they too open in “embedded metadata” rather than “Lensfun database”. I wonder if this could be addressed as a feature request or bug fix? Not owning a Fujifilm camera (my favourite camera that I don’t own) I never noticed this issue before.

I hope you find a solution that works for you.

image

image

Thanks @MStraeten – thinking about the problem led me to the basically same conclusion: using a preset like @kofa suggested but solve the mentioned problem with wrongly identified lenses. I’ve read on the exiv2 mappings somewhere before and was reasonably optimistic to get that done as it sounds logical and doable. But only until I got the first results:

$ exiv2 -pa --grep lens/i example.dng
Exif.Photo.LensSpecification                 Rational    4  1000/10 1000/10 28/10 28/10
Exif.Photo.LensModel                         Ascii      15  100.0 mm f/2.8
Exif.Image.LensInfo                          Rational    4  1000/10 1000/10 28/10 28/10
Xmp.aux.LensInfo                             XmpText    27  1000/10 1000/10 28/10 28/10
Xmp.aux.Lens                                 XmpText    14  100.0 mm f/2.8
Xmp.crs.LensProfileEnable                    XmpText     1  1
Xmp.crs.LensManualDistortionAmount           XmpText     1  0
Xmp.crs.LensProfileSetup                     XmpText    12  LensDefaults
$ exiv2 -pv --grep lens/i example.dng 
0xa432 Photo        LensSpecification           Rational    4  1000/10 1000/10 28/10 28/10
0xa434 Photo        LensModel                   Ascii      15  100.0 mm f/2.8
0xc630 Image        LensInfo                    Rational    4  1000/10 1000/10 28/10 28/10

We see the continuation of the image meta data madhouse: each participant writes whatever he wants whereever he likes, and innocent victims like me can try to entangle their mess. My lenses are made by only three manufacturers and not one of them is even able to keep his own patterns but obviously needs to reinvent the wheel with every new model. In the example above I can neither find an ID nor do I understand what to write where.

Since everything in me refuses to waste my limited liftetime on crap like this, I tend to skip the automation promises of Lens Correction and do it manually – all in all it will probably be faster.

@Terry I never tried to use XMPs of others to test something, so it’s hard to tell whether a behaviour is determined by the XMP values or your defaults. in the 9985.raf.xmp there is this tag:

<rdf:li
darktable:num="12"
darktable:operation="lens"
darktable:enabled="1"
darktable:modversion="10"
darktable:params="gz05eJxj [...] AAQ5xV/"
darktable:multi_name="Fujifilm 18-55"
darktable:multi_name_hand_edited="0"
darktable:multi_priority="0"
darktable:blendop_version="13"
darktable:blendop_params="gz12e [...] Bh0E"/>

I would interpret it as “use Lens Correction preset named ‘Fujifilm 18-55’” and as this preset does not exist on your database there might be a fallback to your default. If I do nothing at all and just activate a plain Lens Correction instance, it starts with ‘Embedded metadata’ too. As it is completely unclear what this setting does, I never used it and can’t tell if it’s a bug or a feature, but I am pretty sure it is nothing Fujifilm specific, as the same happens with Nikon files.

Its documented: darktable 4.6 user manual - lens correction

Thanks @paperdigits for directing me to the user manual which explained why embedded metadata was selected. I revisited image 9985 and must correct my previous 3am I really should go to bed observation. The embedded metadata did apply a correction. I tested this on some more Fujifilm images and corrections are applied if the lens is detected by the camera. I presume some images people have non-Fuji lenses attached via adaptors so no lens metadata is detected. However, the correction is different to the Lensfun database correction. It is hard for me to say if one is better or more correct than the other from the images I have.

I feel maybe a picture of a subject like this doorway might make it clearer as too how effective the lens correction for distortion is being handled by the two options available for Fujifilm camera users.
Barrel distortion_01

It seems the Fujifilm camera embeds the corrections into the RAW file so it would be specific if that is the case. Also on the Nikon files I looked at the Lensfun database was used as the method and identified both the camera and lens used.

Happy new year to all of you and thank you very much for the new Darktable 5.1 version. Sorry to post to this thead but I didn’t want to open a new one as my question is related to lensfun, too: My lens (Tokina 12-28/f4.0 DX) is only partly supported, i.e. there is no vignette correction data available for that lens. Now I wanted to create an exposure style with a drawn mask and apply it (automatically) to images taken with that lens. Unfortunately the mask is not saved wth the style, only the exposure settings …

Has anybody an idea how I can create and apply an “un-vignetting” exposure style?

Edit: … I just saw that there is already a similar feature now included within the lens correction module. I’ll try to play around with this, probably it’s just sufficient.

Why not shoot the vignette correction images for le s fun?

hmm … could be an idea. That indeed would be the best solution, I’ll need to dig a bit deeper into how to do that.