Updated formatting

This commit is contained in:
Prianka Liz Kariat 2023-05-04 01:02:47 +05:30
parent 4401b11c3a
commit 37e14a7cad
2 changed files with 21 additions and 21 deletions

View File

@ -86,7 +86,8 @@ static NSString *const kTaskName = @"objectDetector";
// Capturing `self` as weak in order to avoid `self` being kept in memory // Capturing `self` as weak in order to avoid `self` being kept in memory
// and cause a retain cycle, after self is set to `nil`. // and cause a retain cycle, after self is set to `nil`.
MPPObjectDetector *__weak weakSelf = self; MPPObjectDetector *__weak weakSelf = self;
dispatch_queue_t callbackQueue = dispatch_queue_create([MPPVisionTaskRunner uniqueQueueNameWithTaskName:kTaskName], NULL); dispatch_queue_t callbackQueue =
dispatch_queue_create([MPPVisionTaskRunner uniqueQueueNameWithTaskName:kTaskName], NULL);
packetsCallback = [=](absl::StatusOr<PacketMap> statusOrPackets) { packetsCallback = [=](absl::StatusOr<PacketMap> statusOrPackets) {
if (!weakSelf) { if (!weakSelf) {
return; return;
@ -101,9 +102,9 @@ static NSString *const kTaskName = @"objectDetector";
if (![MPPCommonUtils checkCppError:statusOrPackets.status() toError:&callbackError]) { if (![MPPCommonUtils checkCppError:statusOrPackets.status() toError:&callbackError]) {
dispatch_async(callbackQueue, ^{ dispatch_async(callbackQueue, ^{
[weakSelf.objectDetectorDelegate objectDetector:weakSelf [weakSelf.objectDetectorDelegate objectDetector:weakSelf
didFinishDetectionWithResult:nil didFinishDetectionWithResult:nil
timestampInMilliseconds:Timestamp::Unset().Value() timestampInMilliseconds:Timestamp::Unset().Value()
error:callbackError]; error:callbackError];
}); });
return; return;
} }
@ -116,17 +117,15 @@ static NSString *const kTaskName = @"objectDetector";
MPPObjectDetectionResult *result = [MPPObjectDetectionResult MPPObjectDetectionResult *result = [MPPObjectDetectionResult
objectDetectionResultWithDetectionsPacket:statusOrPackets.value()[kDetectionsStreamName objectDetectionResultWithDetectionsPacket:statusOrPackets.value()[kDetectionsStreamName
.cppString]]; .cppString]];
NSInteger timeStampInMilliseconds = outputPacketMap[kImageOutStreamName.cppString] NSInteger timeStampInMilliseconds =
.Timestamp() outputPacketMap[kImageOutStreamName.cppString].Timestamp().Value() /
.Value() / kMicroSecondsPerMilliSecond;
kMicroSecondsPerMilliSecond;
dispatch_async(callbackQueue, ^{ dispatch_async(callbackQueue, ^{
[weakSelf.objectDetectorDelegate [weakSelf.objectDetectorDelegate objectDetector:weakSelf
objectDetector:weakSelf didFinishDetectionWithResult:result
didFinishDetectionWithResult:result timestampInMilliseconds:timeStampInMilliseconds
timestampInMilliseconds:timeStampInMilliseconds error:callbackError];
error:callbackError];
}); });
}; };
} }

View File

@ -38,19 +38,20 @@ NS_SWIFT_NAME(ObjectDetectorDelegate)
/** /**
* This method notifies a delegate that the results of asynchronous object detection of * This method notifies a delegate that the results of asynchronous object detection of
* an image submitted to the `MPPObjectDetector` is available. * an image submitted to the `MPPObjectDetector` is available.
* *
* This method is called on a private serial dispatch queue created by the `MPPObjectDetector` * This method is called on a private serial dispatch queue created by the `MPPObjectDetector`
* for performing the asynchronous delegates calls. * for performing the asynchronous delegates calls.
* *
* @param objectDetector The object detector which performed the object detection. * @param objectDetector The object detector which performed the object detection.
* This is useful to test equality when there are multiple instances of `MPPObjectDetector`. * This is useful to test equality when there are multiple instances of `MPPObjectDetector`.
* @param result The `MPPObjectDetectionResult` object that contains a list of detections, each detection * @param result The `MPPObjectDetectionResult` object that contains a list of detections, each
* has a bounding box that is expressed in the unrotated input frame of reference coordinates * detection has a bounding box that is expressed in the unrotated input frame of reference
* system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the underlying * coordinates system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the
* image data. * underlying image data.
* @param timestampInMilliseconds The timestamp (in milliseconds) which indicates when the input * @param timestampInMilliseconds The timestamp (in milliseconds) which indicates when the input
* image was sent to the object detector. * image was sent to the object detector.
* @param error An optional error parameter populated when there is an error in performing object detection on the input live stream image data. * @param error An optional error parameter populated when there is an error in performing object
* detection on the input live stream image data.
* *
*/ */
- (void)objectDetector:(MPPObjectDetector *)objectDetector - (void)objectDetector:(MPPObjectDetector *)objectDetector