No lens correction for Canon G7X Mk II in DT 3.2.1

When trying to use the lens correction module in DT 3.2.1 I am told that data for the camera/lens identified in the metadata is not available and asks me to enter it manually. My camera - Canon Powershot G7X Mark II - is not listed. The closest is the G7X; this preset makes no changes to the image even though distortion is apparent - as I guess is reasonable since that preset is for a different camera. The G7X was replaced in 2016, so the Mark II version is not new, by any means.

The DT help function takes me to an online document, at faq | darktable which discusses the lensfun library and directs me to tell ‘those people’ - at GitHub - lensfun/lensfun: The Lensfun project Git repository. This darktable FAQ entry completely misunderstands the capability of ordinary people who enjoy photography, who wish to use DarkTable, but are not programmers: there is little on this github.com page that I can understand and certainly no apparent way of telling ‘those people’ (who ever they are) about the lack of support for Canon G7X Mark II. It does invite me to build my own version of Lensfun (I think) which of course is impossible for me. I have seen no advice or warning in any Darktable documentation that I must have in-depth programming skills before I can use Darktable.

How do I solve this lack of lens correction support for my camera?

Run lensfun-update-data

And if the camera is still not available … then you have to profile the camera/lens yourself,
which is explained here.

So, looking into lensfun github, the G7X Mark II was added back in Feb 2017, and when I check on my darktable 3.2.1 installation, I do see that camera model listed. What platform are you running darktable on? How did you install it? It could be your lensfun database is not up to date (the lensfun-update-data command should be able to fix this). Having said that, selecting the G7X or the G5X options manually in the lens correction module should also work, since it all points to the same lens correction profile.

In the “image information” module of lighttable, when you select the image what exact text does it show for the model, maker, lens, aperture, focal length, and focus distance? I’m just wondering if the aspect ratio is coming into play…

Where does one look, in DT, for the list of supported camera models? I’m running 3.2.1 under Mint 20 Cinnamon, installed from “darktable_3.2.1-1.1_amd64.deb”, downloaded from directions on darktable.org. I have seen no instructions on how to build this lensfun database and the ‘lensfun-update-data’ command is known to my version of Mint. I see no information that is clearly apparent to me that this database is a pre-requisite for running DT.

The “image information” shows that my camera is indeed a model G7 X Mark II of a Canon camera, with a ‘n/a’ lens, and credible (but poorly chosen, thanks to incompetent operator) values for aperture, exposure, focal length and ISO.

Anyway, I conclude from your informative posting that I am, innocently, missing an app from my Linux installation. I’ll see if I can fix that.

Aha!, that’s the end of that plan: it appears that I am required to do some programming work on Lensfun - specifically to compile it. I have tried at various times since about 2008 to compile source code under Linux, without a single success, for a consistent set of reasons, primarily because the author of the source package always makes invalid assumptions about the environment in which I am requested to do this compiling. There is always some thing missing, so I no longer spend time on this activity; life is too short…

It maybe that I have to abandon my use of Darktable if I am unable to accept the level of distortion in this camera. Up to now, under Lightroom, this has not been an issue.

use the package search of your distribution to find out which package holds lensfun-update-data. maybe something like lensfun-tools.

No need to recompile, you can get it from Pascal’s repository:

sudo add-apt-repository ppa:pmjdebruijn/darktable-release
sudo apt-get update
sudo apt install lensfun

if you run lensfun-update-data you should not need a new lensfun library.

Having installed every package I could find which included the letters ‘lensfun’, I was able to run the updater command. Stopping and then restarting DT nearly worked; it finally fully worked when I deleted my earlier attempts to manually assign a camera/lens, then restarting DT again. At that point a sort of auto-apply of the appropriate lens correction happened, for both this Canon Camera and on images from my Fujifilm camera too.

This is excellent progress from what looked like a show-stopper.

My thanks to all who guided me through understanding and/or resolving these difficulties.

1 Like

Just out of interest, are you able to explain what happens in A windows environment? I was delighted to see that the lensfun functionality seems to be shipped embedded within the Windows version of DT - but how does one update it?

That’s what @darix tells you: lensfun-update-data is a Python script that comes with lensfun and I assume they included in the dt Windows installer. You need to run that from a command prompt window.

Not the optimal solution for folks who don’t “do shell”, so to speak.

Just one slight difficulty with this: Window tells me that there is not a single file of type ‘py’ or file-id ‘lensfun-update-data.py’ on my Windows computer running DT 3.2.1; specifically not in the folder . And I know, from quite a fruitless investment of time, that I am unable to find such a script on the lensfun location on github. Further more a search with Google returns no explicit reference to the data string ‘lensfun-update-data.py’ and a ‘Ctrl-F’ search in the browser on the Google search output results also fails to find any such instance.

So how does that work, then?

The lensfun-update-data script file doesn’t have a .py extension.

Here’s a link to the github file:

Yes, I can get to that location but, not being a skilled programmer (and I don’t think that is or ever should be a prerequisite to use DT), I am unable to find any object with a name like 'lensfun-update-data with a file type not=‘py’, or indeed any file type, that is downloadable and is executable in a Windows environment (my Linux installation seems to be up to date). This file looks like a text file - maybe a program source file of some sort, which obviously cannot be executed in Windows. And this is always and consistently my problem with github.com: it is wholly alien to my skill set so I am unable to do anything with it.

You would need to install Python on your windows box. Doesn’t sound like something you’d want to mess with…

Here’s the link for the current database file: http://lensfun.sourceforge.net/db/version_1.tar.bz2. Or, http://lensfun.sourceforge.net/db/version_2.tar.bz2, if your dt application is using the newer lensfun library, unlikely. You can download either with your broswer, then unpack it in the right place. Oh, you might not be able to unpack .bz2 files on Windows without something like 7zip, or you can unpack it on your linux box and copy the fileset over to the Windows directory.

I know this is not optimal, but that’s where FOSS lens correction is at this time…

Thank you for spending time on this to help me through it. Having now read a little of the ‘blog’ on the lensfun website I understand what you mean by “that’s where FOSS lens correction is…”. My reading of that project is that it is essentially dead, with the implication that no ‘new’ camera/lens combination announced from about April 2019 is going to be supported, unless it is identical to any existing combination. In my mind that starts to ask the question of why a future purchaser of an unsupported camera/lens combination would want to continue using DT or RT (or the many other apps. which rely on lensfun) ? This looks a little like ‘shot self in foot’ unless those somewhat larger development resources of DT/RT do indeed take up this work. Or could a group like RedHat or Ubuntu be persuaded of its merits?

By the way, having now figured out how to unpack the tar.bz2 under Windows (and escaped from the awful clutches of some Australian software troll), I find that my Windows install of DT 3.2.1 is at the latest level already. I also find, to my surprise (and embarrassment) that the lens corrections for the Canon G7 X Mk II are identical to those for the G7 X, it being the same lens (and I should have checked this first). But DT does not appear to apply corrections for G7 X if I attempt to apply them to an image in which the image information says ‘G7 X Mark II’. Understandable, but frustrating if the G7 X Mark II is not an option when manually selecting a lens profile - and it was not in my Linux installation, until I managed to run that lensfun-update-data script (and I still don’t know how…).

Adding a new camera to lensfun is trivial – all you need to know is the crop factor of the camera. If someone purchases a lens that is not currently supported by lensfun, it is not difficult to make some test shots and profile it, and add it in to the local database. I actually see that some people have even done this for a couple of the lenses I own, which are not currently included inthe lensfun database, and they have submitted those len profiles as github PRs, but it seems the profiles are not getting merged into the the main repository. So, I can take those profiles and put them on my local machine, and I can create PRs for any other lenses I profile myself so others can benefit, but it is not ideal for people to have to trawl through a bunch of PRs to see if a lens they own has already been profiled but not yet merged into the main database. There does however remain the open question of who is willing to take up the maintenance of the library…

To be fair about lensfun development, there’s probably not a lot of work to do on the algorithms now, kinda like physics - those things don’t change. They still seem to be updating the database, which then is the important thing.

Camera data in general is a funky thing in FOSS - not much No help from the manufacturers, wonky encodings, the need for third-party divination of such things as black/white points and primaries, even the ambiguous naming of items such as lenses. That FOSS software works as well as it does in the face of all this is quite remarkable, IMHO…

Lens correction is becoming more important as manufacturers include such correction in their design trade space. My Nikon Z 27-70mm f4 is a remarkably sharp lens for a zoom, but its distortion is quite noticeable at most focal lengths. Fortunately for me, lensfun has good distortion correction data AND an unambiguous name for the lens. Regarding the name, Nikon is now including a lens name in the metadata, which they apparently haven’t done until recently. Edit: Oh, and the Nikon metadata includes lens distortion correction data, but it’s not currently readable unless you convert a NEF with the Adobe DNGConverter…

@LateJunction, sorry, some of the above is more of a general lament than help for you… :smiley:

Well spoken :+1:

I submitted a change to the database in early 2019, which got merged fairly promptly into the main repository. Last week I was going to profile a couple of my lenses that were missing, but I thought I better check if there were any open PRs concerning those lenses, and I was surprised to find some open PRs matching my lenses. There are still commits being made into the repository, so I’m not sure why some calibration profiles are being merged and others not.