标签: avdepthdata

iOS 12 上的过滤深度数据似乎发生了旋转

我遇到一个问题,.builtInDualCameraisFilteringEnabled = true

这是我的代码:

fileprivate let session = AVCaptureSession()

fileprivate let meta = AVCaptureMetadataOutput()
fileprivate let video = AVCaptureVideoDataOutput()
fileprivate let depth = AVCaptureDepthDataOutput()

fileprivate let camera: AVCaptureDevice
fileprivate let input: AVCaptureDeviceInput

fileprivate let synchronizer: AVCaptureDataOutputSynchronizer

init(delegate: CaptureSessionDelegate?) throws {
    self.delegate = delegate
    session.sessionPreset = .vga640x480

    // Setup Camera Input
    let discovery = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera], mediaType: .video, position: .unspecified)
    if let device = discovery.devices.first {
        camera = device
    } else {
        throw SessionError.CameraNotAvailable("Unable to load camera")
    } …
Run Code Online (Sandbox Code Playgroud)

ios avcapturesession swift ios12 avdepthdata

5
推荐指数
1
解决办法
817
查看次数

AVDepthData 的深度图与 Photoshop 中的 HEIC 文件深度数据不同

我使用以下代码来提取深度图(按照苹果自己的示例):

- (nullable AVDepthData *)depthDataFromImageData:(nonnull NSData *)imageData orientation:(CGImagePropertyOrientation)orientation {
    AVDepthData *depthData = nil;

    CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)imageData, NULL);
    if (imageSource) {
        NSDictionary *auxDataDictionary = (__bridge NSDictionary *)CGImageSourceCopyAuxiliaryDataInfoAtIndex(imageSource, 0, kCGImageAuxiliaryDataTypeDisparity);
        if (auxDataDictionary) {
            depthData = [[AVDepthData depthDataFromDictionaryRepresentation:auxDataDictionary error:NULL] depthDataByApplyingExifOrientation:orientation];
        }

        CFRelease(imageSource);
    }

    return depthData;
}
Run Code Online (Sandbox Code Playgroud)

我将此称为:

[[PHAssetResourceManager defaultManager] requestDataForAssetResource:[PHAssetResource assetResourcesForAsset:asset].firstObject options:nil dataReceivedHandler:^(NSData * _Nonnull data) {
    AVDepthData *depthData = [self depthDataFromImageData:data orientation:[self CGImagePropertyOrientationForUIImageOrientation:pickedUiImageOrientation]];
    CIImage *image = [CIImage imageWithDepthData:depthData];
    UIImage *uiImage = [UIImage imageWithCIImage:image];
    UIGraphicsBeginImageContext(uiImage.size);
    [uiImage drawInRect:CGRectMake(0, 0, uiImage.size.width, uiImage.size.height)];
    UIImage *newImage …
Run Code Online (Sandbox Code Playgroud)

image-processing ios ios12 avdepthdata

4
推荐指数
1
解决办法
1929
查看次数