ExifTool Forum

General => Metadata => Topic started by: LKB on October 31, 2011, 07:15:27 AM

Title: Distance information for Sony SLR cameras
Post by: LKB on October 31, 2011, 07:15:27 AM
Hi,
I started playing with my pic EXIF data - I needed to sort pics based on flash/no flash info.
But, once you start you can't stop,so I am now looking to extract focus distance information and hopefully on which sensor the focus was taken. Does anybody know which exif information are responsible for that?
I have looked at Canon data and was able to locate distance information, but coudnt find the same in the Sony EXIF data
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on October 31, 2011, 07:23:26 AM
In general, cameras do not store accurate focus distance information.  The distance stored by Canon cameras is very rough and not very useful.  Some Nikon cameras store more accurate focus distance, but I haven't seen this information from Sony cameras.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on October 31, 2011, 07:27:53 AM
I see,
Driling more about subject - what about MF/AF information?

And if AF, information which sensor the focus was taken? I saw that Canon is displaying this information...
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on October 31, 2011, 09:01:34 AM
The focus mode is probably already decoded by ExifTool.  The AF point information is most certainly stored in the images somewhere, and the LocalAFAreaPoint information is already decoded for some Sony cameras.  If this information isn't decoded for your camera then it is possible to add this feature to ExifTool if you are willing to take some test pictures.  It would help if I knew what model we are talking about.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on October 31, 2011, 09:03:22 AM
Apologies, should have mentioned it from the start
Camera: Sony A55
Lenses: mix of D and non-D lenses all Sony or Minolta
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on October 31, 2011, 09:14:11 AM
Unfortunately the CameraSettings information (https://exiftool.org/TagNames/Sony.html#CameraSettings) hasn't yet been decoded for the A55, and this is where most of the focus information will be stored.  It will take some work to decode this information.  Let me know if you are willing to help by taking a series of test pictures.  It should only take about 20 pictures or so to decode the AF information, but a few hundred pictures to decode the rest of the CameraSettings information that has been decoded for other models.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on October 31, 2011, 09:21:12 AM
Not a problem, what pictures do you need?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on October 31, 2011, 09:32:14 AM
Great.  If you could take pictures with these settings, keeping careful track of the picture numbers so we don't get confused:

1-4) FocusMode: 1) Manual, 2) AF-S, 3) AF-C, 4) AF-A
5-7) AFAreaMode: 5) Wide, 6) Local, 7) Spot
8-) LocalAfAreaPoint: with the camera on Local AF mode, take a picture with each different AF area

This should cover the basic AF information.

Once you have done this, send me the EXIF from the images (email to philharvey66 at gmail.com).  Extract the EXIF with:

exiftool -o %d%f.exif DIR

where DIR is the name of the directory containing the test images.  Then zip up all of the .exif files and send them to me and I'll analyze them.

Thanks for doing this.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 01, 2011, 07:58:07 PM
Phil,
Since I'm a poor win user need to use exiftool.exe -o %%d%%f.exif -ext .ARW .
Data has been send to your email, i hope my notes are sounds and I did not messed up the order
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 02, 2011, 09:19:17 AM
Thanks.  I got the samples and have responded by email.  I have been able to decode all of the AF information from these.

You only need to double the '%' characters if you are running from a BAT file in Windows.  This shouldn't be necessary when run directly from the Windows command line.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 02, 2011, 01:08:10 PM
Phil,
The results looks great.


Cheers for %  clarification, I usually run batches...
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 03, 2011, 08:32:48 AM
Great.

If there are any more camera settings that you (or anyone else) wants decoded, I encourage you to send me some sample images and I will see what I can do to add this ability.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 03, 2011, 11:08:56 AM
Thank you. When is the update rolling out?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 03, 2011, 11:46:27 AM
At this point it looks like it should be early next week.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: milchtaich on November 03, 2011, 04:33:12 PM
The Sony A100 stores approximate distance information at two locations within the Minolta 0x0020 tag, which are not perfectly correlated.
I don't have any information about other, newer Sony cameras, which do not use the Minolta tags. Nevertheless, I hope the above will be of some use.

Igal Milchtaich
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 03, 2011, 09:26:53 PM
Hi Igal,

Thanks!  I will add this to the next version.  What exactly is the 0x003a-3b formula?  Is this version of the distance any more or less reliable than the 0x49bb one?

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: milchtaich on November 04, 2011, 07:06:51 AM
Hi Phil,
The best formula I could come with is this one. To get the distance in meters, multiply the value by 2^((70 -z)/16), where z is the raw decimal value of the approximate focal length tag (byte 0x49C6). The result usually agrees reasonably well with the 0x49bb one, except at close focus distances where the present tag is more coarse grained (fewer possible values).

Igal
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 04, 2011, 07:13:29 AM
Interesting, thanks.

It would be great to decode this for other models too.  I will see what I can do.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 04, 2011, 07:43:57 AM
I am very interested in this feature. I k ow that distance accuracy is low but even indication of infinity on my wide angle lenses (Minolta 20/2.8) would be of great benefit. It tends to go towards it, especially with people shots and this would allow me to filter out the missed shots easily.

I am more then happy to take more sample shoots on my A55, on the known base/with different lenses maybe ?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 04, 2011, 07:52:39 AM
Coincidentally, I am downloading a set of distance samples for the A55 as I write this.  imaging-resource has the focus distance tests which I can use for this, although the range of distances isn't great (6-16ft).

I'll let you know what I discover.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 04, 2011, 09:15:30 AM
As it turns out, the flash distance tests aren't ideal because 1) images are taken sequentially, so I can be fooled by other information that increments monotonically with shutter count, and 2) image distance is correlated with flash power, so I could be fooled by this too.

That having been said, here are the tags that incremented monotonically for the samples:

Tag 0x0010 0x3b32        : 85+2+2+3+1+3+1+2+3+1+3 (plus lots more in tag 0x0010 nearly identical to this)
Tag 0x0020 0x1244        : 18+18+30+5+10+0+2+0+0+2+2
Tag 0x0020 0x37d3        : 87+2+2+2+2+2+2+2+2+2+2
Tag 0x0020 0x37dd        : 32+4+4+4+4+4+4+4+4+4+4
Tag 0x0020 0x37e1        : 26+2+2+2+2+2+2+2+2+2+2
Tag 0x0020 0x3d06        : 6+2+2+2+2+2+2+2+2+2+2
Tag 0x0020 0x3e62        : 2+1+1+0+1+1+1+0+2+1+3
Tag 0x0020 0x3e66        : 3+0+1+1+2+1+2+0+3+0+1
Tag 0x0020 0x3e6a        : 2+0+0+1+3+2+2+0+2+0+1
Tag 0x0020 0x3f21        : 11+1+1+1+3+0+1+0+9+12+11
Tag 0x0020 0x3f25        : 12+1+3+2+3+3+3+0+7+6+9
Tag 0x0020 0x3f29        : 12+0+4+4+5+4+6+1+7+3+3
Tag 0x0020 0x3fd1        : 17+1+1+0+0+0+1+0+3+2+2
Tag 0x0020 0x3fd5        : 12+2+1+0+1+1+1+1+3+2+1
Camera Settings 3 0x0114 : 106+2+2+2+2+2+2+2+2+2+2
Camera Settings 3 0x01b4 : 31+11+11+11+11+11+11+11+11+11+11
Camera Settings 3 0x0200 : 6+2+2+2+2+2+2+2+2+2+2
Camera Settings 3 0x045f : 150+0+1+1+0+1+1+0+1+1+1


The first value given is the data at the 6ft distance, then the "+X" numbers are the difference between this and the next value for distances which increment by 1ft each, up to 16ft.

None of these possibilities really jumps out at me as being a good candidate.  I have tested a few of the better ones against other samples, and none gave consistently good results.

So we might be out of luck here for the newer Sony models.

- Phil

Edit: I should state for the record that this analysis was for the SLT-A55V
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 04, 2011, 09:30:56 AM
Phil,
Is the flash information only place that dist is stored? D lenses (all Sony and most new Minolota ones) send information to flash, so maybe there are other info location there?
I could design non-incremental test with flash/no-flash and including infinity to test those possibilities. I just need a few more advices here:
-would it be more meaningful to test with large differences in focal length (lets say 20 vs 200), sequential or just a single lens will do?
-what distance changes would you be intersted in? With fine weather I can take my disto and set out .5,3,5,10,20 and maybe 50 m baseline to shoot photos on.

Would this be of any help?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 04, 2011, 09:38:02 AM
I wasn't looking specifically at flash information.  Non-flash samples would be preferable just to avoid confusion with flash information.  Do you have a distance scale on the lens itself?  If you do, a quick set at each of the distances indicated on the lens with manual focus should do the job.  (taken in a random order to avoid the other coincidental correlations.)

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 04, 2011, 09:54:53 AM
Oki,
There is scale on most of my non-DT lenses. I can do those in the evening/over the weekend. One focal length or change them? Should I use prime or zoom?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 04, 2011, 10:27:15 AM
I don't think it matters what focal length or lens, as long as it is an autofocus lens (but set to manual focus for this test of course), and you use the same focal length for all shots.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 07, 2011, 03:37:56 PM
Phil,
I got a bit of deadline breach and can't deliver the photos at the moment. I'll try as soon as possible though...
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 16, 2011, 02:31:57 PM
Phil, how is this feature going? Do you need more samples?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 16, 2011, 05:49:39 PM
Thanks for the reminder, but I haven't forgotten.

The samples are sufficient, and I have analyzed them in some detail but haven't yet found the focus distance information.  I haven't given up yet though, but it isn't looking too hopeful at the moment.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 24, 2011, 06:30:05 PM
I took another close look at the metadata from your A55 test images, and unfortunately I still can't find anything that looks like a reliable focus distance. :(

I won't say that this information doesn't exist, but I will say that it is hiding very well if it does.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 24, 2011, 06:31:44 PM
That is a pity.
What about any information suggesting focusing to infinity? Is there anything like that?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on November 24, 2011, 06:38:24 PM
I only have one sample at infinity focus, so it isn't enough to track this down, but I wouldn't expect this information to exist other than with focus position information which I failed to locate.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on November 24, 2011, 07:45:28 PM
THank you for all hard work. Maybe A55 is too low level to get this information?
Title: Re: Distance information for Sony SLR cameras
Post by: rsjaffe on January 10, 2012, 09:08:21 PM
Quote from: LKB on November 24, 2011, 07:45:28 PM
THank you for all hard work. Maybe A55 is too low level to get this information?
I have a Sony A850, which is their full-frame camera (though a bit older than the A55). Would it be useful if I sent you EXIF dumps from this camera (in order to get distance info). If so, is there a particular set of distances (and/or type of lens--normal wide tele zoom etc) that would make it easier?

--Rory
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on January 11, 2012, 07:24:42 AM
Hi Rory,

Sure, let's give it a try.  How about this?:

For 2 lenses of different focal lengths, shoot a picture using manual focus at each numbered distance on the focus barrel.  Add the focus distance to each file name, then use the following command and send me the EXIF files (mail them to philharvey66 at gmail.com):

exiftool -tagsfromfile @ -all:all -o %d%f.exif DIR

where DIR is the name of the directory containing the images.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: mikey2000 on January 11, 2012, 07:36:33 AM
I saw that the website notes about maker notes now includes info about A55 local AF area.   I was wondering if you have sample images yet from an a77?

I would also be keen to see focus distance information if it's possible to extract it from a77 exif, even if it is only approximate.

Cheers,
Michael
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on January 11, 2012, 07:40:16 AM
Hi Michael,

Thanks for the offer.

I would be willing to bet that I wouldn't be able to decode focas distance information from the A77.  However, focus position should definitely be possible.

If you take a picture using each of the AF points and send me the EXIF files (use the command in my previous post), then I'll decode this information and add it to the next release.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: mikey2000 on January 12, 2012, 01:35:56 AM
No problem!  I've just sent you an email with the exif from various photos.

This is very much appreciated!

Cheers,
Michael
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on January 12, 2012, 08:22:34 AM
Hi Michael,

Thanks for the samples.

As I was analyzing them, I had a strong feeling of déjà vu.  It turns out I did this before, back in November (https://exiftool.org/forum/index.php/topic,3692.msg16953.html#msg16953).

Unfortunately, I get the same result with the samples you sent.  I can't find the AF information anywhere.

I can't believe that the information just isn't there.  Perhaps it is encrypted somehow, and maybe with the samples I am accumulating I'll be able to figure this out sometime.

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: mikey2000 on January 15, 2012, 02:13:33 PM
Sony strikes again!   Thanks for looking though.  If you need more a77 samples for other purposes, just ask!

Cheers
Michael
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on January 16, 2012, 11:56:16 AM
I just got the A850 samples for Rory, and found a byte in tag 0x0020 which gives the focus position with a roughly linear relationship to distance.  However, it varies with the focal length, so some further analysis is necessary to see if it can be converted to a focus distance:

(https://exiftool.org/pics/SonyFocusDistance.gif)

Edit: Rory sent me an email indicating that the one lens was 135mm, not 35mm.  I don't understand this, because the EXIF says 35mm, but if true the formula changes to  distance = val * FocalLength / 1000, which is nicer, makes more sense, and fits the data better.

Edit2: Changed the above plot to use the new formula, and added data for the 400mm focal length. (Thanks Rory!)

Note that the right side of the plot is a value of 128, which is the maximum value for this byte, so it represents infinity focus for each lens.
Title: Re: Distance information for Sony SLR cameras
Post by: mikey2000 on January 16, 2012, 12:21:07 PM
Would you like some a77 samples with a variety of focal length/focus distances?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on January 16, 2012, 01:00:57 PM
Hi Mikey,

Thanks for the offer, but I already have A77 samples like this and I haven't been able to determine where/if this information is stored in A77 images.  The A77 doesn't have the 0x0020 tag, which is where this is found in A100 and A850 images.

- Phil

Edit: I just checked since I am home now with my full set of samples, and it turns out that I don't have focus distance samples for the A77 (I was thinking about the A55).  So if you want to send me some samples, feel free, although we shouldn't get our hopes up.  You can follow the instructions in this thread (https://exiftool.org/forum/index.php?topic=3688.msg17699#msg17699) and send me the EXIF files
Title: Re: Distance information for Sony SLR cameras
Post by: LKB on February 24, 2012, 04:57:03 PM
So do I understand correctly that distance extraction seems to be only possible with A100 & A900 (and possibly A850) on this stage?
Title: Re: Distance information for Sony SLR cameras
Post by: Phil Harvey on February 25, 2012, 06:43:15 AM
Looking back through my records, here are the models I have checked so far, and whether or not I could find FocusDistance information in their images:

Models where I have a full set of focus-distance test shots:

A55 - no
A77 - no
A100 - yes
A560 - no
A580 - no
A850 - yes
NEX-3 - no
NEX-5 - no
NEX-C3 - no

Models where I have a couple of shots, so I'm not sure about these:

A33 - no
A35 - no
NEX-7 - no

- Phil
Title: Re: Distance information for Sony SLR cameras
Post by: JosR on September 08, 2014, 02:12:07 PM
Some updates to this topic, based on recent findings:

1) The existing FocusPosition (Tag 0x0020 FocusInfo, offset 0x09bb), which was validated for the DSLR-A850, is most probably valid
for ALL the earlier DSLR models (except DSLR-A100) as all these have similar Makernotes,
i.e. valid for the DSLR-A200/A300/A350/A230/A290/A330/A380/A390/A700/A850/A900.

2) For the DSLR-A580, I recently found FocusPosition info, also in Tag 0x0020 (MoreInfo - MoreSettings).
However, in this case, the values range from appr. 80 to 255, with 255 indicating Infinity.
For converting this FocusPosition into FocusDistance, I found that the formula mentioned in minolta.pm at WBInfoA100 - 0x49bb
provided the best match for my series of A580 test shots with different focal lengths and at different distances:
    (1.5*2**($val/16-5) + 1) * FocalLength/1000
This FocusPosition info is present in MoreSettings
at offset 0x0029 for the DSLR-A450/A500/A550
at offset 0x002b for the NEX-3/5/5C
at offset 0x002f for the DSLR-A560/A580, SLT-A33/A35/A55V and NEX-C3/VG10E

3) Searching for similar FocusPosition tags for all the newer SLT, NEX, ILCE and ILCA models, I found the following:
Tag9402 offset 0x002c and/or 0x002d: for all newer NEX- and all ILCE-models
Tag9404b offset 0x0020: for newer SLT- and ILCA-models, EXCEPT SLT-A65V and A77V
(A77V/A65V were the first SLT models with the new 94xx Makernote tags - possibly FocusPosition for these models was left out 'accidentally' ...)

For info, attached is a plot of my own tests with the A580, and including the A580 flash distance images from Imaging-resource:
- a reasonable match, except only for 16 mm where the formula appears to give too high distance values ...

Also, for many sample images that I checked, the above formula gave mostly 'acceptable' distance indications, as far as I could deduce from the image and the FocalLength.
But for validation, more tests with other cameras would be very welcome...