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_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
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -116,10 +116,11 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
||||||
[MPPCommonUtils
|
[MPPCommonUtils
|
||||||
createCustomError:error
|
createCustomError:error
|
||||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||||
description:@"Unsupported UIImageOrientation. `imageOrientation` cannot be equal to "
|
description:
|
||||||
@"any of the mirrored orientations "
|
@"Unsupported UIImageOrientation. `imageOrientation` cannot be equal to "
|
||||||
@"(`UIImageOrientationUpMirrored`,`UIImageOrientationDownMirrored`,`"
|
@"any of the mirrored orientations "
|
||||||
@"UIImageOrientationLeftMirrored`,`UIImageOrientationRightMirrored`)"];
|
@"(`UIImageOrientationUpMirrored`,`UIImageOrientationDownMirrored`,`"
|
||||||
|
@"UIImageOrientationLeftMirrored`,`UIImageOrientationRightMirrored`)"];
|
||||||
}
|
}
|
||||||
|
|
||||||
normalizedRect.set_rotation(-rotationDegrees * M_PI / 180.0);
|
normalizedRect.set_rotation(-rotationDegrees * M_PI / 180.0);
|
||||||
|
@ -132,8 +133,9 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
||||||
[MPPCommonUtils
|
[MPPCommonUtils
|
||||||
createCustomError:error
|
createCustomError:error
|
||||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||||
description:
|
description:[NSString stringWithFormat:@"The vision task is not initialized with "
|
||||||
@"The vision task is not initialized with image mode. Current Running Mode:"];
|
@"image mode. Current Running Mode: %@",
|
||||||
|
MPPRunningModeDisplayName(_runningMode)]];
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,8 +148,9 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
||||||
[MPPCommonUtils
|
[MPPCommonUtils
|
||||||
createCustomError:error
|
createCustomError:error
|
||||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||||
description:
|
description:[NSString stringWithFormat:@"The vision task is not initialized with "
|
||||||
@"The vision task is not initialized with image mode. Current Running Mode:"];
|
@"video mode. Current Running Mode: %@",
|
||||||
|
MPPRunningModeDisplayName(_runningMode)]];
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +162,9 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
||||||
[MPPCommonUtils
|
[MPPCommonUtils
|
||||||
createCustomError:error
|
createCustomError:error
|
||||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||||
description:
|
description:[NSString stringWithFormat:@"The vision task is not initialized with "
|
||||||
@"The vision task is not initialized with image mode. Current Running Mode:"];
|
@"live stream mode. Current Running Mode: %@",
|
||||||
|
MPPRunningModeDisplayName(_runningMode)]];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user