Skip to content

Commit

Permalink
Minor fix in RelocalizerStereo
Browse files Browse the repository at this point in the history
Summary:
There is no guarantee that the function pointer `imageFeaturePointDetectorFunction_` returns `false` when no features have been detected.  For an example, see

https://www.internalfb.com/code/fbsource/[970f113ed98c]/xplat/ocean/impl/metaonly/application/ocean/xrplayground/common/experiences/mrroomplan/MRRoomPlanPhoneExperience.cpp?lines=525

The function [`Tracking::MapBuilding::Relocalizer::detectFreakFeatures()`](https://www.internalfb.com/code/fbsource/[970f113ed98c926ea0e815d8763172e587154465]/xplat/ocean/impl/ocean/tracking/mapbuilding/Relocalizer.cpp?lines=52%2C96) will return `true` even when no features have been detected. This can trigger [`asserts`](https://www.internalfb.com/code/fbsource/[970f113ed98c]/xplat/ocean/impl/ocean/tracking/mapbuilding/RelocalizerStereo.cpp?lines=71-72).

This change add an explicit check if features were found.

Reviewed By: janherling

Differential Revision:
D64793617

Privacy Context Container: L1191897

fbshipit-source-id: 155638f761fb8b832be2bb9c846a34c758abef70
  • Loading branch information
enpe authored and facebook-github-bot committed Oct 23, 2024
1 parent 8f9ae7a commit c8e82cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions impl/ocean/tracking/mapbuilding/RelocalizerStereo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool RelocalizerStereo::relocalize(const AnyCamera& cameraA, const AnyCamera& ca
SharedUnifiedDescriptors imagePointDescriptorsA;

ocean_assert(imageFeaturePointDetectorFunction_);
if (!imageFeaturePointDetectorFunction_(cameraA, yFrameA, imagePointsA, imagePointDescriptorsA))
if (!imageFeaturePointDetectorFunction_(cameraA, yFrameA, imagePointsA, imagePointDescriptorsA) || imagePointsA.empty())
{
return false;
}
Expand All @@ -63,7 +63,7 @@ bool RelocalizerStereo::relocalize(const AnyCamera& cameraA, const AnyCamera& ca
SharedUnifiedDescriptors imagePointDescriptorsB;

ocean_assert(imageFeaturePointDetectorFunction_);
if (!imageFeaturePointDetectorFunction_(cameraB, yFrameB, imagePointsB, imagePointDescriptorsB))
if (!imageFeaturePointDetectorFunction_(cameraB, yFrameB, imagePointsB, imagePointDescriptorsB) || imagePointsB.empty())
{
return false;
}
Expand Down

0 comments on commit c8e82cc

Please sign in to comment.