Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Canon EF 80-200mm f/4.5-5.6 II" identified as "Canon EF 80-200mm f/4.5-5.6" #1906

Closed
John55h opened this issue Sep 16, 2021 · 19 comments · Fixed by #1932
Closed

"Canon EF 80-200mm f/4.5-5.6 II" identified as "Canon EF 80-200mm f/4.5-5.6" #1906

John55h opened this issue Sep 16, 2021 · 19 comments · Fixed by #1932

Comments

@John55h
Copy link
Contributor

John55h commented Sep 16, 2021

This issue causes darktable to apply lens correction "Canon EF 80-200mm f/4.5-5.6" to images using "Canon EF 80-200mm f/4.5-5.6 II"

$ exiv2 -V
exiv2 0.27.4

exiv2 0.27.4 output for Canon EF 80-200mm f/4.5-5.6 II

$ exiv2 -pt  IMG_9824.jpg |grep -ai lens
Exif.CanonCs.LensType                        Short       1  Canon EF 80-200mm f/4.5-5.6
Exif.CanonCs.Lens                            Short       3  80.0 - 200.0 mm
Exif.Canon.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSpecification                 Rational    4  80/1 200/1 0/0 0/0
Exif.Photo.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSerialNumber                  Ascii      12  0000000000

The original lens "Canon EF 80-200mm f/4.5-5.6" (I believe) is tagged 28 in TagDetails canonCsLensTtype[] (see canonmn_int.cpp) and the "II" version is tagged 38.

Output of exiv2 for Canon EF 80-200mm f/4.5-5.6 II after applying the patch below:

--- canonmn_int.cpp_0.27.4  2021-06-15 15:08:36.000000000 +0100
+++ canonmn_int.cpp 2021-09-15 20:33:07.463988944 +0100
@@ -1676,7 +1676,7 @@
         {   37, "Tamron AF 28-300mm f/3.5-6.3 XR Di VC LD Aspherical [IF] Macro"}, // 2
         {   37, "Tamron SP AF 17-50mm f/2.8 XR Di II VC LD Aspherical [IF]" }, // 3
         {   37, "Tamron AF 18-270mm f/3.5-6.3 Di II VC LD Aspherical [IF] Macro"}, // 4
-        {   38, "Canon EF 80-200mm f/4.5-5.6"                               },
+        {   38, "Canon EF 80-200mm f/4.5-5.6 II"                            },
         {   39, "Canon EF 75-300mm f/4-5.6"                                 },
         {   40, "Canon EF 28-80mm f/3.5-5.6"                                },
         {   41, "Canon EF 28-90mm f/4-5.6"                                  },
$ exiv2 -pt  IMG_9824.jpg |grep -ai lens
Exif.CanonCs.LensType                        Short       1  Canon EF 80-200mm f/4.5-5.6 II
Exif.CanonCs.Lens                            Short       3  80.0 - 200.0 mm
Exif.Canon.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSpecification                 Rational    4  80/1 200/1 0/0 0/0
Exif.Photo.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSerialNumber                  Ascii      12  0000000000

Darktable now correctly identifies this lens as version "II" and does not apply any correction (no lensfun data), I hope to add correction data to lensfun for this lens at some point.

Small jpeg with "Canon EF 80-200mm f/4.5-5.6 II"
IMG_9832

@kmilos
Copy link
Collaborator

kmilos commented Sep 17, 2021

The original lens "Canon EF 80-200mm f/4.5-5.6" (I believe) is tagged 28 in TagDetails canonCsLensTtype[] (see canonmn_int.cpp) and the "II" version is tagged 38.

Can you perhaps try to find some more supporting evidence for these 28 and 38 ID mappings independent of exiv2?

Exiftool seems to have the same duplication, I wouldn't be surprised that's where exiv2 inherited it from...

@clanmills
Copy link
Collaborator

You can modify the lens recognition on your machine using the configuration file ~/.exiv2. This is documented in the man page. https://exiv2.org/manpage.html

@clanmills
Copy link
Collaborator

Thank You for providing a test image. Here's the configuration file being used.

Before:

519 rmills@rmillsm1:~/Downloads $ curl -LO https://user-images.githubusercontent.com/74864103/133683539-5f296dc3-e156-46c1-86eb-0742cb32ebc8.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 56011  100 56011    0     0   320k      0 --:--:-- --:--:-- --:--:--  331k
520 rmills@rmillsm1:~/Downloads $ exiv2 -g lens/i 133683539-5f296dc3-e156-46c1-86eb-0742cb32ebc8.jpg 
Exif.CanonCs.LensType                        Short       1  Canon EF 80-200mm f/4.5-5.6
Exif.CanonCs.Lens                            Short       3  80.0 - 200.0 mm
Exif.CanonCf.LensAFStopButton                Short       1  0
Exif.Canon.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSpecification                 Rational    4  80/1 200/1 0/0 0/0
Exif.Photo.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSerialNumber                  Ascii      12  0000000000
521 rmills@rmillsm1:~/Downloads $ exiv2 -pv -g lens/i 133683539-5f296dc3-e156-46c1-86eb-0742cb32ebc8.jpg 
0x0016 CanonCs      LensType                    Short       1  38
0x0017 CanonCs      Lens                        Short       3  200 80 1
0x0009 CanonCf      LensAFStopButton            Short       1  0
0x0095 Canon        LensModel                   Ascii      70  EF80-200mm f/4.5-5.6 II
0xa432 Photo        LensSpecification           Rational    4  80/1 200/1 0/0 0/0
0xa434 Photo        LensModel                   Ascii      70  EF80-200mm f/4.5-5.6 II
0xa435 Photo        LensSerialNumber            Ascii      12  0000000000
522 rmills@rmillsm1:~/Downloads $

Configuration File:

522 rmills@rmillsm1:~/Downloads $ bbedit ~/.exiv2 
523 rmills@rmillsm1:~/Downloads $ cat ~/.exiv2 
[canon]
38=Put the lens name here
524 rmills@rmillsm1:~/Downloads $ 

After:

524 rmills@rmillsm1:~/Downloads $ exiv2 -g lens/i 133683539-5f296dc3-e156-46c1-86eb-0742cb32ebc8.jpg 
Exif.CanonCs.LensType                        Short       1  Put the lens name here
Exif.CanonCs.Lens                            Short       3  80.0 - 200.0 mm
Exif.CanonCf.LensAFStopButton                Short       1  0
Exif.Canon.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSpecification                 Rational    4  80/1 200/1 0/0 0/0
Exif.Photo.LensModel                         Ascii      70  EF80-200mm f/4.5-5.6 II
Exif.Photo.LensSerialNumber                  Ascii      12  0000000000
524 rmills@rmillsm1:~/Downloads $

@John55h
Copy link
Contributor Author

John55h commented Sep 22, 2021

I found the lensfun github issue and pull request that uploaded calibration data for "Canon EF 80-200mm f/4.5-5.6 II"
The calibration data is for lens "Canon EF 80-200mm f/4.5-5.6 II" according to the issue below, however the pull request is for "Canon EF 80-200mm f/4.5-5.6" (I guess because that is what exiv2 identified the lens as).

Calibration upload issue
lensfun/lensfun#1173
Pull request
lensfun/lensfun#1272

@kmilos
Copy link
Collaborator

kmilos commented Sep 22, 2021

Thanks, but sadly there is no independent confirmation of the definitive mapping to LensType in those links, even though exiv2/exiftool could be responsible for the lensfun database discrepency...

@clanmills
Copy link
Collaborator

I'm not sure what's being discussed here as I know nothing about lensfun.

Should this issue be closed?

@kmilos
Copy link
Collaborator

kmilos commented Sep 22, 2021

@clanmills
Both exiv2 and exiftool have a possible bug in their lens mapping tables, i.e. Canon IDs 28 and 38 both get reported as Canon EF 80-200mm f/4.5-5.6.

Do you think we have enough evidence to "fix" the 38 mapping to Canon EF 80-200mm f/4.5-5.6 II in exiv2?

@clanmills
Copy link
Collaborator

There is no "bug" in the Exiv2 mapping table. The problem is that the lens is not in the metadata and has to be guessed by examination of other metadata. I don't know how the guess for 28 or 38 arrived in the code. If we change it, we'll break something that was working correctly for somebody else.

The fix is to use the configuration file ~/.exiv2 to modify the lens recognition on your machine.

I'm going to close this issue.

@kmilos
Copy link
Collaborator

kmilos commented Sep 22, 2021

There is no "bug" in the Exiv2 mapping table. The problem is that the lens is not in the metadata and has to be guessed by examination of other metadata.

I wouldn't be so sure Robin - there does seem to be a discrepancy w/ Canon's own MakerNote LensModel string here:

0x0016 CanonCs      LensType                    Short       1  38
0x0095 Canon        LensModel                   Ascii      70  EF80-200mm f/4.5-5.6 II

@kmilos
Copy link
Collaborator

kmilos commented Sep 22, 2021

Both exiv2 and exiftool have a possible bug in their lens mapping tables, i.e. Canon IDs 28 and 38 both get reported as Canon EF 80-200mm f/4.5-5.6.

@boardhead Any idea how exactly this info got into exiftool, the reference just says "private communication"...

@clanmills
Copy link
Collaborator

clanmills commented Sep 22, 2021

Well spotted, @kmilos.

Why doesn't LensFun use Exif.Canon. LensModel which is an ascii string written by Canon.

Exif.CanonCs.LensType is a Short (value 38) which is being interpreted (pretty printed) by Exiv2. Because I'm not a photographer, I don't know know what LensFun does. However, it seems that the whole world demands that Exiv2 must guess the right lens. I feel it's the job of the mysterious LensFun to use the metadata which we read correctly.

Grrrrr.... I am just a grumpy old man. If it makes people happy, use patch in the issue report: #1906 (comment)

@kmilos
Copy link
Collaborator

kmilos commented Sep 22, 2021

I'm not that old, but just as grumpy. For one reason or another it seems lensfun devs decided to use interpreted lens strings from exiv2/exiftool rather than immutable vendor metadata, and we have ourselves a catch 22 situation here...

@John55h Can you submit a PR please? Obvioulsy you'll have to follow it up with a PR to lensfun as well...

@clanmills
Copy link
Collaborator

clanmills commented Sep 22, 2021

@kmilos. If you live long enough, one day you'll be as old as me. You'll never be as grumpy. 😄

@John55h Can you ask LensFun to carefully consider how they determine the lens from the metadata which Exiv2 parses correctly. There should be a cascade of keys to be inspected.

The priority (of truth) is:

  1. Exif.Photo.LensModel
    Miloš added support for Exif 2.32 in Exiv2 v0.27.4. Exif.Photo.LensModel is an Ascii string written by the manufacturer.

  2. In the case of Canon, Exif.Canon.LensModel appears to be much the same. However it's in the Canon makernote and not in the Exif standard.

  3. In the case of Canon, Exif.CanonCs.LensType is an integer that Exiv2 can "translate" (pretty print) by guess-work. Again, this is buried in the Canon makernote.

The manufacturer's makernote is different for every manufacturer and the manufacturer can (and does) change the structure from model-to-model. The "configuration file" is provided to enable the user to modify lens recognition locally on their machine.

Which is the best metadata for LensFun to use? The Exif standard Exif.Photo.LensModel is best. Any ascii metadata such as Exif.Canon.LensModel is second best. Last resort is translated metadata such as Exif.CanonCs.LensType. The configuration file enables the user to modify the translated value of keys such as Exif.CanonCs.LensType.

@boardhead
Copy link
Collaborator

@boardhead Any idea how exactly this info got into exiftool, the reference just says "private communication"...

I know this issue is closed, but I'm OK with changing this. I can't contact the person who originally reported this lens, but even if some non-II variants have LensType 38 I don't mind changing this since adding "II" at least allows this lens to be differentiated from LensType 28.

  • Phil

@PeterWem
Copy link

PeterWem commented Jan 16, 2022

With .exiv2 it is possible to force a lens recognition by using LensID, for example 142=Canon EF 300mm f2.8 L IS USM.

Would it be possible to write other tags in the config file like:
If Exif.Photo.LensModel=Canon EF 300mm f2.8 L IS USM, then force to use the name Canon EF 300mm f2.8 L IS USM.

The reason why I ask is because this lens has the same lensID even together with converters. The converters show up in Exif.Photo.LensModel but not in LensType or LensID.

Thanks

@clanmills
Copy link
Collaborator

@PeterWem You and I think alike. When I implemented the configuration file, I thought about having conditions and concluded that it would end up being a programming language. Here's the proposal: https://exiv2.org/book/#future

I will be 71 on Tuesday. I retired from work in 2014 and retired from open-source last year. I don't believe I will ever have the time to implement M2LScript. I'd be happy to mentor a volunteer. In my day job, I wrote compilers and interpreters, so my skills are up to the task. The challenge is to totally stop work on Exiv2 to make time for M2LScript.

Exiv2 can modify the LensID from 142 to any value you choose, for example 911. Then put 911=My super dooper lens into the config file. You can write a bash (or python) script to traverse any number of images and modify the LensID for those images you believe to be the 911 lens.

@PeterWem
Copy link

PeterWem commented Jan 16, 2022

Thank you very much for your advice! In ~.exiv2 I wrote 142=000. That solved the issue. I think because LensID 000 doesn't exist darktable ignores the tag LensType and continues to the next and the right tag LensModel instead. Now my Canon EF 300mm f2.8 L IS USM, Canon EF 300mm f2.8 L IS USM +1.4x, Canon EF 300mm f2.8 L IS USM + 1.4X II and Canon EF 300mm f2.8 L IS USM + 2x III all show the correct names instead of Canon EF 300mm f/2.8L IS for all four combinations. I suppose this will fail with older cameras that don't have the tags Exif.Photo.LensModel or Exif.Canon.LensModel, but that is a minor problem in my case.

The original problem and the raw files free to download https://discuss.pixls.us/t/lensfun-not-finding-the-right-lens/26779/7?u=peter

@PeterWem
Copy link

Btw, I think M2Lscript sounds like a great idea!

@clanmills
Copy link
Collaborator

I'm glad that we've got that fixed between us. I am still a smart guy at 71.

Exif.Photo.LensModel is a recent addition to the Exif Spec. If the Exif Committee had added that 20 years ago, the lens recognition issue would not exist. I honestly don't feel that it is the responsibility of exiv2 or exiftool to recognise the lens. The responsibility of exiftool and exiv2 is to reliably read/modify/delete metadata. The M2Lscript proposal would establish lens recognition as a distinct technology that interprets metadata.

However, like everybody, I've live in a world of 7x24 hours in a week. M2Lscript is probably a considerable undertaking. There are ways to simplify the engineering effort such as:

  1. Use python, or perl, or chaiscript, or node.js
    If the file exiv2.py is on the path, it could be executed to perform lens recognition.

  2. Use exiftool (either locally or via a web-service).

When M2Lscript is finished, the solution will be simple and obvious. The search for simple and obvious will be neither.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants