darktable-org / darktable

darktable is an open source photography workflow application and raw developer
https://www.darktable.org
GNU General Public License v3.0
9.66k stars 1.13k forks source link

Spurious Unknown Lens #16511

Closed joaobrisson closed 6 months ago

joaobrisson commented 6 months ago

Describe the bug

After import and for some images (both RAW and JPEG), the line for "lens" in the Image Information tab (both lighttable and darkroom) shows "Unknown lens (51)" for a Canon EF-S 18-135mm f/3.5-5.6 lens. Preview of the files on a Mac with Inspector on displays the correct lens identification as does Canon's Digital Photo Professional 4 software. This happens to roughly 10% to 50% of the files on the import a film rolls either small (5-6) or large (100 photos) The erratic behaviour repeats for lenses such as Canon EF 70-300mm f/4-5.6 IS USM or old Canon 35-80mm f/4-5.6 USM shown as Unknown Lens (238) and Unknown Lens (193), respectively. Included below are two photos taken in succession, one shows the problem (IMG_0015), the other is ok (IMG_0016) and their XMP sidecar files. Also included are two snapshots of lighttable for the two photos and a snapshot of the view of the two photos in Canon Digital Photo Professional.

Steps to reproduce

  1. Place the files anywhere on the file system
  2. In lighttable, select add to library then import the two photos

Expected behavior

Correct identification of the lens

Logfile | Screenshot | Screencast

IMG_0015.zip IMG_0016.zip Captura de ecrã 2024-03-23, às 19 29 02 Captura de ecrã 2024-03-23, às 19 28 38 Captura de ecrã 2024-03-23, às 19 26 31

Commit

No response

Where did you obtain darktable from?

downloaded from www.darktable.org

darktable version

4.6.1

What OS are you using?

Mac

What is the version of your OS?

macOS Monterey 12.7.4 (Intel)

Describe your system?

16 GB RAM MacBook Pro 2.5 GHz Intel Core i7

Are you using OpenCL GPU in darktable?

None

If yes, what is the GPU card and driver?

ATM Radeon

Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip

No response

zisoft commented 6 months ago

Reproduced.

Exiv2 command line for one of my images gives

exiv2 -p e ./TestPics/img.CR2 | grep -i lensmodel

Exif.Canon.LensModel                         Ascii      74  EF24-70mm f/2.8L II USM
Exif.Photo.LensModel                         Ascii      24  EF24-70mm f/2.8L II USM

In darktable the lens info is Unknown Lens (495)

kmilos commented 6 months ago

Duplicate, and a known exiv2 issue: https://github.com/darktable-org/darktable/issues/14882

Please search before opening new issues.

zisoft commented 6 months ago

@kmilos: I have checked that and this is only halfway true.

In src/common/exif.cc we check for Exif.Canon.LensModel. At this point Exiv2 returns with Unknown Lens (xxx) which is indeed an Exiv2 issue.

https://github.com/darktable-org/darktable/blob/c04e807343f48f9b633b97077698b45b15ee880f/src/common/exif.cc#L1537-L1545

Later on, we have this in src/common/exif.cc where we make a last attempt with Exif.Photo.LensModel:

https://github.com/darktable-org/darktable/blob/c04e807343f48f9b633b97077698b45b15ee880f/src/common/exif.cc#L1614-L1622

At this point, Exiv2 gives the correct lens name but we check if the previous detection returned with a lens name of only parantheses and numbers and this check fails because Exiv2 now returns not only (xxx) but Unknown Lens (xxx).

This is clearly a thing we need to change on the darktable side.

Exiv2 is generally localized in multiple languages but I can see in the source that Unknown Lens is hard coded without localization.

https://github.com/Exiv2/exiv2/blob/c8f89d66587824ff88e6fea6ebef6952a4b1e8ed/src/canonmn_int.cpp#L2864-L2872

This is most likely to change in the future. So I would suggest to check if the lens name ends with (xxx) which is still not 100% safe.

kmilos commented 6 months ago

So I would suggest to check if the lens name ends with (xxx) which is still not 100% safe.

Makes sense.

zisoft commented 6 months ago

Shoud be fixed with #16514

I could also reproduce this with Sigma lenses.

joaobrisson commented 6 months ago

Sorry, I don't quite get it Do you mean to say that the problem lies elsewhere with exiv2 ? May I stress that lens identification is crucial to automate lens correction?

Please bear with me for a while longer because I think there’s more to it than it shows

i) the Unknown Lens message randomly affects a variable number of photos taken in the same session with the same lens I have experienced, for instance a) 87 occurrences out of 127 photos in one session b) 89 out of 116 c) 2 out of 6 d) 14 out of 43 e) 35 out of 60 question: why this affects only some photos and does not affect them all?

ii) the Unknown Lens message is systematic in that it always shows the same xxx code between the ( ) for a given lens This happens with the 3 Canon lenses I currently use (see my original post) Somehow, the lens is identified!

iii) the Unknown Lens stuff may hide yet more problems In lighttable, I took the photos from session a) above, selected those with Unknown Lens, moved them to a different directory and removed them from darktable Next I opened a Finder window in that directory (I’m on a Mac) and deleted all sidecar files Finally I got back to darktable, selected that directory and imported the photos To my amazement, lighttable correctly identified the lens of all the photos that it hadn’t before! I repeated the procedure with the photos from session c) Again lighttable did succeed in identifying the correct lens for all photos that previously had lens identification as Unknown Lens

However, such behaviour did not reproduce with the photos from the other sessions!

An old feeling from old times debugging in Unix crept into my mind: “Memory leak”!

Sorry to have drawn your attention this long but this is the complete scenario darktable users face

kmilos commented 6 months ago

Please keep the discussion organized either in the original issue, or the upstream exiv2 issue. This one is now closed.

joaobrisson commented 6 months ago

Sorry but you forgot to mention the original issueThen should have linked to thatDo not ignore details and please answer my questionAre you setting the blame on exiv2?Enviado do meu iPad ProNo dia 24/03/2024, às 14:16, Miloš Komarčević @.***> escreveu: Please keep the discussion organized either in the original issue, or the upstream exiv2 issue. This one is now closed.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>