Bug 251920 - Digikam should match lenses on Exif.CanonCs.LensType, not ExifCanonCs.Lens
Summary: Digikam should match lenses on Exif.CanonCs.LensType, not ExifCanonCs.Lens
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Editor-LensCorrection (show other bugs)
Version: 1.4.0
Platform: Mandriva RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-21 13:11 UTC by Buchan Milne
Modified: 2017-08-06 21:08 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 1.5.0
Sentry Crash Report:


Attachments
Trivial patch to use LensType tag on Canon (690 bytes, patch)
2010-09-21 13:20 UTC, Buchan Milne
Details
Patch formatted better to retain comment alignment (686 bytes, patch)
2010-09-21 13:23 UTC, Buchan Milne
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Buchan Milne 2010-09-21 13:11:30 UTC
Version:           1.4.0 (using KDE 4.4.3) 
OS:                Linux

Digikam Lens correction wasn't automatically choosing the correct lens from the lensfun database. Canon cameras return different information for the Lens and LensType tags:

$ exiv2 -pa IMG_2775.JPG |grep Lens
Exif.CanonCs.LensType                        Short       1  Canon EF 70-300mm f/4-5.6 IS USM
Exif.CanonCs.Lens                            Short       3  70.0 - 300.0 mm

While the Lens tag has valid information, the actual Lens model is only correct in LensType.

With the attached patch (only, no other patches), digikam automatically matches the correct lens.

Reproducible: Always

Steps to Reproduce:
Find an image taken on a Canon DSLR (I used Canon EOS 500D) with a lens listed in the lensfun database (I used "Canon EF-S 17-85mm f/4-5.6 IS USM", which is in lensfun 0.2.5, and and "Canon EF 70-300mm f/4-5.6 IS USM" for which I have created a lens profile). Enter the editor, Enhance->Lens->Auto-correction

Actual Results:  
See that you need to select the lens manually.

Expected Results:  
The lens should be selected automatically.

With the attached patch, images taken with both lenses I have resulted in automatic selection of the correct lens profile.
Comment 1 Buchan Milne 2010-09-21 13:20:29 UTC
Created attachment 51856 [details]
Trivial patch to use LensType tag on Canon
Comment 2 Buchan Milne 2010-09-21 13:23:00 UTC
Created attachment 51857 [details]
Patch formatted better to retain comment alignment
Comment 3 caulier.gilles 2010-09-21 13:24:05 UTC
digiKam 1.5.0 has already a similar patch applied.

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp#968

Gilles Caulier
Comment 4 Buchan Milne 2010-09-21 21:19:58 UTC
I applied the fix in http://websvn.kde.org/branches/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp?r1=1165407&r2=1172473 to 1.4.0, and it did not work as expected. Instead of automatically matching the exact lens, it matched a different lens which had a focal length range that covered the shortest focal length. In the quick test I did, instead of matching EF-S 17-85mm f/4-5.6 IS USM, it matched EF-S 10-22mm f/3.5-4.5 USM.

If I instead place the append call with Exif.CanonCs.LensType before Exif.CanonCs.Lens, then it works as expected.

I should probably build from svn, but assuming no other major changes were made, I think this is not fixed.

I can supply a sample image if that would help test (I assume some other Canon DSLRs, such as 40D, work with the Exif.CanonCs.Lens tag, and we actually would prefer both types to work, not one or the other).
Comment 5 caulier.gilles 2010-09-21 22:10:32 UTC
yes send me by mail a test image, or give me a web link to download it

Gilles Caulier
Comment 6 Buchan Milne 2010-09-23 11:53:55 UTC
Looks like it is fixed in trunk in r1178204
Comment 7 Martin Klapetek 2010-10-22 23:13:50 UTC
In 2.0 branch it still detects the wrong lens for "Canon EF-S 18-55mm f/3.5-5.6 IS" as "Canon EF-S 10-22mm f/3.5-4.5 USM". Although the database has only "Canon EF-S 18-55mm f/3.5-5.6" (without the IS), so that may be the problem. I'd propose to do a regular expression match (if it isn't already, not sure).
Comment 8 caulier.gilles 2010-10-23 09:32:09 UTC
Martin,

There is 2 way to fix this problem: the regex is done in liblensfun using GLib2. I suspect that code is not perfect at this place. This can be fixed in lensfun code of course and reported to lensfun project to backport patch. 

This is done by this stage 1 : 

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.cpp#275

Another way is to patch the digiKam lenfun interface to process a regex based on Qt4::QString. Stage 2 is specific to Nikon camera/lens: 

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.cpp#280

There is the last stage :

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.cpp#294

I recommend to add a new stage for Canon camera before last stage, if you choose to patch digiKam lensfun interface source code.

Please patch trunk, i will backport later GSoC 2010 branch.

Gilles Caulier
Comment 9 Martin Klapetek 2010-10-28 13:51:27 UTC
By looking at that, I think that just doing a "reverse search" could be enough. Because now it takes the exiv data and looks into the database. But if this string is just longer by the "IS" or something, it won't match. But if it would be done the other way round - by matching the database to the exiv string, this would work. Consider a use case, when the manufacturer creates just new lenses and adds stuff to the string (like "IS" or something else) but the actual lenses stays the same, this would still get matched with my proposed way. 

Okay, I'll play with it a little and see what I can come up with.