Beginner lens correction question

I have a lens which is returned by exiv2:

Exif.CanonCs.LensType Short 1 Canon EF-M 22mm f/2 STM

And this name is what’s appearing in the lens correction module in darktable v2.4.1 (I’m using Ubuntu 16.04 and I installed darktable via the ppa) I’ve checked in lensfun; support was added in 2014.

But underneath that entry in the lens correction module in darktable it says “camera/lens not found. Please select manually” and it lets me choose canon, then the lens, in the lens box. At this point the controls underneath the lens name magically appear. However, there is no change whatsoever in the picture no matter how much I change the values in the controls.

If I change the empty camera field (above the lens name) I can select a camera, but my camera (canon eos m100) is not in there. (It IS picked up on automatically by the “denoise(profiled)” module though). Once you’ve put a camera in there you cannot remove it! It says “working” when I randomly select a camera, but again, no difference in output.

What do I need to do to get lens correction to pick up this lens, and apply correction for it? For now i’m only using darktable with one camera and one lens, so I don’t mind hard-coding it somehow if that’s possible, although I’ll probably start using it with another camera before long.

First thing’s first:

sudo lensfun-update-data

OK I downloaded, built and installed lensfun (It wasn’t installed before, and - despite what you might find on the internet - it’s not in the usual ubuntu repository). Then I ran your command, but there’s no difference. Do I have to integrate lensfun and darktable in some way?

(Should I be concerned than none of the lensfun xml files contain a reference to my camera? The lens IS mentioned though).

Lensfun only cares about lenses, it doesn’t know about cameras. However the name needs to match exactly! Are you sure that the exif name and the one in lensfun are the same?

It looks like it.

mil-canon.xml:
         <lens>
             <maker>Canon</maker>
             <model>Canon EF-M 22mm f/2 STM</model>
             <mount>Canon EF-M</mount>
             <cropfactor>1.613</cropfactor>
             <calibration>
                 <distortion model="poly3" focal="22" k1="-0.00018" />

etc etc
(hmm. can’t turn off processing of that xml in this forum but it looks valid)

/media/alex/2TB/canon-eos-m100-photos/180320$ exiv2 -pt IMG_0082.CR2 | grep -ai lens
Exif.CanonCs.LensType                        Short       1  Canon EF-M 22mm f/2 STM
Exif.CanonCs.Lens                            Short       3  22.0 mm
Exif.Photo.LensSpecification                 Rational    4  22/1 22/1 0/1 0/1
Exif.Photo.LensModel                         Ascii      17  EF-M22mm f/2 STM
Exif.Photo.LensSerialNumber                  Ascii      11  000003ec2f

Is there a tool for checking lensfun - i just grepped that. Perhaps there are nulls or whitespace or something. Or perhaps the version of lensfun which darktable uses is old/not configured right?

You have answered your own question

You need to report that to lensfun.

Wrong.

To be clear, darktable uses lensfun internally; there was no point in me doing anything with a separate build of lensfun?

Yes.

I think ubuntu 16.04 still ships prehistoric version of lensfun (pre 0.3.x)?
And you can’t (shouldn’t) install lensfun from PPA.

So unless you will then also build darktable against that your local build of lensfun, there is no positive outcome from

@LebedevRI does dt not use the lens database installed system-wide when one does lensfun-update-data?
@xyzzy I edited your post to make your XML and Exiv2 code fragments readable, you can edit your post to learn how I did that.

darktable uses whatever lensfun version it was built against, which in turn uses it’s database.

Since 16.04 still ships with lensfun 0.2.8, naturally, lensfun-update-data does not exist there.
And if you either install newer lensfun from ppa, or build one locally, that will either result in the broken system (see all the posts about lensfun ABI breakage), or the dt will still be using the old lensfun.

This is all totally expected.

Maybe try pmjdebruijn PPA.

Which version of lensfun is darktable currently using (how can I check for myself)?

I’m already using that PPA, as it seemed the happy middle way between building from source and manually downloading and installing zips. Seems that the PPA lags the main build though; which do you think I should be using?

(Thanks for all the quick answers, by the way!)

Maybe

$ dpkg -l | grep lensfun

But the main question is, why are you using rather dated ubuntu version, and then trying to fix it by turning it into slackware via make install?

I’m not using the ubuntu darktable; i’m using the one from the ppa as described on the darktable install page.

I’m a bit confused. Does darktable ship with its own version of lensfun, or does it rely on there already being one installed? What’s the best way of ensuring that darktable and lensfun are up to date; supposing that I contact lensfun and they add support for my camera?

lensfun is used for lens correction.
If the lens correction module isn’t showing your camera or lens, or a wrong one,
then please report that to those folks.

In terms of getting the latest support for my camera/lens from lensfun, is it best if I:

  1. install the latest lensfun
  2. build the latest darktable, from source

?

None of that will help, since lensfun does not know about that camera, as per Lensfun

I understand that, and I’m going to contact them about that.

In the meantime I’m going to try and add an entry to lensfun for my camera, given that the only info apparently needed is the sensor crop, mount etc.

So my question is, having rebuilt lensfun with my/their edit in place, do I just have to rebuild darktable from source on my machine and it’ll pick up those changes?

If the only thing missing initially from lensfun was the camera, then there is zero (actually negative) profit from building local version of lensfun.
Just find the mil-canon.xml installed by liblensfun-data, and edit it, adding that camera of yours.
But first, do report that to lensfun.

If you’re OK with the next generation packaging format, the flatpak of darktable from flathub is shipping lensfun built from git master.

OK, I had four mil-canon.xml files on my system and eventually I found the one which worked.

Interestingly, they’ve tweaked the crop factor for the lens to 1.613, and ditto for the m3, a similar camera to the m100, so i’ve applied those changes too.

Still curious how I’d apply the changes lensfun might eventually make, if you’re recommending not installing lensfun from source.