In some cases when I use "builtInDualCamera" capture device I get white blank depth photo. In other cases it works fine.
So I guess there is a limitation. I use this code to get depth image:
private func saveDepth(name: String, photo: AVCapturePhoto) throws -> URL {
guard var depthData = photo.depthData else {
throw CameraError.photo("No depth data")
}
print("DEBUG: depth data quality \(depthData.depthDataQuality)")
if let orientationValue = photo.metadata[kCGImagePropertyOrientation as String] as? UInt32 {
if let orientation = CGImagePropertyOrientation(rawValue: orientationValue) {
depthData = depthData.applyingExifOrientation(orientation)
}
}
let converted = depthData.converting(toDepthDataType: kCVPixelFormatType_DepthFloat32)
let image = CIImage(cvPixelBuffer: converted.depthDataMap)
guard let colorSpace = image.colorSpace else {
throw CameraError.photo("Can not get image color space")
}
guard let data = context.tiffRepresentation(
of: image,
format: .Lf,
colorSpace: colorSpace,
options: [:]
) else {
throw CameraError.photo("Can not create TIFF")
}
let url = Path.cachePath.appendingPathComponent(name + "_depth.tiff")
try data.write(to: url)
return url
}
Any information about maximum distance or some other limitations for dual camera?