【问题标题】:Get media with AVDepthData without an iPhone 7+在没有 iPhone 7+ 的情况下使用 AVDepthData 获取媒体
【发布时间】:2017-12-02 06:13:29
【问题描述】:

在不拥有 iPhone 7+ 的情况下为 AVDepthData 构建应用程序的最佳方式是什么?

深度数据只能在配备双镜头摄像头的 iPhone 7+ 上采集。但我猜任何 iOS11 设备都可以处理深度数据,前提是它可以访问包含它的照片。我在网上找不到来自 Apple 或其他方的任何此类媒体资源。有人有吗?还是有更好的办法?

我尝试查看 iPhone 7+ 模拟器库,但模拟器崩溃了,因为它不支持深度演示应用正在使用的 Metal。

【问题讨论】:

    标签: image depth ios11 iphone7plus


    【解决方案1】:

    我猜你可以在任何 iOS 设备上处理照片的深度数据。您所需要的只是 iPhone 7+ 拍摄的照片样本。 Here 是其中的几个。

    【讨论】:

    • 这篇文章来自2016年即iOS10,所以我怀疑导出的照片中已经存在深度数据。但我会确认
    • 你找到什么了吗,@Guig?
    【解决方案2】:

    你需要有人(比如我)拥有 iPhone 7+ 和 iOS 11 来向你发送图片。

    在 iOS 11 上使用 Safari 访问此链接并点击 more... -> Save Image

    http://hellocamera.co/img/depth-photo.heic

    注意:我从这张图片中删除了 gps 数据。

    【讨论】:

      【解决方案3】:

      虽然是一项不平凡的任务,但可以生成 AVDepthData 并将其添加到您自己的图像中。

      1. 创建一个深度/差异字典,如 CGImageSource.h CGImageSourceCopyAuxiliaryDataInfoAtIndex 中记录的那样 - 但是,以下是更多详细信息:

      Key kCGImageAuxiliaryDataInfoData - (CFDataRef) - 深度数据

      仅包含一个二进制像素缓冲区。因为它是通过读取 CVPixelBufferLockBaseAddress 中的指针从像素缓冲区中提取的数据。您使用一种受支持类型的格式创建 CVPixelBuffer:

      • kCVPixelFormatType_DisparityFloat16 = 'hdis', /* IEEE754-2008 binary16(半浮点),描述比较两个图像时的标准化偏移。单位为 1/米:( pixelShift / (pixelFocalLength * baselineInMeters) ) */
      • kCVPixelFormatType_DisparityFloat32 = 'fdis', /* IEEE754-2008 binary32 float,描述比较两个图像时的归一化偏移。单位为 1/米:( pixelShift / (pixelFocalLength * baselineInMeters) ) */
      • kCVPixelFormatType_DepthFloat16 = 'hdep', /* IEEE754-2008 binary16(半浮点),以米为单位描述深度(到对象的距离)*/
      • kCVPixelFormatType_DepthFloat32 = 'fdep', /* IEEE754-2008 binary32 float,以米为单位描述深度(到对象的距离)*/

      要将任意灰度图像转换为假深度缓冲区,您需要按像素将灰度像素值(0=黑色到 1=白色,zNear 到 zFar 等)转换为米或 1 /meters 取决于您的目标格式。并将它们转换为正确的浮点格式,具体取决于您从何处获取它们。

      keykCGImageAuxiliaryDataInfoDataDescription - (CFDictionary) - 深度数据描述

      告诉您如何解释我们给您的缓冲区,或告诉我们如何解释您给我们的缓冲区:

      • kCGImagePropertyPixelFormat 是 CoreVideo/CVPixelBuffer.h 深度/视差格式之一
      • kCGImagePropertyWidth/Height 是像素尺寸
      • kCGImagePropertyBytesPerRow 是正确的,它在锡上说的是正确的

      密钥kCGImageAuxiliaryDataInfoMetadata - (CGImageMetadataRef) - 元数据

      这个值是可选的。

      1. 使用init(fromDictionaryRepresentation: [AnyHashable : Any]) 传递上面创建的字典创建 AVDepthData。
      2. 使用 ImageI/O 创建图像:

        // create the image destination (not shown)
        
        // add an image to the destination
        CGImageDestinationAddImage(cgImageDestination, renderedCGImage, attachments)  
        
        // Use AVDepthData to get auxiliary data dictionary          
        

        var auxDataType :NSString?

        让 auxData = depthData.dictionaryRepresentation(forAuxiliaryDataType: &auxDataType)  

        // Add auxiliary data to image destination  
        CGImageDestinationAddAuxiliaryDataInfo(cgImageDestination, auxDataType!, auxData! as CFDictionary)  
        
        if CGImageDestinationFinalize(cgImageDestination) {  
            return data as Data  
        }  
        

      【讨论】:

      猜你喜欢
      • 2012-09-02
      • 2012-12-04
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多