diff --git a/openVulkanoCpp/AR/Provider/ArKit/ArFrameArKit.mm b/openVulkanoCpp/AR/Provider/ArKit/ArFrameArKit.mm index 2c3d32d..3adfa61 100644 --- a/openVulkanoCpp/AR/Provider/ArKit/ArFrameArKit.mm +++ b/openVulkanoCpp/AR/Provider/ArKit/ArFrameArKit.mm @@ -42,6 +42,10 @@ namespace OpenVulkano::AR::ArKit { return GetSize(arKitFrame.smoothedSceneDepth.depthMap); } + if(arKitFrame.capturedDepthData) + { + return GetSize(arKitFrame.capturedDepthData.depthDataMap); + } } return { -1, -1 }; } @@ -113,6 +117,15 @@ namespace OpenVulkano::AR::ArKit m_depthImage.format = ArDepthFormat::METER_FP32; m_depthImage.confidence.resolution = m_depthImage.depth.resolution; } + else if (m_arKitFrame.capturedDepthData) + { + auto depthFormat = arKitFrame.capturedDepthData.depthDataType; + if (arKitFrame.capturedDepthData.depthDataType == kCVPixelFormatType_DepthFloat32) m_depthImage.format = ArDepthFormat::METER_FP32; + else if (arKitFrame.capturedDepthData.depthDataType == kCVPixelFormatType_DepthFloat16) m_depthImage.format = ArDepthFormat::METER_FP16; + else Logger::AR->info("Received depth frame with unsuported format: {} ({})", + depthFormat == kCVPixelFormatType_DisparityFloat16 ? "DisparityFloat16" : (depthFormat == kCVPixelFormatType_DisparityFloat32 ? "DisparityFloat32" : "Unknown"), depthFormat); + m_depthImage.confidence.resolution = { 1, 1 }; + } m_depthImage.intrinsic = frameMetadata.intrinsic.GetForResolution(m_depthImage.depth.resolution); } @@ -134,6 +147,10 @@ namespace OpenVulkano::AR::ArKit CVPixelBufferUnlockBaseAddress(m_arKitFrame.smoothedSceneDepth.depthMap, kCVPixelBufferLock_ReadOnly); CVPixelBufferUnlockBaseAddress(m_arKitFrame.smoothedSceneDepth.confidenceMap, kCVPixelBufferLock_ReadOnly); } + else + { + CVPixelBufferUnlockBaseAddress(m_arKitFrame.capturedDepthData.depthDataMap, kCVPixelBufferLock_ReadOnly); + } } [m_arKitFrame release]; } @@ -184,6 +201,14 @@ namespace OpenVulkano::AR::ArKit m_depthImage.confidence.data = CVPixelBufferGetBaseAddress(m_arKitFrame.smoothedSceneDepth.confidenceMap); m_lockedDepth = true; } + else if(m_arKitFrame.capturedDepthData) + { + CVPixelBufferLockBaseAddress(m_arKitFrame.capturedDepthData.depthDataMap, kCVPixelBufferLock_ReadOnly); + m_depthImage.depth.data = CVPixelBufferGetBaseAddress(m_arKitFrame.capturedDepthData.depthDataMap); + m_frameDepthQuality = static_cast(m_arKitFrame.capturedDepthData.depthDataQuality) + static_cast(m_arKitFrame.capturedDepthData.depthDataAccuracy); + m_depthImage.confidence.data = &m_frameDepthQuality; + m_lockedDepth = true; + } } } return m_depthImage; diff --git a/openVulkanoCpp/AR/Provider/ArKit/ArSessionArKitInternal.mm b/openVulkanoCpp/AR/Provider/ArKit/ArSessionArKitInternal.mm index 48dd3c0..df09743 100644 --- a/openVulkanoCpp/AR/Provider/ArKit/ArSessionArKitInternal.mm +++ b/openVulkanoCpp/AR/Provider/ArKit/ArSessionArKitInternal.mm @@ -35,7 +35,7 @@ namespace OpenVulkano::AR::ArKit std::string SupportedVideoFormatsToString(bool frontCam) { std::stringstream ss("[ "); - auto vidFormats = [ARWorldTrackingConfiguration supportedVideoFormats]; + auto vidFormats = frontCam ? [ARFaceTrackingConfiguration supportedVideoFormats] : [ARWorldTrackingConfiguration supportedVideoFormats]; for (ARVideoFormat* format: vidFormats) { if (ss.tellp() > std::streampos(5)) ss << ", "; @@ -69,7 +69,13 @@ namespace OpenVulkano::AR::ArKit : m_frameId(0) { m_arKitDelegate = [[ArKitDelegate alloc] initWithFrameHandler:this]; - + if (config.useFrontCamera) + { + ARFaceTrackingConfiguration* arConfig = [ARFaceTrackingConfiguration new]; + arConfig.worldTrackingEnabled = true; + m_arConfig = arConfig; + } + else { ARWorldTrackingConfiguration* arConfig = [ARWorldTrackingConfiguration new]; if (config.enableDepth)