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

@@ -48,6 +48,7 @@ option(OPENVULKANO_ENABLE_TEST "Enable testing" ON)
option(OPENVULKANO_ENABLE_EXAMPLES "Enable examples" ON) option(OPENVULKANO_ENABLE_EXAMPLES "Enable examples" ON)
option(OPENVULKANO_ENABLE_MSDF "Enable msdf library" ON) option(OPENVULKANO_ENABLE_MSDF "Enable msdf library" ON)
option(OPENVULKANO_ENABLE_SHADERC "Enable runtime shader compiler" OFF) option(OPENVULKANO_ENABLE_SHADERC "Enable runtime shader compiler" OFF)
option(OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH "Enable arkit TrueDepth (Front Depth Camera) APIs" OFF) # TrueDepth need special privacy policy treatment and must not be included in app if not used by dev
# ----------------------------------------------------------------- # -----------------------------------------------------------------
if (IOS) if (IOS)

View File

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

View File

@@ -32,10 +32,20 @@ namespace OpenVulkano::AR::ArKit
{ {
namespace 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::string SupportedVideoFormatsToString(bool frontCam)
{ {
std::stringstream ss("[ "); std::stringstream ss("[ ");
auto vidFormats = frontCam ? [ARFaceTrackingConfiguration supportedVideoFormats] : [ARWorldTrackingConfiguration supportedVideoFormats]; NSArray<ARVideoFormat*>* vidFormats = GetSupportedVideoFormats(frontCam);
for (ARVideoFormat* format: vidFormats) for (ARVideoFormat* format: vidFormats)
{ {
if (ss.tellp() > std::streampos(5)) ss << ", "; if (ss.tellp() > std::streampos(5)) ss << ", ";
@@ -71,9 +81,13 @@ namespace OpenVulkano::AR::ArKit
m_arKitDelegate = [[ArKitDelegate alloc] initWithFrameHandler:this]; m_arKitDelegate = [[ArKitDelegate alloc] initWithFrameHandler:this];
if (config.useFrontCamera) if (config.useFrontCamera)
{ {
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
ARFaceTrackingConfiguration* arConfig = [ARFaceTrackingConfiguration new]; ARFaceTrackingConfiguration* arConfig = [ARFaceTrackingConfiguration new];
arConfig.worldTrackingEnabled = true; arConfig.worldTrackingEnabled = true;
m_arConfig = arConfig; 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 else
{ {

View File

@@ -81,3 +81,7 @@ LinkMsdf(openVulkanoCpp)
SetGlmDefines(openVulkanoCpp) SetGlmDefines(openVulkanoCpp)
add_compile_definitions(LIBARCHIVE_STATIC) add_compile_definitions(LIBARCHIVE_STATIC)
add_compile_definitions("$<$<CONFIG:Debug>:DEBUG>") add_compile_definitions("$<$<CONFIG:Debug>:DEBUG>")
if (OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH)
target_compile_definitions(openVulkanoCpp PUBLIC OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH)
endif ()