Forum Archive

Extracting Portrait Photo depth map using objc_util

avonlady

Hi,

I was wondering if it is possible to use objc_util to extract depth map from Portrait Photos. Apple has some official code samples on their Developer site, but I wasn't able to make them work in Pythonista.

Any advice will be dearly appreciated.
Thank you

mikael

@avonlady, can you share the code you already have?

avonlady

Unfortunately, I wasn’t able to construct anything even barely functional. It seems that to get the depth data I need to load the image data using functions from the ImageIO framework, and while I figured out how to load a framework and call a class, I don’t know how to call a function that does not reside in a class (e.g. CGImageSourceCopyAuxiliaryDataInfoAtIndex).
These are the resources I tried to use, but I wasn’t able to convert any of the examples into Pythonista’s syntax:
1) https://developer.apple.com/documentation/avfoundation/avdepthdata/2881221-depthdatafromdictionaryrepresent?language=objc
2) https://stackoverflow.com/questions/50240637/getting-depth-data-from-uiimagepickercontroller
3) https://stackoverflow.com/questions/53753640/depth-map-from-avdepthdata-different-from-heic-file-depth-data-in-photoshop