- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试构建一个示例 Android 应用程序来提取使用谷歌相机应用程序拍摄的人像模式照片的深度图。我知道它是沿着模糊的照片保存的。
我阅读了来自 Google 的动态深度格式文档:https://developer.android.com/training/camera2/Dynamic-depth-v1.0.pdf这是非常新的,我找不到与此主题相关的任何资源或如何管理 android 肖像的深度图的提取。
我使用元数据提取器库以编程方式读取文件的元数据,尤其是 XMP 部分,因为它是描述深度信息的地方。我用 Kotlin 编写了一个示例代码来尝试提取深度图:
val inputStream = contentResolver.openInputStream(imageUri)
inputStream?.let { stream ->
val metadata = JpegMetadataReader.readMetadata(stream)
val directories = metadata.directories
val xmpDirectories = metadata.getDirectoriesOfType(XmpDirectory::class.java)
for (xmpDirectory in xmpDirectories) {
val xmpMeta = xmpDirectory.xmpMeta
val itr = xmpMeta.iterator()
while (itr.hasNext()) {
val propertyInfo = itr.next() as XMPPropertyInfo
println(propertyInfo.path + " :: " + propertyInfo.value)
}
}
stream.close()
}
结果输出:
xmpNote:HasExtendedXMP :: 5c970bbab778024b23c5a8269325455c
null :: null
GCreations:CameraBurstID :: 9e286063-a919-4a74-96ee-d7e02d2a17d2
null :: null
GCamera:BurstID :: 9e286063-a919-4a74-96ee-d7e02d2a17d2
GCamera:BurstPrimary :: 1
GCamera:SpecialTypeID ::
GCamera:SpecialTypeID[1] :: com.google.android.apps.camera.gallery.specialtype.SpecialType-PORTRAIT
null :: null
Device:Container ::
Device:Container/Container:Directory ::
Device:Container/Container:Directory[1] ::
Device:Container/Container:Directory[1]/Item:Mime :: image/jpeg
Device:Container/Container:Directory[1]/Item:Length :: 0
Device:Container/Container:Directory[1]/Item:DataURI :: primary_image
Device:Container/Container:Directory[1]/rdf:type :: http://ns.google.com/photos/dd/1.0/container/:Item
Device:Container/Container:Directory[2] ::
Device:Container/Container:Directory[2]/Item:Mime :: image/jpeg
Device:Container/Container:Directory[2]/Item:Length :: 1499039
Device:Container/Container:Directory[2]/Item:DataURI :: android/original_image
Device:Container/Container:Directory[2]/rdf:type :: http://ns.google.com/photos/dd/1.0/container/:Item
Device:Container/Container:Directory[3] ::
Device:Container/Container:Directory[3]/Item:Mime :: image/jpeg
Device:Container/Container:Directory[3]/Item:Length :: 316885
Device:Container/Container:Directory[3]/Item:DataURI :: android/depthmap
Device:Container/Container:Directory[3]/rdf:type :: http://ns.google.com/photos/dd/1.0/container/:Item
Device:Container/Container:Directory[4] ::
Device:Container/Container:Directory[4]/Item:Mime :: image/jpeg
Device:Container/Container:Directory[4]/Item:Length :: 65189
Device:Container/Container:Directory[4]/Item:DataURI :: android/confidencemap
Device:Container/Container:Directory[4]/rdf:type :: http://ns.google.com/photos/dd/1.0/container/:Item
Device:Profiles ::
Device:Profiles[1] ::
Device:Profiles[1]/Profile:Type :: DepthPhoto
Device:Profiles[1]/Profile:CameraIndices ::
Device:Profiles[1]/Profile:CameraIndices[1] :: 0
Device:Profiles[1]/rdf:type :: http://ns.google.com/photos/dd/1.0/device/:Profile
Device:Cameras ::
Device:Cameras[1] ::
Device:Cameras[1]/Camera:Trait :: Physical
Device:Cameras[1]/Camera:Image ::
Device:Cameras[1]/Camera:Image/Image:ItemSemantic :: Original
Device:Cameras[1]/Camera:Image/Image:ItemURI :: android/original_image
Device:Cameras[1]/Camera:DepthMap ::
Device:Cameras[1]/Camera:DepthMap/DepthMap:ItemSemantic :: Depth
Device:Cameras[1]/Camera:DepthMap/DepthMap:Format :: RangeInverse
Device:Cameras[1]/Camera:DepthMap/DepthMap:Units :: Diopters
Device:Cameras[1]/Camera:DepthMap/DepthMap:Near :: 0.302570
Device:Cameras[1]/Camera:DepthMap/DepthMap:Far :: 1.754560
Device:Cameras[1]/Camera:DepthMap/DepthMap:DepthURI :: android/depthmap
Device:Cameras[1]/Camera:DepthMap/DepthMap:MeasureType :: OpticalAxis
Device:Cameras[1]/Camera:DepthMap/DepthMap:ConfidenceURI :: android/confidencemap
Device:Cameras[1]/Camera:DepthMap/DepthMap:FocalTableEntryCount :: 256
Device:Cameras[1]/Camera:DepthMap/DepthMap:FocalTable :: heqaPgAAsEGla5s+AACwQZztmz4AALBBbnCcPgAAsEEb9Jw+AACwQah4nT4AALBBFP6dPgAAsEFkhJ4+AACwQZkLnz4AALBBtZOfPsfjrkG7HKA+Xd2sQa2moD7z1qpBjTGhPonQqEFfvaE+H8qmQSNKoj61w6RB3teiPku9okGRZqM+4bagQT/2oz53sJ5B64akPg2qnEGWGKU+o6OaQUSrpT45nZhB+T6mPs+WlkG106Y+ZZCUQX1ppz76iZJBUgCoPpCDkEE4mKg+Jn2OQTIxqT68doxBQsupPlJwikFtZqo+6GmIQbMCqz5+Y4ZBGaCrPhRdhEGiPqw+qlaCQVHerD5AUIBBKX+tPqyTfEEuIa4+2IZ4QWLErj4DenRByWivPi9tcEFnDrA+W2BsQT61sD6HU2hBVF2xPrNGZEGqBrI+3zlgQUSxsj4LLVxBJ12zPjcgWEFVCrQ+YhNUQdS4tD6OBlBBpmi1Prr5S0HPGbY+5uxHQVTMtj4S4ENBOIC3Pj7TP0F/Nbg+asY7QS7suD6WuTdBSaS5PsGsM0HTXbo+7Z8vQdMYuz4ZkytBStW7PkWGJ0E/k7w+cXkjQbZSvT6dbB9BsxO+PslfG0E61r4+9VIXQVOavz4gRhNB/1/APkw5D0FGJ8E+eCwLQSrwwT6kHwdBs7rCPtASA0HjhsM++Av+QMJUxD5P8vVAVCTFPqfY7UCf9cU+/77lQKjIxj5Xpd1AdZ3HPq6L1UALdMg+BnLNQHFMyT5eWMVArCbKPrY+vUDCAss+DSW1QLrgyz5lC61AmcDMPr3xpEBmos0+FdicQCeGzj5svpRA4mvPPsSkjECfU9A+HIuEQGQ90T7n4nhANynSPpevaEAiF9M+RnxYQCgH1D72SEhAU/nUPqUVOECr7dU+VeInQDTk1j4ErxdA+dzXP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AgHurRj8AAACAYVZIPwAAAICACEo/AAAAgAjCSz8AAACALoNNPwAAAIAeTE8/AAAAgA8dUT8AAACAPPZSP3YmPL7W11Q/IaQwvx3CVj9TH5m/SrVYP5Xs2b+bsVo/61wNwFe3XD+Mwy3AucZePy0qTsAM4GA/zpBuwJoDYz+4e4fAqjFlPwivl8CPamc/WeKnwJSuaT+pFbjAEv5rP/pIyMBjWW4/SnzYwN3AcD+br+jA4jRzP+vi+MDYtXU/HosEwSFEeD/GpAzBK+B6P26+FMFpin0/F9gcwaUhgD+/8STBqIWBP2cLLcF58YI/DyU1wV1lhD+4Pj3BmuGFP2BYRcF3Zoc/CHJNwUD0iD+wi1XBSIuKP1mlXcHdK4w/Ab9lwVzWjT+p2G3BG4uPP1HydcF8SpE/+gt+wecUkz/REoPBweqUP6Ufh8F6zJY/eSyLwYq6mD9NOY/BZrWaPyFGk8GUvZw/9lKXwZzTnj/KX5vBCvigP55sn8F6K6M/cnmjwYZupT9GhqfB2sGnPxqTq8ErJqo/7p+vwS6crD/CrLPBsCSvP5e5t8GHwLE/a8a7wY1wtD8/07/BtjW3PxPgw8H4ELo/5+zHwWUDvT+7+cvBHQ7AP48G0MFLMsM/YxPUwThxxj84INjBQ8zJPwwt3MHXRM0/4DngwYnc0D+0RuTB+5TUP4hT6MH5b9g/XGDswXNv3D8wbfDBbZXgPwR69ME
Device:Cameras[1]/Camera:ImagingModel ::
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:FocalLengthX :: 3187.589355
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:FocalLengthY :: 3187.589355
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:ImageWidth :: 4032
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:ImageHeight :: 3024
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:PrincipalPointX :: 2000.483154
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:PrincipalPointY :: 1541.417236
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:Skew :: 0.000000
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:PixelAspectRatio :: 1.000000
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:DistortionCount :: 4
Device:Cameras[1]/Camera:ImagingModel/ImagingModel:Distortion :: AACAPwAAAABBQ7w9AAAAAEgGf74AAAAA5SpFPgAAAAA
Device:Cameras[1]/rdf:type :: http://ns.google.com/photos/dd/1.0/device/:Camera
根据 Google 的文档,深度图图像被序列化为 base64 字符串 XMP 属性。但我不知道如何提取它以生成基于此深度数据的新图像。我认为我几乎解决了我的问题,但我错过了一些关于 Adobe XMP 标准的确认。
我发现了一个叫做“sidecar Xmp 文件”的东西,也许我试图找到的深度图就在其中。
我上传到https://www.photopea.com上,成功看到深度图嵌入了照片
最佳答案
像素手机人像模式照片由4个JFIF结构拼接https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format .每个 JFIF 结构都是一个 jpeg 图像。
JFIF 结构以标记 0xFFD8 开始,以标记 0xFFD9 结束。因此,我们可以将一个人像模式图像拆分为 4 个 jpeg 文件。
以下 python 代码打印标记位置并将 PXL_20210107_114027740.PORTRAIT.jpg 拆分为,
with open('PXL_20210107_114027740.PORTRAIT.jpg', mode='rb') as infile:
buffer = infile.read()
bufferlen = len(buffer)
pos = 0
pos_d8 = 0
n = 0
i = 0
while i < bufferlen:
if buffer[i] == 0xff:
pos = i
i += 1
if buffer[i] == 0xd8:
print('ffd8: {0}'.format(pos))
pos_d8 = pos
elif buffer[i] == 0xd9:
print('ffd9: {0} len: {1}'.format(pos, pos - pos_d8 + 2))
with open('pxl_out_{0}.jpg'.format(n), mode='wb') as outfile:
n += 1
outfile.write(buffer[pos_d8: pos + 2])
i += 1
关于Android Q - 从人像模式照片中获取深度图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58957619/
我正在使用python 2.7 当我尝试在其上运行epsilon操作时出现此错误, 这是我的代码 import cv2 import numpy as np img = cv2.imread('img
1 很多程序员对互联网行业中广泛讨论的“35岁危机”表示不满,似乎所有的程序员都有着35岁的职业保质期。然而,随着AI技术的兴起,这场翻天覆地的技术革命正以更加残酷且直接的方式渗透到各行各业。程序员
我有一个包含多个子模块的项目,我想列出每个子模块的相对深度 该项目: main_project submodule1 submodule1\submodule1_1 submo
我有一张彩色图像及其深度图,它们都是由 Kinect 捕获的。我想将它投影到另一个位置(以查看它在另一个视角下的样子)。由于我没有 Kinect 的内在参数(相机参数);我该如何实现? P.S:我正在
给出了这三个网址: 1) https://example.com 2) https://example.com/app 3) https://example.com/app?param=hello 假
这个着色器(最后的代码)使用 raymarching 来渲染程序几何: 但是,在图像(上图)中,背景中的立方体应该部分遮挡粉红色实体;不是因为这个: struct fragmentOutput {
我希望能够在 ThreeJS 中创建一个房间。这是我到目前为止所拥有的: http://jsfiddle.net/7oyq4yqz/ var camera, scene, renderer, geom
我正在尝试通过编写小程序来学习 Haskell...所以我目前正在为简单表达式编写一个词法分析器/解析器。 (是的,我可以使用 Alex/Happy...但我想先学习核心语言)。 我的解析器本质上是一
我想使用像 [parse_ini_file][1] 这样的东西。 例如,我有一个 boot.ini 文件,我将加载该文件以进行进一步的处理: ;database connection sett
我正在使用 Mockito 来测试我的类(class)。我正在尝试使用深度 stub ,因为我没有办法在 Mockito 中的另一个模拟对象中注入(inject) Mock。 class MyServ
我试图在调整设备屏幕大小时重新排列布局,所以我这样做: if(screenOrientation == SCREEN_ORIENTATION_LANDSCAPE) { document
我正在 Ubuntu 上编写一个简单的 OpenGL 程序,它使用顶点数组绘制两个正方形(一个在另一个前面)。由于某种原因,GL_DEPTH_TEST 似乎不起作用。后面的物体出现在前面的物体前面
static FAST_FUNC int fileAction(const char *pathname, struct stat *sb UNUSED_PARAM, void *mo
我有这样的层次结构: namespace MyService{ class IBase { public: virtual ~IBase(){} protected: IPointer
我正在制作一个图片库,需要一些循环类别方面的帮助。下一个深度是图库配置文件中的已知设置,因此这不是关于无限深度循环的问题,而是循环已知深度并输出所有结果的最有效方法。 本质上,我想创建一个 包含系统中
如何以编程方式在树状结构上获取 n 深度迭代器?在根目录中我有 List 每个节点有 Map> n+1 深度。 我已修复 1 个深度: // DEPTH 1 nodeData.forEach(base
我正在构建一个包含大量自定义元素的 Polymer 单页界面。 现在我希望我的元素具有某种主样式,我可以在 index.html 或我的主要内容元素中定义它。可以这样想: index.html
我正在尝试每 25 秒连接到配对的蓝牙设备,通过 AlarmManager 安排,它会触发 WakefulBroadcastReceiver 以启动服务以进行连接。设备进入休眠状态后,前几个小时一切正
假设有一个有默认值的函数: int foo(int x=42); 如果这被其他人这样调用: int bar(int x=42) { return foo(x); } int moo(int x=42)
是否可以使用 Javascript 获取 url 深度(级别)? 如果我有这个网址:www.website.com/site/product/category/item -> depth=4www.w
我是一名优秀的程序员,十分优秀!