Decoding CameraSettings and other similar makernote tags

Started by mvadu, September 30, 2010, 11:48:09 PM

Previous topic - Next topic

mvadu

Hi Phil,
I am back again with another question.

In my program once I am done with all standard exif tags I get OffsetSchema (59933) and Makernote tags, and start decoding maker notes. I am able to read the individual tags inside makernote tag. Now I have to decode encoded tags like CameraSettings, and have a question.

As I understand these tags (http://www.exiftool.org/TagNames/Canon.html#CameraSettings) can have differnt meaning depending on the placement (index). But what I don't understand is how to determine if an index has an value or just not used by the camera at all.

I went through %Image::ExifTool::Canon::CameraSettings function, and I could not grasp it as I am not familiar with Perl. I need to know if a byte/bytes are used by camera with value of zero, or camera did not use the tag at all and it's just zero padding.

I have this CanonCameraSettings value block from Canon T1i,
62 00 02 00  00 00 03 00 10 00 01 00
00 00 02 00 00 00 01 00  00 00 01 00 00 00 00 00
01 00 ff 7f ff 7f 03 00  02 00 00 00 03 00 ff ff
b2 00 87 00 1c 00 01 00  78 00 20 01 00 00 08 20
00 00 00 00 ff ff ff ff  ff ff 00 00 00 00 00 00
00 00 ff ff ff ff 00 00  00 00 ff 7f ff ff ff ff
ff ff 00 00 ff ff

after 2 tags (98, 2) I have a 0, and I am not sure what the case with it is.

I have a linked list implementation which I build with an entry per tag. This list will be used by UI class to parse and presentation.
I want to create a linked list entry for valid tags, and skip to next entry if it's not used.

Phil Harvey

Quote from: mvadu on September 30, 2010, 11:48:09 PM
I need to know if a byte/bytes are used by camera with value of zero, or camera did not use the tag at all and it's just zero padding.

There is no way to tell, but to be safe one should assume that all bytes are significant (although the meaning of many is still unknown to us).

Quote
after 2 tags (98, 2) I have a 0, and I am not sure what the case with it is.

I don't understand what you are asking.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mvadu

Thanks for the clarification Phil.

Quote from: Phil Harvey on October 01, 2010, 07:11:18 AM
Quote
after 2 tags (98, 2) I have a 0, and I am not sure what the case with it is.

I don't understand what you are asking.
I was not sure about third member of that array. In the same context of byte being used as padding, and used to store some value.
So going by your answer I think I have to have a lookup table with all index's which my code can decode, and skip rest..


Phil Harvey

Quote from: mvadu on October 01, 2010, 07:45:31 AM
after 2 tags (98, 2) I have a 0, and I am not sure what the case with it is.

I was not sure about third member of that array. In the same context of byte being used as padding, and used to store some value.

Ah, I see now.  98 = 0x62,0x00.  Right.

So in this case the 3rd entry (index=2) in the Canon CameraSettings is SelfTimer, which is "Off" when the value is 0.  See the PrintConv in Canon.pm for the decoding of this.

But there are many unknown entries, like the 7th (index=6) for example.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mvadu

#4
gotcha.. I am feeling guilty for copy pasting your look table from your page (http://www.exiftool.org/TagNames/Canon.html) to my code. I am really grateful for your guidance.

PH Edit: fixed link

Phil Harvey

Quote from: mvadu on October 01, 2010, 08:03:02 PM
I am feeling guilty for copy pasting your look table from your page

Don't feel guilty.  I made the code public so other people could make use of it. :)

It was a lot of work to figure out all of this stuff, and it doesn't make sense that other programmers have to repeat this work for their own software.  Many other people have already borrowed from my work.  What also makes sense to me is that if people borrow from my work, then they give back when they make discoveries of their own.  This way, everyone benefits.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mvadu

Thanks Phil, I will surely do.

by the way you are really lucky to have started ExifTool in Perl, which is a typeless language. I am working on VC++, and each stage having to worry about types, type conversion, string, memory allocation and deallocation etc, I am not sure when will start my next module (to store decoded tag values in an indexed file based database ???)

I was going through Canon.pm, and noticed these two lines:
line 1326: Sharpness:   RawConv => '$val == 0x7fff ? undef : $val',
line 1356: CameraISO:  RawConv => '$val != 0x7fff ? $val : undef',

Both are same comparison with 0x7FFF (32767) but the if/else are interchanged. Any specific reasons?
Wouldn't it be better to have same comparison for the sake easy readability?


Phil Harvey

Quote from: mvadu on October 04, 2010, 09:48:50 PM
by the way you are really lucky to have started ExifTool in Perl, which is a typeless language.

Yes, this does come in very handy.

Quotememory allocation and deallocation etc,

and this is a godsend!

Quote
Wouldn't it be better to have same comparison for the sake easy readability?

Yes, thanks.  I'll change this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mvadu

Hi Phil, sorry for keeping this old thread alive..

This time for LensType tag inside CameraSettings. Your lookup (which is also used for few camera specific decoding too). As I understand this is a int16s type value, but look up has few rational values(for few Sigma and other lenses like 10.1). How is that possible?

Phil Harvey

     Notes => q{
        Decimal values differentiate lenses which would otherwise have the same
        LensType, and are used by the Composite LensID tag when attempting to
        identify the specific lens model.
     },


The stored lens ID's are all integer, but I needed some way to represent multiple lenses which have the same ID number, so I use decimal values for this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mvadu

gotcha.. makes sense..

One more question.. In your code what does ValueConvInv represent? ValueConv is for decoded value, ValueConvInv is for encoding it? (say while rebuilding maker notes, or writing it back)?

Nice profile picture by the way

Phil Harvey

Yes, ValueConvInv is the opposite of ValueConv, and is used when writing.

All of these tag information members are documented in lib/Image/ExifTool/README of the full distribution.

Quote from: mvadu on October 07, 2010, 09:24:16 PM
Nice profile picture by the way

Thanks.  I just discovered this feature of the forum. :)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mvadu

Hi Phil, looks like I am not leaving you for quite sometime.

I was working on a file by Canon SX110, and when I use -h -v switch i see a warning
Warning: [minor] Adjusted MakerNotes base by 66 - SX110.jpg

I understand that value 66 is from microsoft's ill tag OffsetSchema tag (59933). But i searched the codebase for "Adjusted MakerNotes base" word to see how you handle taht tag. Only one hit is from \lib\Image\ExifTool\Panasonic.pm. SO I am confused, how do you use this tag? why panasonic procedure output is coming for Canon camera?

I appreciate your patience and timely answers. You are not only a great coder, but great mentor too.

Phil Harvey

Quote from: mvadu on October 10, 2010, 11:18:54 PM
I understand that value 66 is from microsoft's ill tag OffsetSchema tag (59933).

No, no, NO!!!!  Ignore Microsoft's OffsetSchema tag!  (Sorry, I get upset just thinking about this stupid tag.)  OffsetSchema is unreliable because it gives a relative shift which is easily invalidated by an EXIF editor which doesn't recalculate and update the value when rewriting the image.

The value I calculate is from the original makernote offset stored in the Canon makernote footer.  (This is what Microsoft should have stored if they had any brains amongst their programmers, but alas, this is not the case.)

Quote
But i searched the codebase for "Adjusted MakerNotes base" word to see how you handle taht tag.

Look at MakerNotes::FixBase().  The print statement is [qq]$exifTool->Warn("Adjusted $dirName base by $fix",1);[/qq]

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mvadu

Great!! as usual thanks a ton.
Could you please explain what is the logic behind Get32u(\$footer, 4); (Get32u in general, I could not find the function body).

I think I will search for a PERL debugger so that I can run your code and check the values myself (instead of troubling you)
Any suggestions (on Windows)