Add cmake option to disable true depth APIs

This commit is contained in:
Georg Hagen
2025-02-11 12:01:37 +01:00
parent a4c6122ed6
commit a992b65c39
4 changed files with 31 additions and 3 deletions

View File

@@ -42,10 +42,12 @@ namespace OpenVulkano::AR::ArKit
{
return GetSize(arKitFrame.smoothedSceneDepth.depthMap);
}
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
if(arKitFrame.capturedDepthData)
{
return GetSize(arKitFrame.capturedDepthData.depthDataMap);
}
#endif
}
return { -1, -1 };
}
@@ -117,6 +119,7 @@ namespace OpenVulkano::AR::ArKit
m_depthImage.format = ArDepthFormat::METER_FP32;
m_depthImage.confidence.resolution = m_depthImage.depth.resolution;
}
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
else if (m_arKitFrame.capturedDepthData)
{
auto depthFormat = arKitFrame.capturedDepthData.depthDataType;
@@ -126,6 +129,7 @@ namespace OpenVulkano::AR::ArKit
depthFormat == kCVPixelFormatType_DisparityFloat16 ? "DisparityFloat16" : (depthFormat == kCVPixelFormatType_DisparityFloat32 ? "DisparityFloat32" : "Unknown"), depthFormat);
m_depthImage.confidence.resolution = { 1, 1 };
}
#endif
m_depthImage.intrinsic = frameMetadata.intrinsic.GetForResolution(m_depthImage.depth.resolution);
}
@@ -147,10 +151,12 @@ namespace OpenVulkano::AR::ArKit
CVPixelBufferUnlockBaseAddress(m_arKitFrame.smoothedSceneDepth.depthMap, kCVPixelBufferLock_ReadOnly);
CVPixelBufferUnlockBaseAddress(m_arKitFrame.smoothedSceneDepth.confidenceMap, kCVPixelBufferLock_ReadOnly);
}
else
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
else if (m_arKitFrame.capturedDepthData)
{
CVPixelBufferUnlockBaseAddress(m_arKitFrame.capturedDepthData.depthDataMap, kCVPixelBufferLock_ReadOnly);
}
#endif
}
[m_arKitFrame release];
}
@@ -201,7 +207,8 @@ namespace OpenVulkano::AR::ArKit
m_depthImage.confidence.data = CVPixelBufferGetBaseAddress(m_arKitFrame.smoothedSceneDepth.confidenceMap);
m_lockedDepth = true;
}
else if(m_arKitFrame.capturedDepthData)
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
else if (m_arKitFrame.capturedDepthData)
{
CVPixelBufferLockBaseAddress(m_arKitFrame.capturedDepthData.depthDataMap, kCVPixelBufferLock_ReadOnly);
m_depthImage.depth.data = CVPixelBufferGetBaseAddress(m_arKitFrame.capturedDepthData.depthDataMap);
@@ -209,6 +216,8 @@ namespace OpenVulkano::AR::ArKit
m_depthImage.confidence.data = &m_frameDepthQuality;
m_lockedDepth = true;
}
#endif
else Logger::AR->warn("Could not acquire depth image, because none was captured.");
}
}
return m_depthImage;

View File

@@ -32,10 +32,20 @@ namespace OpenVulkano::AR::ArKit
{
namespace
{
NSArray<ARVideoFormat*>* GetSupportedVideoFormats(bool frontCam)
{
if (!frontCam) return [ARWorldTrackingConfiguration supportedVideoFormats];
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
return [ARFaceTrackingConfiguration supportedVideoFormats];
#else
return @[];
#endif
}
std::string SupportedVideoFormatsToString(bool frontCam)
{
std::stringstream ss("[ ");
auto vidFormats = frontCam ? [ARFaceTrackingConfiguration supportedVideoFormats] : [ARWorldTrackingConfiguration supportedVideoFormats];
NSArray<ARVideoFormat*>* vidFormats = GetSupportedVideoFormats(frontCam);
for (ARVideoFormat* format: vidFormats)
{
if (ss.tellp() > std::streampos(5)) ss << ", ";
@@ -71,9 +81,13 @@ namespace OpenVulkano::AR::ArKit
m_arKitDelegate = [[ArKitDelegate alloc] initWithFrameHandler:this];
if (config.useFrontCamera)
{
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
ARFaceTrackingConfiguration* arConfig = [ARFaceTrackingConfiguration new];
arConfig.worldTrackingEnabled = true;
m_arConfig = arConfig;
#else
throw std::runtime_error("TrueDepth APIs are disabled in the current build! Enable OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH to enable front tracking experiences.");
#endif
}
else
{