diff --git a/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm b/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm index 308afadaf..14b95bed1 100644 --- a/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm +++ b/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm @@ -90,8 +90,11 @@ static NSString *const kTaskName = @"imageClassifier"; // Capturing `self` as weak in order to avoid `self` being kept in memory // and cause a retain cycle, after self is set to `nil`. MPPImageClassifier *__weak weakSelf = self; - - // Create a private serial dispatch queue in which the deleagte method will be called asynchronously. This is to ensure that if the client performs a long running operation in the delegate method, the queue on which the C++ callbacks is invoked is not blocked and is freed up to continue with its operations. + + // Create a private serial dispatch queue in which the deleagte method will be called + // asynchronously. This is to ensure that if the client performs a long running operation in + // the delegate method, the queue on which the C++ callbacks is invoked is not blocked and is + // freed up to continue with its operations. const char *queueName = [MPPVisionTaskRunner uniqueQueueNameWithTaskName:kTaskName]; dispatch_queue_t callbackQueue = dispatch_queue_create(queueName, NULL); packetsCallback = [=](absl::StatusOr status_or_packets) { @@ -108,10 +111,10 @@ static NSString *const kTaskName = @"imageClassifier"; NSError *callbackError = nil; if (![MPPCommonUtils checkCppError:status_or_packets.status() toError:&callbackError]) { dispatch_async(callbackQueue, ^{ - [weakSelf.imageClassifierDelegate imageClassifier:weakSelf - didFinishClassificationWithResult:nil - timestampInMilliseconds:Timestamp::Unset().Value() - error:callbackError]; + [weakSelf.imageClassifierDelegate imageClassifier:weakSelf + didFinishClassificationWithResult:nil + timestampInMilliseconds:Timestamp::Unset().Value() + error:callbackError]; }); return; } @@ -123,17 +126,16 @@ static NSString *const kTaskName = @"imageClassifier"; MPPImageClassifierResult *result = [MPPImageClassifierResult imageClassifierResultWithClassificationsPacket: - outputPacketMap[kClassificationsStreamName.cppString]]; + outputPacketMap[kClassificationsStreamName.cppString]]; - NSInteger timeStampInMilliseconds = outputPacketMap[kImageOutStreamName.cppString] - .Timestamp() - .Value() / - kMicroSecondsPerMilliSecond; + NSInteger timeStampInMilliseconds = + outputPacketMap[kImageOutStreamName.cppString].Timestamp().Value() / + kMicroSecondsPerMilliSecond; dispatch_async(callbackQueue, ^{ - [weakSelf.imageClassifierDelegate imageClassifier:weakSelf - didFinishClassificationWithResult:result - timestampInMilliseconds:timeStampInMilliseconds - error:callbackError]; + [weakSelf.imageClassifierDelegate imageClassifier:weakSelf + didFinishClassificationWithResult:result + timestampInMilliseconds:timeStampInMilliseconds + error:callbackError]; }); }; } diff --git a/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifierOptions.h b/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifierOptions.h index bbddd24eb..84f6ff07b 100644 --- a/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifierOptions.h +++ b/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifierOptions.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN /** * This protocol defines an interface for the delegates of `MPPImageClassifier` object to receive - * results of asynchronous classification of images + * results of asynchronous classification of images * (i.e, when `runningMode = MPPRunningModeLiveStream`). * * The delegate of `MPPImageClassifier` must adopt `MPPImageClassifierDelegate` protocol. @@ -37,12 +37,12 @@ NS_SWIFT_NAME(ImageClassifierDelegate) /** * This method notifies a delegate that the results of asynchronous classification of * an image submitted to the `MPPImageClassifier` is available. - * + * * This method is called on a private serial queue created by the `MPPImageClassifier` * for performing the asynchronous delegates calls. * * @param imageClassifier The image classifier which performed the classification. - * This is useful to test equality when there are multiple instances of `MPPImageClassifier`. + * This is useful to test equality when there are multiple instances of `MPPImageClassifier`. * @param result An `MPPImageClassifierResult` object that contains a list of image classifications. * @param timestampInMilliseconds The timestamp (in milliseconds) which indicates when the input * image was sent to the image classifier.