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

Sigma 24-70mm F2,8 DG OS HSM Art not detected #743

Closed
codingdave opened this issue Mar 14, 2019 · 7 comments
Closed

Sigma 24-70mm F2,8 DG OS HSM Art not detected #743

codingdave opened this issue Mar 14, 2019 · 7 comments
Assignees
Milestone

Comments

@codingdave
Copy link
Contributor

Hi, I have a Sigma Lens which I do not find supported yet. Though the entry

cat ~/.exiv2
[nikon]
201=Sigma 24-70mm F2,8 DG OS HSM Art

is working fine I hope I can help others to have an automatic support. As described at 3. Contributing Lens Data I shot a small JPG with caps-on that is unmodified and attached to this case.

I would love to make a pr, but I have no idea and did not find any documentation how to create and interprete the data required for fmountlens[].

DSC_5190

Btw, these links are dead (from src/nikonmn_int.cpp):
//------------------------------------------------------------------------------
//
//
// Created by Robert Rottmerhusen 2005 - 2018
// http://www.rottmerhusen.com (lens_id@rottmerhusen.com)
//
// For contributor info and more visit my online list:
// http://www.rottmerhusen.com/objektives/lensid/thirdparty.html

Kind regards
Dave

@clanmills
Copy link
Collaborator

Thanks for letting us know about this. And I'm glad to hear that ~/.exiv2 is working for you. I added that in Exiv2 v0.26 because it enables users to immediately update the lens recognition without waiting for a software update. And the other reason to add this feature was to reduce the work for me to deal many requests for new lenses.

We had a very good contributor dealing with lens recognition. He left the project to return to college and that's when I decided to add ~/.exiv2 to enable users and reduce my work-load.

I don't know how the tables in src/nikonmn_int.cpp work. The documentation concerning the table is at the top. I don't believe every field is used by Exiv2 to determine the lens, however the table was "bought in" without modification.

static const struct FMntLens {unsigned char lid,stps,focs,focl,aps,apl,lfw, ltype, tcinfo, dblid, mid; const char *manuf, *lnumber, *lensname;}
fmountlens[] = {
{0x01,0x58,0x50,0x50,0x14,0x14,0x02,0x00,0x00,0x00,0x00, "Nikon", "JAA00901", "AF Nikkor 50mm f/1.8"},

Here's the raw data from my Nikon/Sigma lens, and your sample.

$ bin/exiv2 -pv --grep lens/i http://clanmills.com/Stonehenge.jpg
0x0083 Nikon3       LensType                    Byte        1  14
0x0084 Nikon3       Lens                        Rational    4  180/10 2500/10 35/10 63/10
0x008b Nikon3       LensFStops                  Undefined   4  55 1 12 0
0x000c NikonLd3     LensIDNumber                Byte        1  146
0x000d NikonLd3     LensFStops                  Byte        1  55
$ bin/exiv2 -pv --grep lens/i ~/Downloads/54391258-9632c000-46a4-11e9-87fc-d7db6a5e99dd.JPG 
0x0083 Nikon3       LensType                    Byte        1  78
0x0084 Nikon3       Lens                        Rational    4  240/10 700/10 28/10 28/10
0x008b Nikon3       LensFStops                  Undefined   4  72 1 12 0
0x000c NikonLd3     LensIDNumber                Byte        1  201
0x000d NikonLd3     LensFStops                  Byte        1  72
$ 

I've copied and modified the record for my Sigma/Nikon Lens, however this hasn't been successful.

{0x92,0x39,0x2D,0x88,0x2C,0x40,0x4B,0x0E,0x01,0x00,0x00, "Sigma", "", "18-250mm F3.5-6.3 DC OS Macro HSM"},
{0xc9,0x48,0x37,0x5c,0x2C,0x40,0x4B,0x4E,0x01,0x00,0x00, "Sigma", "", "Sigma 24-70mm F2,8 DG OS HSM Art"},

I'm going to ask @FreddieWitherden as he worked on that code last year. If Freddie is unable to help you, I cannot be of further help. However, your lens is being recognised by the entry in ~/.exiv2, so you have a fix.

It is regrettable that Exiv2 became involved with lens recognition because the lens type isn't stored in the metadata. It is deduced from the metadata. Deducing the lens type has created a code maintenance issue as new lenses are released with great frequency.

@FreddieWitherden
Copy link
Contributor

So the underlying problem is that the Nikon lens IDs are not sufficient to uniquely identify a lens. (This is because some third party lenses have IDs which conflict with those of Nikon lenses.) To this end additional data such as the focal length range and aperture is used to help disambiguate lenses with duplicate IDs. Thus in order for everything to work I believe you need to change more than just the ID.

I am still trying to unpick some aspects of the table and am not currently in a position where I know how to construct an entry from scratch. However, my suggestion would be to see if you can e-mail Robert Rottmerhusen and see what is going on with his site (which until recently was well maintained and updated).

The good news, going forwards at least, is that more modern mounts enable the lens to transmit its full name (as opposed to just an ID) to the camera body so that it is no longer the problem of libraries such as exiv2.

@codingdave
Copy link
Contributor Author

codingdave commented Mar 15, 2019 via email

@clanmills
Copy link
Collaborator

@FreddieWitherden Thanks for stepping into this. Your thoughts are the same as mine. I modified 5 entries in:

{0x92,0x39,0x2D,0x88,0x2C,0x40,0x4B,0x0E,0x01,0x00,0x00, "Sigma", "", "18-250mm F3.5-6.3 DC OS Macro HSM"},
{0xc9,0x48,0x37,0x5c,0x2C,0x40,0x4B,0x4E,0x01,0x00,0x00, "Sigma", "", "Sigma 24-70mm F2,8 DG OS HSM Art"},
My Lens Dave's Lens Code
0x92,0x39,0x2D,0x88 0xc9,0x48,0x37,0x5c lid,stps,focs,foc
0x0E 0x4E ltype

I guess I'm going to have to debug fmountlens in src/nikonmn_int.cpp and discover the exact metadata required to match the lens.

$ grep fmountlens src/*.cpp
src/nikonmn_int.cpp:fmountlens[] = {
src/nikonmn_int.cpp:         * fmountlens[]
src/nikonmn_int.cpp:         * www.rottmerhusen.com/objektives/lensid/files/c-header/fmountlens4.h
src/nikonmn_int.cpp:            const struct FMntLens*  pf = fmountlens;
src/nikonmn_int.cpp:        for (int i = 0; fmountlens[i].lensname != NULL; ++i) {
src/nikonmn_int.cpp:            if (   raw[0] == fmountlens[i].lid ) {
src/nikonmn_int.cpp:            if (   raw[0] == fmountlens[i].lid
src/nikonmn_int.cpp:                &&(raw[1] == fmountlens[i].stps || strcmp(fmountlens[i].manuf, "Sigma") == 0)
src/nikonmn_int.cpp:                && raw[2] == fmountlens[i].focs
src/nikonmn_int.cpp:                && raw[3] == fmountlens[i].focl
src/nikonmn_int.cpp:                && raw[4] == fmountlens[i].aps
src/nikonmn_int.cpp:                && raw[5] == fmountlens[i].apl
src/nikonmn_int.cpp:                && raw[6] == fmountlens[i].lfw
src/nikonmn_int.cpp:                && raw[7] == fmountlens[i].ltype) {
src/nikonmn_int.cpp:                return os << fmountlens[i].manuf << " " << fmountlens[i].lensname;
$

Today is the scheduled date for Exiv2 v0.27.1 RC1 and I'm not ready. Probably in for a 12 hour day with that.

@clanmills
Copy link
Collaborator

clanmills commented Mar 15, 2019

Gentlemen:

I wasn't able to get the release out today. Ran into a documentation obstacle which I'll fix next week. So, to finish the week on a high, I had another look at this. The correct entry in the table is:

{0xc9,0x48,0x37,0x5c,0x24,0x24,0x4b,0x4E,0x01,0x00,0x00, "Sigma", "", "24-70mm F2,8 DG OS HSM Art"},

I discovered this by tweaking this code (locally, on my machine):

            if (   raw[0] == fmountlens[i].lid
                // stps varies with focal length for some Sigma zoom lenses.
                &&(raw[1] == fmountlens[i].stps || strcmp(fmountlens[i].manuf, "Sigma") == 0)
                && raw[2] == fmountlens[i].focs
                && raw[3] == fmountlens[i].focl
                // && raw[4] == fmountlens[i].aps
                // && raw[5] == fmountlens[i].apl
                // && raw[6] == fmountlens[i].lfw
                && raw[7] == fmountlens[i].ltype) {
                // Lens found in database
                std::cout <<  "raw[4] = " << (int) raw[4]
                          << " raw[5] = " << (int) raw[5]
                          << " raw[6] = " << (int) raw[6]
                          << std::endl;
                return os << fmountlens[i].manuf << " " << fmountlens[i].lensname;
            }

which nicely recognises the lens (with yesterday's record) and tells us that:

658 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance/build $ bin/exiv2 -pa --grep lens/i ~/Downloads/54391258-9632c000-46a4-11e9-87fc-d7db6a5e99dd.JPG 
Exif.Nikon3.LensType                         Byte        1  D G VR
Exif.Nikon3.Lens                             Rational    4  24-70mm F2.8
Exif.Nikon3.LensFStops                       Undefined   4  6
Exif.NikonLd3.LensIDNumber                   Byte        1  raw[4] = 36 raw[5] = 36 raw[6] = 75
Sigma Sigma 24-70mm F2,8 DG OS HSM Art
Exif.NikonLd3.LensFStops                     Byte        1  F6.0

A little higher in the code, we have:

        static const char* tags[] = {
            "LensIDNumber",
            "LensFStops",
            "MinFocalLength",
            "MaxFocalLength",
            "MaxApertureAtMinFocal",
            "MaxApertureAtMaxFocal",
            "MCUVersion"
        };

So, here's the raw information:

$ exiv2 -pv --grep focal/i --grep lens/i --grep mcu/i ~/Downloads/54391258-9632c000-46a4-11e9-87fc-d7db6a5e99dd.JPG 
0x920a Photo        FocalLength                 Rational    1  240/10
0x0083 Nikon3       LensType                    Byte        1  78         <- [7]
0x0084 Nikon3       Lens                        Rational    4  240/10 700/10 28/10 28/10
0x008b Nikon3       LensFStops                  Undefined   4  72 1 12 0
0x000b NikonLd3     FocalLength                 Byte        1  55
0x000c NikonLd3     LensIDNumber                Byte        1  201        <- [0]
0x000d NikonLd3     LensFStops                  Byte        1  72         <- [1]
0x000e NikonLd3     MinFocalLength              Byte        1  55         <- [2]
0x000f NikonLd3     MaxFocalLength              Byte        1  92         <- [3]
0x0010 NikonLd3     MaxApertureAtMinFocal       Byte        1  36         <- [4]
0x0011 NikonLd3     MaxApertureAtMaxFocal       Byte        1  36         <- [5]
0x0012 NikonLd3     MCUVersion                  Byte        1  75         <- [6]
0xa405 Photo        FocalLengthIn35mmFilm       Short       1  24
$ 
code Key Test Image in Hex Index
lid Exif.NikonLd3.LensIDNumber 201 0xc9 [0]
stps Exif.NikonLd3.LensFStops 72 0x48 [1]
focs Exif.NikonLd3.MinFocalLength 55 0x37 [2]
foc Exif.NikonLd3.MaxFocalLength 92 0x5c [3]
aps Exif.NikonLd3.MaxApertureAtMinFocal 36 0x24 [4]
apl Exif.NikonLd3.MaxApertureAtMaxFocal 36 0x24 [5]
lfw Exif.NikonLd3.MCUVersion 75 0x4b [6]
ltype Exif.Nikon3.LensType 78 0x4e [7]
tcinfo ignored 1 0x01 [8]
dblid ignored 0 0x00 [9]
dblid ignored 0 0x00 [10]
{0xc9,0x48,0x37,0x5c,0x24,0x24,0x4b,0x4e,0x01,0x00,0x00, "Sigma", "", "24-70mm F2,8 DG OS HSM Art"},

I'll submit a PR with an update to the test suite to include the metadata from Dave's image.

With the record above, the existing test suite passes and the output from Dave's image is:

$ bin/exiv2 -pa --grep lens/i ~/Downloads/54391258-9632c000-46a4-11e9-87fc-d7db6a5e99dd.JPG 
Exif.Nikon3.LensType                         Byte        1  D G VR
Exif.Nikon3.Lens                             Rational    4  24-70mm F2.8
Exif.Nikon3.LensFStops                       Undefined   4  6
Exif.NikonLd3.LensIDNumber                   Byte        1  Sigma 24-70mm F2,8 DG OS HSM Art
Exif.NikonLd3.LensFStops                     Byte        1  F6.0
$ 

The fix isn't urgent and will not go into v0.27.1 as Dave uses the ~/.exiv2 work-around. I'll assign this issue to Milestone 0.27.2 which is due at the end of Q2 = 30 June 2019.

@clanmills clanmills self-assigned this Mar 15, 2019
@clanmills clanmills added this to the v0.27.2 milestone Mar 15, 2019
@codingdave
Copy link
Contributor Author

codingdave commented Mar 15, 2019 via email

@clanmills
Copy link
Collaborator

PR with code and update to the test suite has been submitted to branch 0.27-maintenance #886

Fix will be included in Exiv2 v0.27.2 which is on schedule for release on 2019-06-30.

The fix will be ported to 'master' and included in Exiv2 v0.28 which we hope to release in 2020.

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

No branches or pull requests

3 participants