Lens correction: Selecting lenses when using lens adapters


today I ran into a problem with Darktable when I was trying to post-process a RAW that was shot with a Sony Camera (Sonly Alpha 7RII) and a Sigma 150-600 with Canon EF mount. I am using the Sigma MC-11 adapter.

After some discussion on IRC we found that the only way for me to (manually) select the proper lens was to select some camera that is compatible with Canon EF, then select the lens, then switch the Camera back to the Sony. That process doesn’t sound optimal to me and given more people might be using lens adapters, I wonder if we can improve this.

While debugging, we also found that the lens string in the EXIF data doesn’t match what exactly what is in lensfun, so there might be multiple problems:

exiv2 -pv --grep lensmodel/i test.arw
0xa434 Photo        LensModel                   Ascii      46  150-600mm F5-6.3 DG OS HSM | Contemporary 015

Having the auto detection work would of course be nice as well, but being able to manually select independent of the camera type/mount or some kind of support for the adapters in that logic would be nice too.

@darix on IRC asked me to start a topic about this here.



This is a fun combinations of problems

  1. does lensfun already track adapters in their data? lensfun-update-data doesnt seem to show any. given that the big 3 just forced adapters on all their customer (Canon EF-R /Nikon F-Z/ Sigma L mount) I think it would be a good idea to ship the needed informations in lensfun data directly @seebk

  2. the lens model name is not matching between lensfun and exiv2. What can be done about that? or does lensfun do a substring match? the name in the lensfun DB is: Sigma 150-600mm f/5-6.3 DG OS HSM | C @clanmills

  3. darktable/lensfun limit the user to the DBs native to their mount. and it doesnt seem to have a way around this. @Pascal_Obry @houz

Forgot to mention: exiftool shows Sigma 150-600mm F5-6.3 DG OS HSM | C + MC-11

I don’t know what lensfun does. Lens recognition is troublesome because the type of lens is usually not in the metadata. Lens recognition usually involves a guess using other metadata such as max/min aperture/focal length. In Exiv2 v0.26, an option was added to enable the user to overwrite the default lens recognition with a value in the file ~/.exiv2. This is documented in the exiv2 man page released with Exiv2 v0.27.

it still seems that exiftool has some guessing code for the adapter. maybe we can share/port that?:slight_smile:

Yes. I’ve thought of that. I added code to Exiv2 a couple of years ago to call Exiftool being deployed as a web-service. I decided not to deploy this for a variety of reasons such as performance and adopted the ~/.exiv2 work-around to enable users to override the lens definitions “burnt” into the code.

Other reasons not to adopt this included:

  1. Negotiating with Phil/Exiftool (with whom I have a friendly relationship).
  2. Hosting the web-service.
  3. I like to the idea of having a “proper language interpreter” built into exiv2 and lens recognition would be written in that language. Users could download modified “lens scripts”.
  4. I’d like to improve our test suite of images/known lenses.

Many folks have asked me to do more, however no-one has volunteered to embrace challenge.

Well one of my pet projects right now is “improve the data collection and shipping to users for all the data needed to support new gear”

so currently collecting all the different data formats and the content of those that we need.

so maybe in the long run we can have a “camera-update-data” script that will feed exiv libs/tools, raw editors, lensfun.

Robin will you join us at the LGM in Saarbruecken?

1 Like

Regret. I can’t come to LGM in Saarbruecken because on that weekend I will be in Scotland on family business that cannot be changed.

However, I’ve written 7 slides and asked Andreas Schneider to give a 5-minute lightning presentation “Exiv2 Status Update”.

The news from Team Exiv2 is positive and things are moving forward. We have 6 regular contributors and I’m very pleased to no long carry this alone. We face the same situation as every project (both open-source and commercial) by having more requests than engineers.

  1. Lensfun does not track adapters but there is a script to add adapters to the local database: lensfun-add-adapter. The problem is that AFAIK you cannot know from the exif data if an adapter was used or not and some adapters do not allow to detect the lens by the camera. Overall, automatic recognition when an adapter is used would be challenging.
    Still, something like the script above could be implemented in the API itself such that the app UI offers a field to select an adapter/camera combination and the Lensfun database query then considers this in the search process.

  2. Lens model naming has two sub-problems. First, he lens name itself is not stored in the exif data but there is only a lens ID field. And the lens ID is not always unqiue.
    Second, the exiv2 lens name does not match the lens name in the lensfun database. To solve this problem that exiv2 has decoded the ID into a name and this name is different in the Lensfun DB, one could add a lens ID field to the Lensfun database entries. Matching between exif data and Lensfun profiles would then be done on the base of the ID and not with an error prone string compare.

  3. See 1)

Does it affect results if you substitute the camera in the lens correction? I use Sony A7 with Fotga adapter and see no difference. I am have saved a preset for my lens and select them when shooting with the adapter. Maybe that would help to mitigate your issues?