Updated formatting

This commit is contained in:
Prianka Liz Kariat 2023-02-14 20:39:25 +05:30
parent b940a19462
commit 17ff493a9d
3 changed files with 27 additions and 31 deletions

View File

@ -27,12 +27,12 @@ typedef NS_ENUM(NSUInteger, MPPRunningMode) {
/** The mode for running a mediapipe vision task on single image inputs. */ /** The mode for running a mediapipe vision task on single image inputs. */
MPPRunningModeImage, MPPRunningModeImage,
/**mThe mode for running a mediapipe vision task on the decoded frames of a video. */ /** The mode for running a mediapipe vision task on the decoded frames of a video. */
MPPRunningModeVideo, MPPRunningModeVideo,
/** The mode for running a mediapipe vision task on a live stream of input data, /** The mode for running a mediapipe vision task on a live stream of input data, such as from
* such as from camera. * camera.
*/ */
MPPRunningModeLiveStream, MPPRunningModeLiveStream,
} NS_SWIFT_NAME(RunningMode); } NS_SWIFT_NAME(RunningMode);

View File

@ -26,7 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface MPPVisionTaskRunner : MPPTaskRunner @interface MPPVisionTaskRunner : MPPTaskRunner
/** /**
* Initializes a new `MPPVisionTaskRunner` with the MediaPipe calculator config protol running mode and packetsCallback. * Initializes a new `MPPVisionTaskRunner` with the MediaPipe calculator config protol running mode
* and packetsCallback.
* *
* @param graphConfig A MediaPipe calculator config proto. * @param graphConfig A MediaPipe calculator config proto.
* @param runningMode MediaPipe vision task running mode. * @param runningMode MediaPipe vision task running mode.
@ -40,10 +41,10 @@ NS_ASSUME_NONNULL_BEGIN
* proto, running mode and packets callback. * proto, running mode and packets callback.
*/ */
- (nullable instancetype)initWithCalculatorGraphConfig:(mediapipe::CalculatorGraphConfig)graphConfig - (nullable instancetype)initWithCalculatorGraphConfig:(mediapipe::CalculatorGraphConfig)graphConfig
runningMode:(MPPRunningMode)runningMode runningMode:(MPPRunningMode)runningMode
packetsCallback: packetsCallback:
(mediapipe::tasks::core::PacketsCallback)packetsCallback (mediapipe::tasks::core::PacketsCallback)packetsCallback
error:(NSError **)error; error:(NSError **)error;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;

View File

@ -29,45 +29,40 @@ using ::mediapipe::CalculatorGraphConfig;
@implementation MPPVisionTaskRunner @implementation MPPVisionTaskRunner
- (nullable instancetype)initWithCalculatorGraphConfig:(mediapipe::CalculatorGraphConfig)graphConfig - (nullable instancetype)initWithCalculatorGraphConfig:(mediapipe::CalculatorGraphConfig)graphConfig
runningMode:(MPPRunningMode)runningMode runningMode:(MPPRunningMode)runningMode
packetsCallback: packetsCallback:
(mediapipe::tasks::core::PacketsCallback)packetsCallback (mediapipe::tasks::core::PacketsCallback)packetsCallback
error:(NSError **)error { error:(NSError **)error {
switch (runningMode) { switch (runningMode) {
case MPPRunningModeImage: case MPPRunningModeImage:
case MPPRunningModeVideo: { case MPPRunningModeVideo: {
if (packetsCallback) { if (packetsCallback) {
[MPPCommonUtils [MPPCommonUtils createCustomError:error
createCustomError:error withCode:MPPTasksErrorCodeInvalidArgumentError
withCode:MPPTasksErrorCodeInvalidArgumentError description:@"The vision task is in image or video mode, a "
description: @"user-defined result callback should not be provided."];
@"The vision task is in image or video mode, a user-defined result callback should not be provided."];
return nil; return nil;
} }
break; break;
} }
case MPPRunningModeLiveStream: { case MPPRunningModeLiveStream: {
if (!packetsCallback) { if (!packetsCallback) {
[MPPCommonUtils [MPPCommonUtils createCustomError:error
createCustomError:error withCode:MPPTasksErrorCodeInvalidArgumentError
withCode:MPPTasksErrorCodeInvalidArgumentError description:@"The vision task is in live stream mode, a user-defined "
description: @"result callback must be provided."];
@"The vision task is in live stream mode, a user-defined result callback must be provided."];
return nil; return nil;
} }
break; break;
} }
default: { default: {
[MPPCommonUtils [MPPCommonUtils createCustomError:error
createCustomError:error withCode:MPPTasksErrorCodeInvalidArgumentError
withCode:MPPTasksErrorCodeInvalidArgumentError description:@"Unrecognized running mode"];
description: return nil;
@"Unrecognized running mode"];
return nil;
} }
} }
_runningMode = runningMode; _runningMode = runningMode;
self = [super initWithCalculatorGraphConfig:graphConfig self = [super initWithCalculatorGraphConfig:graphConfig
packetsCallback:packetsCallback packetsCallback:packetsCallback