How to get depth map in Android Q

前端 未结 1 1544
我寻月下人不归
我寻月下人不归 2020-12-30 15:11

in Android Q there is a option to get depth map from image.

Starting in Android Q, cameras can store the depth data for an image in a separate file, u

相关标签:
1条回答
  • 2020-12-30 16:12

    If you retrieve a DYNAMIC_DEPTH jpeg, the depth image is stored in the bytes immediately after the main jpeg image. The documentation leaves a lot to be desired in explaining this; I finally figured it out by searching the whole byte buffer for JPEG start and end markers.

    I wrote a parser that you can look at or use here: https://github.com/kmewhort/funar/blob/master/app/src/main/java/com/kmewhort/funar/preprocessors/JpegParser.java. It does the following:

    1. Uses com.drew.imaging.ImageMetadataReader to read the EXIF.
    2. Uses com.adobe.internal.xmp to read info about the depth image sizes (and some other interesting depth attributes that you don't necessarily need, depending on your use case)
    3. Calculates the byte locations of the depth image by subtracting each trailer size from the final byte of the whole byte buffer (there can be other trailer images, such as thumbnails). It returns a wrapped byte buffer of the actual depth JPEG.
    0 讨论(0)
提交回复
热议问题