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

Incorrect lense name with Nikon D7200 and Sigma AF 18-250mm f/3.5-6.3 DC OS HSM Macro #4135

Closed
Kildor opened this issue Oct 7, 2017 · 10 comments
Assignees
Labels
scope: metadata Reading / writing metadata type: enhancement Something could be better than it currently is
Milestone

Comments

@Kildor
Copy link

Kildor commented Oct 7, 2017

I've gotten a used lense Sigma AF 18-250mm f/3.5-6.3 DC OS HSM Macro, but RT is not able to recognise correct and full lense name at some images showing it as generic "AF 18-250mm f/3.5-6.3"
Raw files examples:
https://filebin.net/w5deodayzg7hsmap
DSC_5073.NEF -- Sigma AF 18-250mm f/3.5-6.3 DC OS HSM Macro
DSC_5077.NEF -- AF 18-250mm f/3.5-6.3

The only difference I see is focal range, the RT shows correct lense name if range is 250. In any other case it shows uncorrect name.

AboutThisBuild.txt
Version: 5.3
Branch: 5.3
Commit: ec0f793
Commit date: 2017-09-30
Compiler: gcc 7.2.0
Processor: generic x86
System: Windows
Bit depth: 64 bits
Gtkmm: V3.22.0
Lensfun: V0.3.2.0
Build type: release
Build flags: -m64 -mwin32 -mthreads -Wno-aggressive-loop-optimizations -std=c++11 -mtune=generic -Werror=unused-label -fopenmp -Werror=unknown-pragmas -Wall -Wno-unused-result -Wno-deprecated-declarations -DNDEBUG -O3
Link flags: -m64 -mthreads -static-libgcc -mtune=generic -s -O3
OpenMP support: ON
MMAP support: ON

@heckflosse
Copy link
Collaborator

Your file DSC_5071.NEF has lens id 92 40 2D 88 2C 40 4B 0E which is not present in our database.
For this reason, rt can not detect the correct lens name and tries to find a matching lens based on focal length and aperture.

Your file DSC_5076.NEF has lens id F1 47 5C 8E 30 3C DF 0E which matches the entry
{"F1 47 5C 8E 30 3C DF 0E", "Tamron SP 70-300mm f/4-5.6 Di VC USD (A005)"},

@Kildor
Copy link
Author

Kildor commented Oct 8, 2017

Sorry. I mixed files and uploaded wrong one. Now I've uploaded correct (which I referred in report) files. 5076 was made with Tamron SP 70-300.
5071 is also incorrect Sigma 18-250.

@heckflosse
Copy link
Collaborator

That's interesting.
The different focal length settings result in different lens ids.

fl 18mm  => id 92 40 2D 88 2C 40 4B 0E
fl 90mm  => id 92 30 2D 88 2C 40 4B 0E
fl 250mm => id 92 2C 2D 88 2C 40 4B 0E

The entry in our database corresponds to the id for fl 250mm.
Can you provide some more shots from that lens with different focal length settings?

@Kildor
Copy link
Author

Kildor commented Oct 9, 2017

Sure.
Uploaded more raws.
185 and 210 mm are recognised as Sigma, 18, 75, 130 aren't.

@Kildor Kildor closed this as completed Oct 9, 2017
@Kildor Kildor reopened this Oct 9, 2017
@heckflosse
Copy link
Collaborator

The following patch solves the issue, but as @Beep6581 regularly updates the exif database, I want his ok to apply the patch.

diff --git a/rtexif/nikonattribs.cc b/rtexif/nikonattribs.cc
index ac8e69ea..af7efc3a 100644
--- a/rtexif/nikonattribs.cc
+++ b/rtexif/nikonattribs.cc
@@ -949,7 +949,22 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
     {"90 3B 53 80 30 3C 92 0E", "AF-S DX VR Zoom-Nikkor 55-200mm f/4-5.6G IF-ED"},
     {"90 40 2D 80 2C 40 4B 0E", "Sigma 18-200mm f/3.5-6.3 II DC OS HSM"},
     {"91 54 44 44 0C 0C 4B 06", "Sigma 35mm f/1.4 DG HSM"},
-    {"92 2C 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"},
+    // lens id varies with focal length for this lens
+    {"92 2C 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (250mm)
+    {"92 2B 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (210mm)
+    {"92 2C 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (185mm)
+    {"92 2D 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (155mm)
+    {"92 2E 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (130mm)
+    {"92 2F 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (105mm)
+    {"92 30 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (90mm)
+    {"92 32 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (75mm)
+    {"92 33 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (62mm)
+    {"92 35 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (52mm)
+    {"92 37 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (44mm)
+    {"92 39 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (38mm)
+    {"92 3A 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (32mm)
+    {"92 3E 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (22mm)
+    {"92 40 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (18mm)
     {"92 48 24 37 24 24 94 06", "AF-S Zoom-Nikkor 14-24mm f/2.8G ED"},
     {"93 48 37 5C 24 24 95 06", "AF-S Zoom-Nikkor 24-70mm f/2.8G ED"},
     {"94 40 2D 53 2C 3C 96 06", "AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED II"},

@Beep6581 Beep6581 self-assigned this Oct 13, 2017
@Beep6581
Copy link
Owner

Beep6581 commented Oct 13, 2017

Even if the patch is correct, the fix must be made upstream using our metadata source - ExifTool - otherwise the fix will be lost on the next update. I assigned myself so that I remember to report this to them tomorrow.

@Beep6581
Copy link
Owner

Issue opened:
http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,8628.0.html

@Beep6581
Copy link
Owner

The changing element in the lens ID is handled programmatically by ExifTool:

# Convert unknown LensID values
# Inputs: 0) value, 1) flag for inverse conversion, 2) PrintConv hash ref
sub LensIDConv($$$)
{
    my ($val, $inv, $conv) = @_;
    return undef if $inv;
    # multiple lenses with the same LensID are distinguished by decimal values
    if ($$conv{"$val.1"}) {
        my ($i, @vals, @user);
        for ($i=1; ; ++$i) {
            my $lens = $$conv{"$val.$i"} or last;
            if ($Image::ExifTool::userLens{$lens}) {
                push @user, $lens;
            } else {
                push @vals, $lens;
            }
        }
        return join(' or ', @user) if @user;
        return join(' or ', @vals);
    }
    # Sigma has been changing the LensID on some new lenses
    # and with some Sigma lenses the LensFStops changes! (argh!)
    my $pat = $val;
    $pat =~ s/^\w+ \w+/.. ../;
    my @ids = sort grep /^$pat$/, keys %$conv;
    if (@ids) {
        # first try different LensFStops (2nd value)
        ($pat = $val) =~ s/ \w+/ ../;
        my @good = grep /^$pat$/, @ids;
        return $$conv{$good[0]} if @good;
        # then try different LensType (1st value)
        ($pat = $val) =~ s/^\w+/../;
        @good = grep /^$pat$/, @ids;
        return "Unknown ($val) $$conv{$good[0]} ?" if @good;
    }
    return undef;
}

https://sourceforge.net/p/exiftool/code/ci/master/tree/lib/Image/ExifTool/Nikon.pm#l7866

@Beep6581 Beep6581 removed their assignment Oct 28, 2017
@Beep6581 Beep6581 added type: enhancement Something could be better than it currently is scope: metadata Reading / writing metadata labels Oct 28, 2017
@Beep6581 Beep6581 added this to the v5.6 milestone Mar 8, 2019
@Beep6581 Beep6581 self-assigned this Mar 8, 2019
@Beep6581
Copy link
Owner

Beep6581 commented Mar 8, 2019

I want to close this issue one way or another.

There is no way of having those lens IDs automatically generated on update, for the reason expressed by Phil Harvey of ExifTool:

Sorry, the other LensID's aren't listed with the -listx option. They are handled programatically. I did this way because it seemed unrealistic to try to determine all possible LensID's for each of these variable-aperture lenses, and I didn't like the idea of having so many duplicate lenses in the list.

We could append these IDs to the map manually, but separately from the automatically generated section. @heckflosse would this be ok?

diff --git a/rtexif/nikonattribs.cc b/rtexif/nikonattribs.cc
index a1fa28c34..b2066150d 100644
--- a/rtexif/nikonattribs.cc
+++ b/rtexif/nikonattribs.cc
@@ -1148,7 +1148,26 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
     {"FE 53 5C 80 24 24 84 06", "Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)"},
     {"FE 54 5C 80 24 24 DF 0E", "Tamron SP 70-200mm f/2.8 Di VC USD (A009)"},
     {"FE 54 64 64 24 24 DF 0E", "Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F004)"},
-    {"FF 40 2D 80 2C 40 4B 06", "Sigma 18-200mm f/3.5-6.3 DC"}
+    {"FF 40 2D 80 2C 40 4B 06", "Sigma 18-200mm f/3.5-6.3 DC"},
+
+    // There are cases where one lens uses multiple IDs which change based on the focal length or aperture.
+    // These IDs cannot be listed using ExifTool, and so must be entered manually below.
+    // #4135
+
+    {"92 2B 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (210mm)
+    {"92 2C 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (185mm)
+    {"92 2D 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (155mm)
+    {"92 2E 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (130mm)
+    {"92 2F 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (105mm)
+    {"92 30 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (90mm)
+    {"92 32 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (75mm)
+    {"92 33 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (62mm)
+    {"92 35 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (52mm)
+    {"92 37 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (44mm)
+    {"92 39 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (38mm)
+    {"92 3A 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (32mm)
+    {"92 3E 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"}, // (22mm)
+    {"92 40 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC Macro OS HSM"} // (18mm)
 };
 
 const TagAttrib nikonISOInfoAttribs[] = {

@Kildor could you upload the sample files again please?

@Beep6581
Copy link
Owner

Ping @heckflosse @Kildor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: metadata Reading / writing metadata type: enhancement Something could be better than it currently is
Projects
None yet
Development

No branches or pull requests

3 participants