From 69017381af8d647b14242320e3a2c208c2b42d8f Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Wed, 24 May 2023 19:57:38 +0530 Subject: [PATCH] Updated MPPObjectDetectorResult Helpers to return empty result instead of nil --- .../utils/sources/MPPObjectDetectorResult+Helpers.mm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mediapipe/tasks/ios/vision/object_detector/utils/sources/MPPObjectDetectorResult+Helpers.mm b/mediapipe/tasks/ios/vision/object_detector/utils/sources/MPPObjectDetectorResult+Helpers.mm index b2f9cfc08..3a8a72f71 100644 --- a/mediapipe/tasks/ios/vision/object_detector/utils/sources/MPPObjectDetectorResult+Helpers.mm +++ b/mediapipe/tasks/ios/vision/object_detector/utils/sources/MPPObjectDetectorResult+Helpers.mm @@ -25,8 +25,12 @@ using ::mediapipe::Packet; + (nullable MPPObjectDetectorResult *)objectDetectorResultWithDetectionsPacket: (const Packet &)packet { + + NSInteger timestampInMilliseconds = (NSInteger)(packet.Timestamp().Value() / + kMicroSecondsPerMilliSecond); if (!packet.ValidateAsType>().ok()) { - return nil; + return [[MPPObjectDetectorResult alloc] initWithDetections:@[] + timestampInMilliseconds:timestampInMilliseconds]; } const std::vector &detectionProtos = packet.Get>(); @@ -39,8 +43,7 @@ using ::mediapipe::Packet; return [[MPPObjectDetectorResult alloc] initWithDetections:detections - timestampInMilliseconds:(NSInteger)(packet.Timestamp().Value() / - kMicroSecondsPerMilliSecond)]; + timestampInMilliseconds:timestampInMilliseconds]; } @end