Added inline function to return display name of MPPRunningMode
This commit is contained in:
parent
f2dfa7f474
commit
412476eba1
|
@ -38,4 +38,23 @@ typedef NS_ENUM(NSUInteger, MPPRunningMode) {
|
|||
|
||||
} NS_SWIFT_NAME(RunningMode);
|
||||
|
||||
NS_INLINE NSString *MPPRunningModeDisplayName(MPPRunningMode runningMode) {
|
||||
|
||||
if (runningMode > MPPRunningModeLiveStream) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
#define MPPRunningModeDisplayNameMap(mode) [mode] = @#mode
|
||||
|
||||
NSString *displayNameMap[MPPRunningModeLiveStream + 1] = {
|
||||
MPPRunningModeDisplayNameMap(MPPRunningModeImage),
|
||||
MPPRunningModeDisplayNameMap(MPPRunningModeVideo),
|
||||
MPPRunningModeDisplayNameMap(MPPRunningModeLiveStream),
|
||||
};
|
||||
|
||||
#undef MPPRunningModeDisplayNameMap
|
||||
|
||||
return displayNameMap[runningMode];
|
||||
}
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -116,7 +116,8 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
|||
[MPPCommonUtils
|
||||
createCustomError:error
|
||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||
description:@"Unsupported UIImageOrientation. `imageOrientation` cannot be equal to "
|
||||
description:
|
||||
@"Unsupported UIImageOrientation. `imageOrientation` cannot be equal to "
|
||||
@"any of the mirrored orientations "
|
||||
@"(`UIImageOrientationUpMirrored`,`UIImageOrientationDownMirrored`,`"
|
||||
@"UIImageOrientationLeftMirrored`,`UIImageOrientationRightMirrored`)"];
|
||||
|
@ -132,8 +133,9 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
|||
[MPPCommonUtils
|
||||
createCustomError:error
|
||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||
description:
|
||||
@"The vision task is not initialized with image mode. Current Running Mode:"];
|
||||
description:[NSString stringWithFormat:@"The vision task is not initialized with "
|
||||
@"image mode. Current Running Mode: %@",
|
||||
MPPRunningModeDisplayName(_runningMode)]];
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
@ -146,8 +148,9 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
|||
[MPPCommonUtils
|
||||
createCustomError:error
|
||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||
description:
|
||||
@"The vision task is not initialized with image mode. Current Running Mode:"];
|
||||
description:[NSString stringWithFormat:@"The vision task is not initialized with "
|
||||
@"video mode. Current Running Mode: %@",
|
||||
MPPRunningModeDisplayName(_runningMode)]];
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
@ -159,8 +162,9 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
|||
[MPPCommonUtils
|
||||
createCustomError:error
|
||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||
description:
|
||||
@"The vision task is not initialized with image mode. Current Running Mode:"];
|
||||
description:[NSString stringWithFormat:@"The vision task is not initialized with "
|
||||
@"live stream mode. Current Running Mode: %@",
|
||||
MPPRunningModeDisplayName(_runningMode)]];
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user