Bug 184156 - showfoto lensfun select wrong lens
Summary: showfoto lensfun select wrong lens
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Unclassified
Component: Plugin-Editor-LensCorrection (show other bugs)
Version: 1.5.0
Platform: Slackware Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-12 17:16 UTC by Ricardson Williams
Modified: 2016-07-01 09:22 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 3.0.0


Attachments
lens data (1.41 KB, text/plain)
2009-02-19 17:47 UTC, Andi Clemens
Details
lens display in showFoto (211.27 KB, image/png)
2009-02-22 10:41 UTC, Andi Clemens
Details
lensfun -> showfoto: different lens names? (362.59 KB, image/png)
2009-03-10 16:56 UTC, Andi Clemens
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardson Williams 2009-02-12 17:16:02 UTC
Version:           0.10.0-rc1 (using KDE 4.2.0)
OS:                Linux
Installed from:    Slackware Packages

When I open the picture in showfoto and try to fix the lens distortion showfoto didnt select the correct lens.. "always" show "Nikon 24-85mm" didnt fill the Lens model correctl the option "Use Metadata" is ON.
Comment 1 Andi Clemens 2009-02-19 08:25:26 UTC
And what lens should be displayed? For me it is working fine (Nikon D50 and Panasonic DMC-FZ3).
Comment 2 Ricardson Williams 2009-02-19 10:31:09 UTC
In my case should display Nikon 17-55 lens.. and always show 24-85mm, the machine model no problem..
Comment 3 Andi Clemens 2009-02-19 12:54:27 UTC
Can you attach an example image? If you don't want to provide it here, you can sent it to me by mail.

Andi
Comment 4 Andi Clemens 2009-02-19 16:26:19 UTC
Right now I can't tell if it is a bug in digiKam or lensfun, but it doesn't work for my Nikkor 18-55mm, 1:3,5-5.6G ED AF S-DX, too.
If you take a look at the image properties tab, you see a strange lens name:
48 50 48 49 118 202 103 220 10 206 242 106 190 40 168 204 136 249 18 222 49 194 47 38 240 43 86 109 114 111 86 

I don't think this is correct :-)
Need to do further investigations.

Andi
Comment 5 caulier.gilles 2009-02-19 16:53:17 UTC
Nikon lens name is extracted to makernote using Exiv2. Nikon is know to encrypt informations (:=(((. I remember a topic about in Exiv2 bugzilla. I don't know if it's solved now.

Gilles
Comment 6 Andi Clemens 2009-02-19 17:18:39 UTC
Right, mostly all Nikon lens seem to fail, but there are fixes for 0.18.1.
I will check the SVN version and see if it is working in there.
Comment 7 Andi Clemens 2009-02-19 17:47:08 UTC
Created attachment 31476 [details]
lens data

I compiled latest trunk and at least your lens is detected by the command line tool, see the attachment. Mine is still not recognized :-(

But digiKam / showFoto still displays the strange number code in the Photograph Information tab. Why?
I recompiled libkexiv2 etc and digiKam, but it is not read properly... I know digikam uses db for this data, too, but I tested also with showFoto and no lens data is available.

Gilles,

any idea?
Comment 8 caulier.gilles 2009-02-19 18:14:40 UTC
Sound like something is missing in libkexiv2 to decode these informations.

Andreas,

There is something special in Exiv2 command line tool to decode Nikon Lens info ?

Gilles
Comment 9 Andreas Huggel 2009-02-20 01:08:05 UTC
Gilles,

No, the command line tool doesn't do anything special, this is done in the library. But what about this:

http://uk.groups.yahoo.com/group/exiv2/message/1408

Decrypting only works if digiKam/libkexiv2 use the new method to call the pretty-print function.
Comment 10 Andreas Huggel 2009-02-20 16:52:36 UTC
Andi,

I've updated the Nikon lens list to the latest version (this database is a separate project maintained by Robert Rottmerhusen). Can you svn update and try again? If your lens is still not recognized, please send me an image together with the exact lens name (see the list near the end of nikonmn.cpp file for details/comparison).

Andreas
Comment 11 Andi Clemens 2009-02-21 14:59:56 UTC
Andreas,

somehow it seems to work now and then, I'm using the SVN built from 4 days ago.

Error: Directory NikonPreview with 8224 entries considered invalid; not read.
Exif.Nikon3.LensType                         Byte        1  D G
Exif.Nikon3.Lens                             Rational    4  18-55mm F3.5-5.6
Exif.Nikon3.LensFStops                       Undefined   4  5.33333
Exif.Nikon3.LensData                         Undefined  31  Nikon AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED

The first error message is weird... but at least the lens is detected. Sometimes it happens that it only reads those numbers again.

I will compile latest trunk later on, right now I'm too busy.
Still in digiKam it is not working, but that seems to be our fault then.

Andi
Comment 12 caulier.gilles 2009-02-21 17:11:42 UTC
Andi, Andreas,

Code relevant to Lens detection is here :

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

Gilles
Comment 13 Andreas Huggel 2009-02-22 08:01:32 UTC
Ok. I suggest this fix in KExiv2::getExifTagString (kexiv2exif.cpp, line 679): Just replace

684         Exiv2::ExifData exifData(d->exifMetadata);
...
688             std::ostringstream os;
689             os << *it;
690             QString tagValue = QString::fromLocal8Bit(os.str().c_str());

with

684         const Exiv2::ExifData& exifData(d->exifMetadata);
...
688             std::string val = it->print(&exifData);
689             QString tagValue = QString::fromLocal8Bit(val.str().c_str());

or is there a particular reason why the Exif metadata container must be copied in line 684?

Andreas
Comment 14 caulier.gilles 2009-02-22 09:35:22 UTC
Andreas

>or is there a particular reason why the Exif metadata container must be copied
>in line 684?

With older Exiv2 (< 0.14), yes to prevent crash with mutithreading. With recent Exiv2, it work fine.

Gilles
Comment 15 caulier.gilles 2009-02-22 09:52:02 UTC
Andreas,

QString tagValue = QString::fromLocal8Bit(val.str().c_str());

must be :

QString tagValue = QString::fromLocal8Bit(val.c_str());

... else it doesn't compile :

[ 11%] Building CXX object libs/libkexiv2/libkexiv2/CMakeFiles/kexiv2.dir/kexiv2exif.o
/home/gilles/Documents/devel/SVN/trunk/kdegraphics/libs/libkexiv2/libkexiv2/kexiv2exif.cpp: In member function ‘QString KExiv2Iface::KExiv2::getExifTagString(const char*, bool) const’:
/home/gilles/Documents/devel/SVN/trunk/kdegraphics/libs/libkexiv2/libkexiv2/kexiv2exif.cpp:690: error: ‘struct std::string’ has no member named ‘str’

Gilles
Comment 16 caulier.gilles 2009-02-22 09:53:04 UTC
SVN commit 929807 by cgilles:

patch exiv2 with Andreas tip. Need to be tested.
CCBUGS: 184156


 M  +5 -5      kexiv2exif.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=929807
Comment 17 caulier.gilles 2009-02-22 09:54:02 UTC
Andi,

libkexiv2 from trunk is patched. can you try again ?

Gilles
Comment 18 caulier.gilles 2009-02-22 10:07:22 UTC
Andreas,

it->print() function exists since which Exiv2 version ?

Gilles
Comment 19 Andi Clemens 2009-02-22 10:19:59 UTC
Gilles,

it is working in showFoto, but not in digiKam. I guess the lens value is saved in the database.
Lensfun still selects the wrong lens, but I guess they have their own database.
Comment 20 Andi Clemens 2009-02-22 10:41:50 UTC
Created attachment 31536 [details]
lens display in showFoto
Comment 21 caulier.gilles 2009-02-22 11:51:53 UTC
>lens display in showFoto

ok. this is want mean that patch work fine.

>it is working in showFoto, but not in digiKam. I guess the lens value is saved
>in the database.

yes it's stored in DB. you must sync again DB with photo metadata

>Lensfun still selects the wrong lens, but I guess they have their own database.

yes, if lensfun do not have an entry relevant of your lens, nothing special will be done. At least a message in plugin must be displayed if lens is not found...

Gilles
Comment 22 Andreas Huggel 2009-02-22 17:08:17 UTC
> it->print() function exists since which Exiv2 version ?

std::string print(const ExifData* pMetadata =0) const;
in class Exiv2::Metadatum exists since 0.18-pre2. Before that it was print() without any argument.

Andreas
Comment 23 Andi Clemens 2009-03-10 11:52:18 UTC
*** Bug 169214 has been marked as a duplicate of this bug. ***
Comment 24 Andi Clemens 2009-03-10 16:56:05 UTC
Created attachment 31993 [details]
lensfun -> showfoto: different lens names?

I don't know if this is an issue, but I compared a lot of images now (taken with different cameras of course) and lensfun always displays another lens name then showfoto / exiv2.
Because of this everytime the first item in the camera lens combobox of lensfun plugin is selected, although the lens name is listed in the combobox.
In this screenshot you can see that the first lens in the list was chosen, but the actual lens is listed in the combobox, too.
There seem to be significant differences in the names from lensfun and exiv2, this is why the lenses are never selected correctly.

I can remember that my lens was displayed as "Nikkor  18-55mm Lens...." in showfoto some weeks ago, but not it only reads "18-55mm F3.5-5.6", so maybe this is the reason lensfun auto detection is not working at all.

Did exiv2 change the name resolution in some way?

Andi
Comment 25 Andreas Huggel 2009-03-10 17:27:44 UTC
> I can remember that my lens was displayed as "Nikkor  18-55mm Lens...." in
> showfoto some weeks ago, but not it only reads "18-55mm F3.5-5.6", so maybe
> this is the reason lensfun auto detection is not working at all.
>
> Did exiv2 change the name resolution in some way?

No it should still be the same, although I've updated the Nikon lens list recently - http://dev.exiv2.org/repositories/revision/exiv2/1751

Is there a difference between showfoto+exiv2-SVN and exiv2-SVN output?
Or between exiv2-SVN and exiv2-0.18?

Andreas
Comment 26 Andi Clemens 2009-03-12 14:23:29 UTC
I can't see any differences.
But maybe lensfun is expecting the LensData field?

Exif.Nikon3.LensType                         Byte        1  D G
Exif.Nikon3.Lens                             Rational    4  18-55mm F3.5-5.6
Exif.Nikon3.LensFStops                       Undefined   4  5.33333
Exif.Nikon3.LensData                         Undefined  31  Nikon AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED

This looks more like the string in lensfun then the Lens value we seem to use.
Comment 27 caulier.gilles 2010-01-25 14:35:18 UTC
Andi,

Whats news there ? It's Exiv2 or lensfun issue ? Solved with last version ?

Gilles Caulier
Comment 28 Andi Clemens 2010-01-25 22:45:44 UTC
Hmm don't know what's wrong here, but I can still reproduce it.
Comment 29 Jens Mueller 2010-04-11 00:15:09 UTC
I added some additional lensfun search in rev1111465. Andi, others: can you please try it again? The one of my nikon lenses that is in lensfun db is found and selected.

Jens
Comment 30 Jens Mueller 2010-04-15 00:05:46 UTC
SVN commit 1114931 by jmueller:

do lensfun search not only for lenses, do it also for make and model

CCBUGS: 184156

 M  +26 -2     lensfuncameraselector.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1114931
Comment 31 caulier.gilles 2010-09-18 10:39:16 UTC
Jens,

I work hard to improve metadata parsing and detect better lens type to pass on LensFun. I fully rewritten the code about in trunk. Please take a look

The goal of this work is to provide a new BQM tool to fix lens distorsion... The tool must be able to apply correction automatically...

Note : in digikam/libs/dimg/filters/lens, there is a new small command line test program to parse an image and detect lens type. All is printed to the console. The program is to hack parsing metadata code from digiKam lensfuniface... 

Gilles Caulier
Comment 32 caulier.gilles 2010-09-18 10:41:06 UTC
For BQM lensfun tool, take a look there :

https://bugs.kde.org/show_bug.cgi?id=216353

Gilles Caulier
Comment 33 caulier.gilles 2010-09-18 10:44:57 UTC
Jens,

The new code to parse metadata is not in lensfun widget anymore. I migrarted it to lensfun iface, to make a BQM tool more easily.

Look this method :

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

Please, test, hack, and report. I need help there. Thanks in advance

Gilles Caulier
Comment 34 Gandalf Lechner 2010-09-18 21:49:26 UTC
With a fresh svn checkout, the automatic lens distortion correction crashes as soon as I select it from the menu. In the console I read

digikam(19485)/digikam (core) Digikam::EditorToolThreaded::slotEffect: Preview  "Linsenautokorrektur"  started...
digikam: symbol lookup error: /usr/lib/kde4/digikamimageplugin_enhance.so: undefined symbol: _ZN7Digikam12LensFunIface17setFilterSettingsERKNS_16LensFunContainerE
Comment 35 caulier.gilles 2010-09-18 22:22:46 UTC
Make clean all, and recompile/install whole digiKam.

Gilles Caulier
Comment 36 caulier.gilles 2010-09-29 15:32:56 UTC
SVN commit 1180943 by cgilles:

deal with Canon Lens and LensType tags when Lensfun search lens description from metadata
If Exiv2 cannot decrypt lens data, it will return a number, not a string.
CCBUGS: 184156 


 M  +2 -1      dmetadata.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1180943
Comment 37 Gandalf Lechner 2010-10-08 10:33:32 UTC
The lenscorrection has improved a lot already, thank you! My favourite camera/lens combination is now correctly detected. However, many lenses are still not detected corrected automatically, although they are available in the list.

Correctly detected:
Camera:
Canon EOS 7D
Lenses:
Canon EF-S 17-55mm f/2.8 IS USM


Not correctly detected:
Camera:
Canon EOS Kiss Digital X (=400D)
Lenses:
Canon EF-S 18-55mm f/3.5-4.5 USM
Canon EF 100mm f/2.8 Macro
Sigma 10-20mm f/4-5.6
Sigma 30mm f/1.4 DC HSM
Canon 70-300 mm f/4-5.6 IS USM
Comment 38 caulier.gilles 2010-10-08 11:15:51 UTC
Gandalf,

For all lens not detected, i need sample images to test. Please send me files by mail.

Thanks in advance

Gilles Caulier
Comment 39 Gandalf Lechner 2010-10-08 22:52:50 UTC
(In reply to comment #38)
> Gandalf,
> 
> For all lens not detected, i need sample images to test. Please send me files
> by mail.

Ok, I send you some images.

Gandalf


> 
> Thanks in advance
> 
> Gilles Caulier
Comment 40 caulier.gilles 2010-10-09 15:14:05 UTC
SVN commit 1184220 by cgilles:

wrap around Canon 400D camera to query lensfun DB properly.
CCBUGS: 184156


 M  +14 -4     lensfuniface.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1184220
Comment 41 caulier.gilles 2010-12-09 14:25:50 UTC
What's news in this file ?

Can someone update sate of this entry using current code from svn (not 1.6.0). in trunk i sync lensfun code again with new profiled camera lens.

Anyway, i think it can be closed now. Future work will be done in lensfun library as well, not in digiKam & co

Gilles Caulier
Comment 42 Gandalf Lechner 2010-12-10 08:57:51 UTC
Regarding comment #37,

Canon EOS Kiss Digital X (=400D)
Canon EF-S 18-55mm f/3.5-4.5 USM
Sigma 10-20mm f/4-5.6
Sigma 30mm f/1.4 DC HSM

now seem to be correctly detected.

What's not working for me yet are the lenses

Canon EF 100mm f/2.8 Macro
Canon 70-300 mm f/4-5.6 IS USM

The 70-300mm is not in the list, but the 100mm is, but still the lenscorrection tool likes to pick some wide angle canon lens instead.

Gandalf
Comment 43 caulier.gilles 2011-12-17 19:06:27 UTC
Williams,

This file still valid using digiKam 2.4 ?

Gilles Caulier
Comment 44 caulier.gilles 2013-01-07 12:01:38 UTC
Following comment #42, and my personal tests, I cannot reproduce the problem with current implementation from git/master (next 3.0.0).

If lens identification still missing, please report to Exiv2 project to patch maker lens database relevant.
If lens profile still missing, please report to LensFun project to patch database relevant.

Gilles Caulier