Trouble getting Depth map from Pixel 4a image

Started by digital_pro, October 10, 2020, 11:05:00 PM

Previous topic - Next topic

digital_pro

I'm not sure whether this is a bug or simply that none of the suggested methods I can find for extracting the depth map from a current Pixel 4a image using the latest version of Google's Camera are working for me. I've tried just about every combination of .config file (from February) and various ways of expressing the tag, but can't get the latest version of Exiftool (Windows EXE downloaded tonight), to output anything. I'm pretty familiar with Exiftool (since nearly day 1), but have never used it for a depth map. Would love to hear what will work. I've attached the depth-enabled version of a sample image. I know it has a depth map because if I open it online with photopea, it finds it.

There is some merit to this quest, as I'm helping teach an imaging course at Stanford and we've bought a few of the phones for our lab, so it'd be great for the students to be able to experiment with the depth data.

Thanks for any help. I've attached an example of an image I'm looking to get the depth from. -- David

Phil Harvey

The depth map is the the second trailer in this image.  You can extract it like this:

exiftool pxl_depth.jpg -trailer -b | exiftool - -trailer -b > depthmap.jpg

- 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 ($).

digital_pro

Phil -- Thanks! It works perfectly on Linux. However, on Windows 10 using exiftool 12.07 I get an odd behavior where while -trailer recognizes the correct size of the trailer image (1498774 bytes), when I add the -b flag to write it out, I get a larger file (attached) that doesn't seem to be useable. Not sure if there is some other flag I need to use? Thanks, as always.

StarGeek

If you're using Powershell, switch to CMD.  Powershell will corrupt binary data that is redirected or piped.  See here.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

digital_pro

StarGeek -- Thanks! That was exactly it. Seems like a really awful bug to have existed apparently for years. -- David

digital_pro

Now that I can read the depth map, has anyone found accurate documentation on the encoding? From experimentation it appears to be in "diopters" (maybe 1/meters) and the values are based on a 128 for the subject distance, as histograms are grouped there. I'm well into sorting that out, but it seems like there should be a secret squirrel decoder ring for what Google writes out someplace. Thanks! -- David

Phil Harvey

Sorry, I don't know anything about how to interpret a depth image.

- 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 ($).

digital_pro

Phil -- Thanks as always for your prompt reply. I'm slogging through taking some calibration images and will eventually get out the other side. Strange that Google goes as far as publishing a spec, but then doesn't bother tying it down to their specific implementation. Not sure if that is on purpose or just lazy.