Convert ARDepthData to AVDepthData with float32 or depth32 disparity

70 views Asked by At

I want to create a 3D model with Photogrammetry Session. It's working fine with AVCaptureSession with Depth Data. But I want to capture a series of frames from ARKit and sceneDepth which is of type ARDepthMap.

DepthData is being stored as .tiff but I'm still getting the error:

"No Auxiliary Depth Data found" 

while running the photogrammetry session.

if let depthData = self.arView?.session.currentFrame?.sceneDepth?.depthMap{
    if  let colorSpace = CGColorSpace(name: CGColorSpace.linearGray) {
        let depthImage = CIImage(cvImageBuffer: depthData,
                                       options: [ .auxiliaryDisparity: true,
                                                  .auxiliaryDepth: true ] )
        depthMapData = context.tiffRepresentation(of: depthImage,
                                              format: .Lf,
                                          colorSpace: colorSpace,
                                             options: [.disparityImage: depthImage])
    }
}

if let image = self.arView?.session.currentFrame?.capturedImage {
    if let imageData = self.convertPixelBufferToHighQualityJPEG(pixelBuffer: image) {
        self.addCapture(Capture(id: photoId, 
                         photoData: imageData, 
 photoPixelBuffer: image,depthData: depthMapData))
            photoId = photoId+1
    }
}
0

There are 0 answers