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

查看:447
本文介绍了如何在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获取此深度图? 我正在将银河s10与拟南芥Q一起使用

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.

我写了一个解析器,您可以在这里查看或使用:

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天全站免登陆