Author Topic: Trouble getting Depth map from Pixel 4a image  (Read 1326 times)

digital_pro

  • Newbie
  • *
  • Posts: 5
Trouble getting Depth map from Pixel 4a image
« on: October 10, 2020, 11:05:00 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18771
    • ExifTool Home Page
Re: Trouble getting Depth map from Pixel 4a image
« Reply #1 on: October 11, 2020, 06:11:35 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

digital_pro

  • Newbie
  • *
  • Posts: 5
Re: Trouble getting Depth map from Pixel 4a image
« Reply #2 on: October 11, 2020, 02:50:05 PM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 5862
Re: Trouble getting Depth map from Pixel 4a image
« Reply #3 on: October 11, 2020, 03:24:22 PM »
If you're using Powershell, switch to CMD.  Powershell will corrupt binary data that is redirected or piped.  See here.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

digital_pro

  • Newbie
  • *
  • Posts: 5
Re: Trouble getting Depth map from Pixel 4a image
« Reply #4 on: October 11, 2020, 03:35:45 PM »
StarGeek -- Thanks! That was exactly it. Seems like a really awful bug to have existed apparently for years. -- David

digital_pro

  • Newbie
  • *
  • Posts: 5
Re: Trouble getting Depth map from Pixel 4a image
« Reply #5 on: October 12, 2020, 10:01:11 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18771
    • ExifTool Home Page
Re: Trouble getting Depth map from Pixel 4a image
« Reply #6 on: October 12, 2020, 10:27:58 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

digital_pro

  • Newbie
  • *
  • Posts: 5
Re: Trouble getting Depth map from Pixel 4a image
« Reply #7 on: October 12, 2020, 10:33:21 PM »
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.