inter brand adapters & lensfun

I have a Fringer EF2Zii adapter to fit Canon EF lenses on my Nikon Z6iii
Of course, lensfun does not recognize this.

For example, my Canon 17-40mm f/4L USM is reported as VR 17-40mm f/4G on the Nikon.

In the lens correction module, I have to switch the camera to, for example, a Canon R6 Mark ii and then I can select the correct lens and lens correction is applied correctly.

How can I copy the lens correction data from the Canon lens to the Nikon compatible lenses and change the name so that I can apply it automatically in darktable?


Are you sure you want to do that?

What you seem to need is to get lensfun to recognise your body/lens combination. For that, it may be enough to add the mount of your Nikon camera to the description of your Canon lenses (preferably in a copy of the file in a local location, not in the ā€œofficialā€ lensfun database).

Have a look how that is done for third-party lenses (brands like Sigma or Tamron).

Oh, and work on copies of the files, XML is rather precise about syntax, and an error may mean your file becomes unreadable (easy enough to correct, may be hard to find).

1 Like

What is you just ignore the fact that it a Nikon body all together and select a canon camera body and the right lens?

1 Like

He’d have to do that manually each time…

If he makes a .dtstyle out of that, it can be applied at import for all files…

OK, asking the question is answering it after some further fiddling.

I installed Darktable from scratch building from github. I can’t find where Darktable pulls the lens data from, but I could not find it in the github checkout. Nor was there a ~/.local/share/lensfun directory with the xmls
That is what confused me, even after the submodule update thing.
where does the main build get its data from then?

# my build steps
sudo apt-get build-dep darktable
git clone --recurse-submodules --depth 1 https://github.com/darktable-org/darktable.git
cd darktable
git submodule update --init
./build.sh --prefix /opt/darktable-test --enable-ai --build-type Release --install --sudo

So what I did:

lens-update-data

This gives me the ~/.local/share/lensfun/updates/version_1 directory with all the xml’s

Now I needed to get into slr-canon.xml, pull the data for the 17-40mm f/4L
copy that in to mil-nikon.xml and change the info in the maker and model tags to match the exif I get

<lens>                                                                                                                                                                                                                                >
        <maker>Nikon</maker>                                                                                                                                                                                                              >
        <model>VR 17-40mm f/4G</model>
        <mount>Nikon Z</mount>
        <cropfactor>1</cropfactor>                                                                                                                                                                                                        >
        <calibration>                                                                                                                                                                                                                     >
            <distortion model="ptlens" focal="17" a="0.020104" b="-0.047886" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="19" a="0.016917" b="-0.039854" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="20" a="0.015352" b="-0.035125" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="22" a="0.01352" b="-0.027379" c="0"/>                                                                                                                                                       >
            <distortion model="ptlens" focal="24" a="0.012744" b="-0.024334" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="26" a="0.012023" b="-0.02158" c="0"/>                                                                                                                                                       >
            <distortion model="ptlens" focal="28" a="0.008491" b="-0.013858" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="32" a="0.007181" b="-0.008983" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="35" a="0.006829" b="-0.007622" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="37" a="0.006676" b="-0.007544" c="0"/>                                                                                                                                                      >
            <distortion model="ptlens" focal="40" a="0.00464" b="-0.003826" c="0"/>                                                                                                                                                       >
        </calibration>                                                                                                                                                                                                                    >
    </lens>

restarting Darktable, and now the lens is recognized properly on all Z cams
I would have to do that for every EF lens I have and probably every time lensfun is updated. (smells like a scripting adventure)

1 Like

Tried lensfun-add-adapter?

1 Like

yes, it shows the canon lenses, but with their native name, so no automatic matching

Maybe then try using .exiv2 (or exiv2.ini) config file to also fix up the name string as expected natively? (Force metadata re-read will be needed.)

No, that should not be needed. In fact, you do not want to create new lens descriptions (or worse, overwrite existing ones).

What is the lens info you have in your metadata? (using Exiftool or Exiv2)?

And what do you get in darktable after running lensfun-add-adapter picking Nikon Z6_3 as camera and Canon EF as mount? (you may have to reread metadata)

Yes, in theory. However, Canon EF lens ā€œnativeā€ strings come from exiv2 mappings of Canon MakerNote lens IDs as found and written by a Canon body. On a Nikon body, exiv2 only knows about and parses Nikon MakerNotes, and what the adapter puts in there, which I guess is implementation dependent…

Anyhow, lens detection is a major PITA, and getting to and analyzing the various metadata pieces has already been discussed multiple times in the forum. Good luck hunting.

That’s where the ~/.exiv2 file comes in…
That’s a file, btw, not a directory, at least under Linux, which OP seems to be using (given the ā€œsudoā€ use).

I know… Having potentially multiple versions of the same lens reported under different names doesn’t help.
In my case, I have a perfectly valid combination of body and lens, a combination present in the lensfun database, where the lens is reported with a slightly different name than is in the lensfun database => not recognised… .exiv2 helped there.

Lensfun is an external library, meaning you have to (build and) install it separately from darktable. If you want to build darktable from source, you’ll also need the development packages for the external libraries installed on your system.

That’s where the ~/.exiv2 file comes in…
That’s a file, btw, not a directory,

so, how does it work, does it rewrite the exif from the camera?

Lensfun is an external library, meaning you have to (build and) install it separately from darktable. If you want to build darktable from source, you’ll also need the development packages for the external libraries installed on your system.

I understand that now, it gets pulled in using the submodules, apparently it lives under /usr/share/lensfun/version_1 on my debian system, which I found out after this post.

anyway, the adapter is not reporting the ā€˜true’ canon name of the lens, but some Nikon ā€˜equivalent’. The EF 70-200 f/2.8L USM gets reported as VR 70-200mm f/2.8G, so Darktable won’t recognize it automagically.

No, you list the name you want associated with a given lensID value (explained in the link @kmilos gave). But you may have an issue in case you use Nikon lenses using the same lensID value… (each brand decides which values to use for its lenses)