Skip to content

Commit

Permalink
Fixed multi-tracker behavior in Devices::ARKit
Browse files Browse the repository at this point in the history
Summary:
The capabilities logic contained a bug when re-starting/using too many different trackers.

This diff fixes the behavior and ensures that every tracker has access to the necessary capabilities (if possible).

Reviewed By: enpe

Differential Revision: D65555556

fbshipit-source-id: aba01d131fd008c3b2612764dc60f9abcef20213
  • Loading branch information
janherling authored and facebook-github-bot committed Nov 6, 2024
1 parent 9ffe4a4 commit 43ffe4d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions impl/ocean/devices/arkit/AKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ - (bool)restart:(AKDevice*)device withMedium:(const Media::LiveVideoRef&)inputLi
return false;
}

#ifdef OCEAN_DEBUG
const ScopedLock scopedLock(lock_);

AKDevice::TrackerCapabilities necessaryTrackerCapabilities = device->trackerCapabilities();

for (AKDevice::DeviceMap::const_iterator iDevice = deviceMap_.cbegin(); iDevice != deviceMap_.cend(); ++iDevice)
{
ocean_assert(iDevice->first == device || iDevice->first->name() != device->name());
}
#endif

const AKDevice::TrackerCapabilities necessaryTrackerCapabilities = device->trackerCapabilities();

const ScopedLock scopedLock(lock_);
necessaryTrackerCapabilities = AKDevice::TrackerCapabilities(necessaryTrackerCapabilities | iDevice->first->trackerCapabilities());
}

if (inputLiveVideo_ && &*inputLiveVideo_ != &*inputLiveVideo)
{
Expand Down Expand Up @@ -265,7 +265,11 @@ - (bool)restart:(AKDevice*)device withMedium:(const Media::LiveVideoRef&)inputLi
}
}

if (!sceneReconstructionActivated)
if (sceneReconstructionActivated)
{
trackerCapabilities_ = Devices::ARKit::AKDevice::TrackerCapabilities(trackerCapabilities_ | Devices::ARKit::AKDevice::TC_MESH_RECONSTRUCTION);
}
else
{
Log::warning() << "The devices does not support ARKit's scene reconstruction";
}
Expand All @@ -278,6 +282,8 @@ - (bool)restart:(AKDevice*)device withMedium:(const Media::LiveVideoRef&)inputLi
if ([ARWorldTrackingConfiguration supportsFrameSemantics:ARFrameSemanticSceneDepth])
{
arWorldTrackingConfiguration.frameSemantics = ARFrameSemanticSceneDepth;

trackerCapabilities_ = Devices::ARKit::AKDevice::TrackerCapabilities(trackerCapabilities_ | Devices::ARKit::AKDevice::TC_DEPTH);
}
}
}
Expand All @@ -289,6 +295,8 @@ - (bool)restart:(AKDevice*)device withMedium:(const Media::LiveVideoRef&)inputLi
if (ARWorldTrackingConfiguration.supportsUserFaceTracking)
{
arWorldTrackingConfiguration.userFaceTrackingEnabled = true;

trackerCapabilities_ = Devices::ARKit::AKDevice::TrackerCapabilities(trackerCapabilities_ | Devices::ARKit::AKDevice::TC_FACE);
}
else
{
Expand Down Expand Up @@ -331,6 +339,8 @@ - (bool)restart:(AKDevice*)device withMedium:(const Media::LiveVideoRef&)inputLi
}
}

trackerCapabilities_ = Devices::ARKit::AKDevice::TrackerCapabilities(trackerCapabilities_ | Devices::ARKit::AKDevice::TC_FACE);

arConfiguration_ = arFaceTrackingConfiguration;
}

Expand Down

0 comments on commit 43ffe4d

Please sign in to comment.