ExifTool Forum

General => Metadata => Topic started by: ulrichk7 on May 26, 2024, 07:22:54 AM

Title: AFInfo Tags for Pentax K3-iii
Post by: ulrichk7 on May 26, 2024, 07:22:54 AM
HI,

found some infos about the tag here (https://exiftool.org/TagNames/Pentax.html#AFInfo) .
This seems to be what is used by the K3-iii (the AFPointsInFocus is empty), but some of the info is not relevant for K3-iii(?)

I wonder, if it is possible to get the points in focus and to assign them to one of the 101(!) AF points of the camera.
The camera knows this  ;) see attachment - foto of the LCD monitor and the red-dot mark of the point in focus (Autofocus_sample.jpg).

My 'project' is to show this on the PC. Therefor I extract the (smaller) jpg from the DNG by
exiftool -b -W %d%f_AF.%s -copy0:previewimage -PreviewImage picture.DNG

An then fade it and compose with a prepared png of all AF points by
convert picture_AF.jpg -fill white -colorize 50% AF_points.png -gravity center -composite picture_with_AF_points.jpg

This works quite well and results in the second attachment (picture_with_AFpoints.jpg).

While this was the easy part, the question is now how to get the points in focus from the EXIF AFInfo and color them in red in the output?

exiftool -U -s '-Pentax_AFInfo*' picture.DNG
gives me 4976 lines of output.

I could prepare some sample DNG or need advice how to proceed.
Thank you in advance

Ulrich





Title: Re: AFInfo Tags for Pentax K3-iii
Post by: StarGeek on May 26, 2024, 10:33:44 AM
Unfortunately, most camera companies do not document their MakerNotes. What is known of the MakerNotes has only been found by people testing things out by taking a photo, changing a setting, taking another photo, compare what has changed, etc.

It's quite probable that nobody knows what all that data means. Two of the tags listed under AFInfo literally have "Unknown" in their name.

So there's not much help to be offered. With thousands of lines of data, it seems like a huge task that nobody has felt it was worth the time needed to decode it, especially since camera companies are constantly changing formats and the results might not be transferable to other models.
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: ulrichk7 on May 26, 2024, 01:12:35 PM
Thank you StarGeek for the quick reply.
Yes, I was afraid of that. 4976 is a bit too much for trial and error.
I also read somewhere that the meaning might change in different firmware versions.
So I guess I will live with the two easy steps and - in case - do the coloring manually according to the LCD info.

Ulrich
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on May 27, 2024, 01:37:46 PM
This shouldn't be too hard to find.  If more than 1 AF point may be active at the same time, then the 101 AF points may be represented by the bits in 13 bytes.  But presumably there is also a primary AF point that may be represented by a single byte.  If you can shoot a series of 8 images I may be able to figure it out.  If we number the AF rows by letter A-I and the columns 1-13, then samples with AF points in this sequence would be good: A1,A2,A3,A13,B1,B2,E7(center),I13.  (For reference the picture you posted uses A11.)  You can email the samples to me: philharvey66 at gmail.com

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 06, 2025, 11:29:27 AM
Quote from: Phil Harvey on May 27, 2024, 01:37:46 PMThis shouldn't be too hard to find.

Since there were no further replies to this topic and I couldn't find any corresponding entries in the "ancient history" I assume the task was hard enough so that nobody dared to tackle this 😄

A user of the LrC focus point plugin (https://github.com/musselwhizzle/Focus-Points) has contacted me to asked for K-3 III support. Of course, I'm unable to visualize focus points information that exiftool does not decode.

The guy has provided me with 41 JPG ooc images (one per each user-selectable point in focus) and I have gathered all Pentax_AFInfo tags in one big Excel file (4969 tags x 41 values). If you remove the all-zero tags, there are still ~2800 lines left.

From your experience, can you advise how to approach this to narrow down the potential entries and finally identify the relevant tags?

Thanks, Karsten
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 06, 2025, 02:38:39 PM
Hi Karsten,

I assume you know which focus point is selected for each image.

The easiest thing to do would be to upload these files somewhere and send me a link so I can look at them myself.  I have developed some scripts to compare metadata in multiple files to look for things like this.  My email is philharvey66 at gmail.com

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 06, 2025, 04:28:51 PM
I got the files and have taken a first look... nothing obvious.  Are we sure that this information is recorded?  Does any Pentax software show the AF points for this model?

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 07, 2025, 03:07:20 AM
I have tried Pentax' Software Digital Camera Utility Version 5 (DCU) some weeks ago - unfortunately it doesn't show focus points. My contact is not aware of any other way than using the camera display.

Since the JPGs are OOC I would expect that focus point information has been recorded. Anyway, I will double check with my contact to make sure the camera displays focus points for these JPGs.
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 07, 2025, 02:31:23 PM
My contact has confirmed that he only recorded JPGs and for these the camera does show focus points.

He also noted:

The SEL XS focus points, which I used for the test images were added to the K 3-III only with firmware version 1.70 in Dec 2022. Originally, the SEL S focus points were slightly larger. "Focusing when using the viewfinder can now be even more precise. The active focus area now also has the option of (XS) for the active AF area in addition to the (S) option."

He will do a second series of 41 images tomorrow using the SEL S focus points, which are slightly larger but exactly in the same place. I have no clue if/how this affects the coding of tags, but if your analysis is fully automated and script-based, it might be worthwhile to give it a try.

- Karsten
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 07, 2025, 03:00:45 PM
OK.  These samples could be helpful.  Thanks.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 08, 2025, 12:40:19 PM
I got the second set, thanks.

I've managed to decode the AF Points for the files you sent.  As well, I've fixed decoding of the sensor temperature.  This is what I get for the files:

> exiftool K3-III_AFPoints_* -filename -afpoints -afpointsunknown -sensortemperature -u -T
IMG46885.JPG C2 C2 32.1 C
IMG46886.JPG C3 C3 32.1 C
IMG46887.JPG C4 C4 32.1 C
IMG46888.JPG C5 C5 32.1 C
IMG46889.JPG C6 C6 32.2 C
IMG46890.JPG C7 C7 32.2 C
IMG46891.JPG C8 C8 32.2 C
IMG46892.JPG D1 D1 32.3 C
IMG46893.JPG D2 D2 32.3 C
IMG46894.JPG D3 D3 32.4 C
IMG46895.JPG D4 D4 32.3 C
IMG46896.JPG D5 D5 32.4 C
IMG46897.JPG D6 D6 32.5 C
IMG46898.JPG D7 D7 32.5 C
IMG46900.JPG D8 D8 32.5 C
IMG46901.JPG D9 D9 32.6 C
IMG46902.JPG E1 E1 32.7 C
IMG46903.JPG E2 E2 32.7 C
IMG46904.JPG E3 E3 32.6 C
IMG46905.JPG E4 E4 32.7 C
IMG46906.JPG E5 E5 32.7 C
IMG46907.JPG E6 E6 32.7 C
IMG46908.JPG E7 E7 32.8 C
IMG46909.JPG E8 E8 32.9 C
IMG46910.JPG E9 E9 32.9 C
IMG46911.JPG F1 F1 32.9 C
IMG46912.JPG F2 F2 33.0 C
IMG46913.JPG F3 F3 33.0 C
IMG46914.JPG F4 F4 33.0 C
IMG46915.JPG F5 F5 33.0 C
IMG46916.JPG F6 F6 33.1 C
IMG46917.JPG F7 F7 33.1 C
IMG46918.JPG F8 F8 33.1 C
IMG46919.JPG F9 F9 33.2 C
IMG46920.JPG G2 G2 33.2 C
IMG46921.JPG G3 G3 33.3 C
IMG46922.JPG G4 G4 33.3 C
IMG46923.JPG G5 G5 33.3 C
IMG46924.JPG G6 G6 33.3 C
IMG46925.JPG G7 G7 33.4 C
IMG46926.JPG G8 G8 33.4 C
IMG46954.JPG C2 C2 24.9 C
IMG46955.JPG C3 C3 25.0 C
IMG46956.JPG C4 C4 25.1 C
IMG46957.JPG C5 C5 25.1 C
IMG46958.JPG C6 C6 25.3 C
IMG46959.JPG C7 C7 25.4 C
IMG46960.JPG C8 C8 25.4 C
IMG46961.JPG D1 D1 25.6 C
IMG46962.JPG D2 D2 25.6 C
IMG46963.JPG D3 D3 25.8 C
IMG46964.JPG D4 D4 25.9 C
IMG46965.JPG D5 D5 26.1 C
IMG46966.JPG D6 D6 26.1 C
IMG46967.JPG D7 D7 26.1 C
IMG46968.JPG D8 D8 26.3 C
IMG46969.JPG D9 (none) 26.4 C
IMG46970.JPG E1 E1 26.4 C
IMG46971.JPG E2 E2 26.5 C
IMG46972.JPG E3 E3 26.5 C
IMG46973.JPG E4 E4 26.7 C
IMG46974.JPG E5 E5 26.7 C
IMG46975.JPG E6 E6 26.8 C
IMG46976.JPG E7 E7 26.8 C
IMG46977.JPG E8 E8 27.0 C
IMG46978.JPG E9 E9 27.0 C
IMG46979.JPG F1 E1.E3.F1 27.1 C
IMG46980.JPG F2 F2 27.2 C
IMG46981.JPG F3 F3 27.2 C
IMG46982.JPG F4 F4 27.3 C
IMG46983.JPG F5 F5 27.3 C
IMG46984.JPG F6 F6 27.4 C
IMG46985.JPG F7 F7 27.5 C
IMG46986.JPG F8 F8 27.6 C
IMG46987.JPG F9 F9 27.7 C
IMG46988.JPG G2 G2 27.8 C
IMG46989.JPG G3 G3 27.8 C
IMG46990.JPG G4 G4 27.9 C
IMG46991.JPG G5 G5 27.9 C
IMG46992.JPG G6 G6 28.0 C
IMG46993.JPG G7 G7 28.1 C
IMG46994.JPG G8 G8 28.1 C

Each AF point is represented by a different byte in the AFInfo record, but the order of the points is weird: C3 C4 C5 C6 C7 D3 D4 D5 D6 D7 E3 E4 E5 E6 E7 F3 F4 F5 F6 F7 G3 G4 G5 G6 G7 E1 E9 D2 D8 E2 E8 F2 F8 C2 C8 G2 G8 D1 D9 F1 F9.  Using the -n option gives you the original byte values instead of the AF point names as above.

The decoding for XS and S modes is the same.

I don't know what AFPointsUnknown is indicating, so I'll extract this as an Unknown tag for now.

Expect this update in version 13.27.

- Phil

Edit: Fixed ExifTool version number
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 08, 2025, 01:22:26 PM
OMG, you're a magician, Phil 👏👏👏

I have spent like an hour, filtering out tags that don't seem to be relevant, and searching for row patterns for the remaining tags. What is the trick to approach such a task? Or is it your business secret? 😉😄

P.S.: I guess you're referring to 13.27, right?
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 08, 2025, 03:36:41 PM
Yes, 13.27.

The trick was to stare at the -U output until my head started throbbing... ;)

And I'm still staring.  There is some other potentially interesting stuff happening in the AFInfo record.  My normal technique for AF points didn't work because normally they don't have a separate byte for each point.  What worked was to look for bytes that were different for only one image, then I noticed that there was a set of bytes where a different one was non-zero for each image.  It would have been easier if the AF points were ordered, but eventually I spotted this.  It didn't help that some AF points were labelled incorrectly in the 2nd set of images you sent, but this set of images was very helpful for comparison.

The other interesting stuff seems to be a measurement done at each AF point, with a second measurement at each of the 33 inner AF points.  These measurements have values between about -100 and +200, but I don't know what they mean.  I think I'll extract these as AFPointValues and make it Unknown.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 08, 2025, 05:22:01 PM
13.27 is now available.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 08, 2025, 08:44:15 PM
Minor change upcoming in 13.28:  In the event that multiple AF points are active, 13.27 uses a dot (.) as a separator.  13.28 will use a comma (,).

Also, I'm thinking the tag should be called AFPointsSelected instead of AFPoints.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 09, 2025, 09:11:45 AM
Quote from: Phil Harvey on April 08, 2025, 08:44:15 PMAlso, I'm thinking the tag should be called AFPointsSelected instead of AFPoints.
Looking at other Pentax models I'm not sure if AFPointsSelected would be the best choice. See attached screenshots of the test images I have.

The plug-in's current logic is to query AFPointSelected (w/o "s") and AFPointsInFocus and visualize the result. AFPointsSelected (w/ "s") has been used by exiftool only for K-1 and K-1 II but in this case it was redundant information.

If I look at the ExifToolGUI folder view for K-3 (8 images) and K-3 II (87 images), only AFPointSelected (w/o "s") and AFPointsInFocus have data. Somehow I get the feeling that it's strange that AFPointsInFocus is "none" for 6 out 8 images and there's not a K-3 II single image out of the 87 that has more than 1 AFPointsInFocus.

Anyway, I have posted introduction of the plugin in PentaxForums right now, and I expect there will be some feedback to better understand to what an extent the AF point tags match shooting practice. Plus, I want to collect response from real-world tests for K-3 III AF info.

As for the plugin, my aim for Pentax is same as for Nikon, i.e. getting rid of questionable combinations of selected/used/infocus and just put simple boxes, hopefully for not too many different tags for different models. With Warren's help I was able to figure out the one tag which is the relevant for all Nikon cameras (not considering the exceptions ;D )

In this context, it seems to me that AFPointsInFocus would be the better choice.

What do you think?


Pentax Various.jpg
Pentax K3.jpg
Pentax K3 II.jpg
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 09, 2025, 11:51:58 AM
This values of this tag may in fact indicate focus, but I can't tell.  All of the values are 2 for all of the samples.  All I can say for sure from the samples is that the AF point was selected.  A different value may indicate selected but not focused.  I include the "s" in this tag name not because I have seen multiple values, but because this is possible (unlike single-byte values for eg. AFPointSelected).

I don't know if the K-3II has its focus points decoded properly, but maybe we'll find out.  The K-3III seems very different in the way it stores this information.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 09, 2025, 12:19:04 PM
OK, then let's proceed with whatever tag name you consider to be reasonable at this point.

On another topic that I forgot to mention in my prev post.

We have currently focused (nice pun, isn't it 😄) on the 41 user selectable focus points. The K-3 III has additional 60 not selectable points. If tag-wise these are handled like the non-selectable points on e.g. Nikon D850 (according to Warren, these never show up in the AF tags) then I would assume there is no real need to deal with that.

In case it's not - what would happen if exiftool encounters e.g. A1, A2 etc.?
(in this context, my contact should have probably better chosen 13x9 grid for the naming scheme, not 10x10).

K-3 III AF Layout.png
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 09, 2025, 12:40:22 PM
Interesting.  There are exactly 60 unknown bytes between AFPointsSelected and AFPointsUnknown.  The problem is that even if these represent the other 60 AF points it will be very difficult to figure out which bytes correspond to which points due to the irregular ordering of the AF points.

Right now, ExifTool decodes only the 41 points used in the samples.

I don't know why your user decided on E5 as the name of the central point.  I hope there was a good reason because I can't reconcile this with the AF-point diagram in your post.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 09, 2025, 03:08:11 PM
Quote from: Phil Harvey on April 09, 2025, 12:40:22 PMI don't know why your user decided on E5 as the name of the central point.  I hope there was a good reason
I'm afraid there wasn't. And I didn't pay attention - sorry for that. I will check with him.

I will finish with some good news for today.

It seems I managed to find a quick and good mapping of the focus point names to pixel coordinates and was able to build the first prototype for K-3 III. The test images looked very good. Then I poured a glass of red wine and ran the plugin on the ~90 samples downloaded from dpreview. 8 were taken using Contrast Detect AF (with FaceDetect / ContrastDetect data still missing in EXIF) but the remaining ones looked really good!

Cheers to you and many thanks for your great support, Phil!

Cheers.jpg





Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 10, 2025, 11:58:06 AM
My contact confirmed that he didn't choose the names for a certain reason :(

I have prepared an Excel file with a proper scheme if you want to fix that in 13.28. See attachment.

First testing on 'real world' images looks really good!

Before giving this to the K-3 III users at Pentax Forums for extended testing I wanted to check with you, how complex you consider the task to decode information on contrast AF (ContrastDetectAfArea and FaceDetect information).

Would this need to be approached similarly to finding the focus points, i.e. capturing specific scenes (perhaps with specific settings), then trying to identify the respective tags?


K-3 III AF Points.jpg


Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 10, 2025, 12:43:25 PM
In the left side of your spreadsheet, do you mean to number the rows 2-10?  I think this should be 1-9 like the right side, correct?  I'll update 13.28 to use A1 though M9 with G5 as the center point.

Decoding contrast-detect and face-detect should be possible if I had a few sample images.  I probably don't need a full set for these because they tend to be stored a bit more logically than the phase-detect points.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 10, 2025, 01:36:51 PM
Quote from: Phil Harvey on April 10, 2025, 12:43:25 PMIn the left side of your spreadsheet, do you mean to number the rows 2-10?  I think this should be 1-9 like the right side, correct?  I'll update 13.28 to use A1 though M9 with G5 as the center point.
Oh sh... yes, you're right. I have used a formula to fill the cell values starting from A1 and when I was done with the summary per row on the right side I inserted a row at the top to place the heading "Focus points:" :-[

I have 8 images captured with contrast AF, at least one of them clearly shows a face. Perhaps Christian has some more faces to add. I will put the images in my dropbox and mail you the link.
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: blue-j on April 10, 2025, 09:04:43 PM
I love this Lightroom plug-in!  So cool!  i would love to reproduce it on the web, and contribute toward the data wrangling.  Any guidance toward that end?  I see most of the plugin is in Lua, and the logic in not trivial, so porting to the web could end up taking years off my life.... ?  Is there a shared database of AF points?  Could ExifTool be made to create a composite tag, or do they vary too much?  - J
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 11, 2025, 03:17:33 AM
Quote from: blue-j on April 10, 2025, 09:04:43 PMwould love to reproduce it on the web
The first thing that needs to be clarified before starting such a project is whether it is in accordance with the copyright holder's license terms. Which is not me, but the person who owns the Github repository and started this development:

https://github.com/musselwhizzle/Focus-Points#license (https://github.com/musselwhizzle/Focus-Points#license)

I suggest that you go to Github and create an issue for your request, as far as it concerns the plugin (not exiftool). I can use this as a reference to approach Joshua (the owner). We can also have all kinds of technical discussion there (Lua, AF point logic etc.). We should not hijack this thread which is about Pentax AF.

- Karsten
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 11, 2025, 09:17:30 AM
I've had a look at the contrast-detect samples and I can't see anything obvious.  I think more samples are necessary.  A few samples with exactly the same settings and the face and focus subject in different locations would be useful.   And some with multiple faces.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: blue-j on April 11, 2025, 01:24:51 PM
Karsten, i already knew the license before asking, thanks.  i was not hijacking the thread, nor was i off topic or inappropriate in posting this in the exiftool forum, if you read more slowly.  i was also asking whether a composite tag were possible, and whether a public database of AF points was already in the works.  Phil must have decoded these things a hundred times or more by this point!

- J
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: Phil Harvey on April 11, 2025, 02:10:21 PM
I don't know exactly what you are thinking of for the public database, but to be useful it would include coordinates for drawing the AF areas, which is somewhat beyond the scope of ExifTool.  However, if this information was available it could theoretically be used in a Composite tag of a custom config file, but likely isn't something I would build into the production ExifTool.

- Phil
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: capricorn on April 11, 2025, 02:25:26 PM
Quote from: blue-j on April 11, 2025, 01:24:51 PMi was not hijacking the thread
I'm sorry if you took my post as a blame - this was not my intention. It was just an offer to have detailed plugin related discussion in a place where this belongs.
Title: Re: AFInfo Tags for Pentax K3-iii
Post by: blue-j on April 13, 2025, 03:55:37 PM
Understood!  Sorry I overreacted.  Makes sense.  : )

- J