如何在 Android Q 中获取深度图 [英] How to get depth map in Android Q

查看:57
本文介绍了如何在 Android Q 中获取深度图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android Q 中,有一个选项可以从图像中获取深度图.

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

从 Android Q 开始,相机可以使用称为动态深度格式 (DDF) 的新架构将图像的深度数据存储在单独的文件中.应用程序可以请求 JPG 图像及其深度元数据,使用该信息在后处理中应用他们想要的任何模糊,而无需修改原始图像数据.要阅读新格式的规范,请参阅动态深度格式.

Starting in Android Q, cameras can store the depth data for an image in a separate file, using a new schema called Dynamic Depth Format (DDF). Apps can request both the JPG image and its depth metadata, using that information to apply any blur they want in post-processing without modifying the original image data. To read the specification for the new format, see Dynamic Depth Format.

我已阅读此文件动态深度格式看起来深度数据作为 XMP 元数据存储在 JPG 文件中,现在我的问题是如何从文件或直接从 android API 获取此深度图?我正在使用带安卓 Q 的 Galaxy s10

I have read this file Dynamic Depth Format and it looks that depth data is stored in JPG file as XMP metadata and now my question is how to get this depth map from file or directly from android API? I am using galaxy s10 with anrdoid Q

推荐答案

如果您检索 DYNAMIC_DEPTH jpeg,则深度图像将存储在主 jpeg 图像之后的字节中.文档在解释这一点时还有很多不足之处;我终于通过在整个字节缓冲区中搜索 JPEG 开始和结束标记来解决这个问题.

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.

我写了一个解析器,你可以在这里查看或使用:https://github.com/kmewhort/funar/blob/master/app/src/main/java/com/kmewhort/funar/preprocessors/JpegParser.java.它执行以下操作:

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. 使用 com.drew.imaging.ImageMetadataReader 读取 EXIF.
  2. 使用 com.adobe.internal.xmp 读取有关深度图像大小的信息(以及您不一定需要的其他一些有趣的深度属性,具体取决于您的用例)
  3. 通过从整个字节缓冲区的最后一个字节中减去每个预告片大小来计算深度图像的字节位置(可以有其他预告片图像,例如缩略图).它返回实际深度 JPEG 的包装字节缓冲区.
  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.

这篇关于如何在 Android Q 中获取深度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆