Added inline function to return display name of MPPRunningMode

This commit is contained in:
Prianka Liz Kariat 2023-03-03 14:39:03 +05:30
parent f2dfa7f474
commit 412476eba1
2 changed files with 33 additions and 10 deletions

View File

@ -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

View File

@ -116,10 +116,11 @@ using ::mediapipe::tasks::core::PacketsCallback;
[MPPCommonUtils
createCustomError:error
withCode:MPPTasksErrorCodeInvalidArgumentError
description:@"Unsupported UIImageOrientation. `imageOrientation` cannot be equal to "
@"any of the mirrored orientations "
@"(`UIImageOrientationUpMirrored`,`UIImageOrientationDownMirrored`,`"
@"UIImageOrientationLeftMirrored`,`UIImageOrientationRightMirrored`)"];
description:
@"Unsupported UIImageOrientation. `imageOrientation` cannot be equal to "
@"any of the mirrored orientations "
@"(`UIImageOrientationUpMirrored`,`UIImageOrientationDownMirrored`,`"
@"UIImageOrientationLeftMirrored`,`UIImageOrientationRightMirrored`)"];
}
normalizedRect.set_rotation(-rotationDegrees * M_PI / 180.0);
@ -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;
}