Decoding CameraSettings and other similar makernote tags

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

Previous topic - Next topic

Phil Harvey

Quote from: mvadu on October 11, 2010, 11:52:24 PM
Could you please explain what is the logic behind Get32u(\$footer, 4); (Get32u in general, I could not find the function body).

This function is defined in lib/Image/Exiftool.pm, but isn't very easy to read.  Basically all these functions just extract a single value at the specified offset in the data.  Get32u() extracts a 32-bit unsigned integer (at offset 4 in $footer of your example).  The following lookup table from ExifTool.pm defines the functions that are used to read values of each data type:

my %readValueProc = (
   int8s => \&Get8s,
   int8u => \&Get8u,
   int16s => \&Get16s,
   int16u => \&Get16u,
   int16uRev => \&Get16uRev,
   int32s => \&Get32s,
   int32u => \&Get32u,
   int64s => \&Get64s,
   int64u => \&Get64u,
   rational32s => \&GetRational32s,
   rational32u => \&GetRational32u,
   rational64s => \&GetRational64s,
   rational64u => \&GetRational64u,
   fixed16s => \&GetFixed16s,
   fixed16u => \&GetFixed16u,
   fixed32s => \&GetFixed32s,
   fixed32u => \&GetFixed32u,
   float => \&GetFloat,
   double => \&GetDouble,
   extended => \&GetExtended,
   ifd => \&Get32u,
   ifd64 => \&Get64u,
);


QuoteI 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)

Perl has a built-in debugger (invoked with the perl -d option), which I have used on occasion, but I do most of my debugging by inserting print statements (which isn't as bad as it sounds because there is no compile step in the debugging cycle).

- 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 response Phil.
I was looking at http://www.epic-ide.org/index.php (I already have Eclipse for AVR developemtn work).

Phil Harvey

You do AVR development?  Cool.  I've done some 8-bit AVR development on this system, but we're upgrading to AVR32 and I need to figure out how to get the new compiler working on a Mac so I can get going on 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

AVR development in Eclipse is fun! you need
1. Eclipse for C/C++ (http://www.eclipse.org/cdt/)
2. AVR LibC (http://www.nongnu.org/avr-libc/)
3. AVR GCC Toolchain (http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_GCC_Toolchain).

Debugging is easier in AVR Studio (I have never used hardware debugger).

mvadu

Quote from: Phil Harvey on October 12, 2010, 08:13:25 AM
but I do most of my debugging by inserting print statements (which isn't as bad as it sounds because there is no compile step in the debugging cycle).

- Phil
Phil, today I found an easy way.. When I execute the standalone exiftool.exe in windows, it extracts (i don't know what kind of packaging you used) all source files, and editing them works ;D

Now I need your help in figuring out where to add print statements.
1 => { #PH
       Name => 'AutoISO',
       Notes => 'actual ISO used = BaseISO * AutoISO / 100',
       ValueConv => 'exp($val/32*log(2))*100',
       ValueConvInv => '32*log($val/100)/log(2)',
       PrintConv => 'sprintf("%.0f",$val)',
       PrintConvInv => '$val',
   },

Say this is the code I want to debug (shotinfo look up table). Where should I add the print statement?
say I want to print the original tag value, converted value, the PROCESS_PROC for this tag is Image::ExifTool::ProcessBinaryData, so I went and added
    foreach (keys %{$$tagTablePtr{GROUPS}}) {
            print $tagTablePtr->{GROUPS}{"Name"} . "\n";
        }

But I got few blank line in the output.. removing {"Name"} gave me HASH(0x2a2d8ac), HASH(0x2a2d8ac) etc.

Phil Harvey

#20
ExifTool is a PAR package, which is basically a bundle of Perl and ExifTool with all the necessary libraries.  They are all unpacked in your temporary directory when running.  Since ExifTool is pure Perl, the ExifTool script and libraries are Perl source code and may be edited as you have discovered.

I'm not sure what you are trying to do, but the GROUPS hash contains key values of 1, 2 and 3, which are the default group names for families 1-3 for the tags in the table.

If you just want to print the original values of all tags, you could use the -U -v3 options.

- 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

Quote from: Phil Harvey on October 19, 2010, 07:26:23 AM
I'm not sure what you are trying to do, but the GROUPS hash contains key values of 1, 2 and 3, which are the default group names for families 1-3 for the tag in the table.

If you just want to print the original values of all tags, you could use the -U -v3 options.

- Phil
Thanks for the information Phil, Yes, -U -v3 gives me the information I was looking for.

I wanted to see the value transformation during runtime, so I was looking for a way to alter your code to print values/tag names etc. from within your code. (like dumping whole GROUP hash)
I tried

while ( ($key,$val) = each %{$$tagTablePtr{GROUPS}} ) {
print "$key => $val\n";
}

But I got
1 => Canon
0 => MakerNotes
2 => Camera
1 => Canon
0 => MakerNotes
....so on


So how do I go about printing values assigned in %Image::ExifTool::Canon::ShotInfo function?

P.S> sorry for pulling you in to Perl teaching, but please bear with me

Phil Harvey

sub dumpHash($)
{
    my $hash = shift;
    foreach my $key (sort keys %$hash) {
        print "$key => $$hash{$key}\n";
    }
}

dumpHash($$tagTablePtr{GROUPS});


I can get a lot fancier, but that is the basic idea.

- 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