Added method for creating unique dispatch queue names in MPPVisionTaskRunner
This commit is contained in:
parent
c6e3f08282
commit
a21c08bf4d
|
@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
+ (NSString *)stringWithCppString:(std::string)text;
|
+ (NSString *)stringWithCppString:(std::string)text;
|
||||||
|
|
||||||
|
+ (NSString *)uuidString;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -24,4 +24,8 @@
|
||||||
return [NSString stringWithCString:text.c_str() encoding:[NSString defaultCStringEncoding]];
|
return [NSString stringWithCString:text.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (NSString *)uuidString{
|
||||||
|
return [[NSUUID UUID] UUIDString];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -58,6 +58,7 @@ objc_library(
|
||||||
"//mediapipe/framework/formats:rect_cc_proto",
|
"//mediapipe/framework/formats:rect_cc_proto",
|
||||||
"//mediapipe/tasks/ios/common:MPPCommon",
|
"//mediapipe/tasks/ios/common:MPPCommon",
|
||||||
"//mediapipe/tasks/ios/common/utils:MPPCommonUtils",
|
"//mediapipe/tasks/ios/common/utils:MPPCommonUtils",
|
||||||
|
"//mediapipe/tasks/ios/common/utils:NSStringHelpers",
|
||||||
"//mediapipe/tasks/ios/core:MPPTaskRunner",
|
"//mediapipe/tasks/ios/core:MPPTaskRunner",
|
||||||
"//third_party/apple_frameworks:UIKit",
|
"//third_party/apple_frameworks:UIKit",
|
||||||
"@com_google_absl//absl/status:statusor",
|
"@com_google_absl//absl/status:statusor",
|
||||||
|
|
|
@ -141,6 +141,20 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
(mediapipe::tasks::core::PacketsCallback)packetsCallback
|
(mediapipe::tasks::core::PacketsCallback)packetsCallback
|
||||||
error:(NSError **)error NS_UNAVAILABLE;
|
error:(NSError **)error NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a unique dispatch queue name by adding the given suffix and a `UUID` to the
|
||||||
|
* pre-defined queue name prefix for vision tasks. The vision tasks can use this method to get
|
||||||
|
* unique dispatch queue names which are consistent with other vision tasks.
|
||||||
|
* Dispatch queue names need not be unique, but for easy debugging we ensure that the queue names
|
||||||
|
* are unique.
|
||||||
|
*
|
||||||
|
* @param suffix A suffix that identifies a dispatch queue's functionality.
|
||||||
|
*
|
||||||
|
* @return A unique dispatch queue name by adding the given suffix and a `UUID` to the pre-defined
|
||||||
|
* queue name prefix for vision tasks.
|
||||||
|
*/
|
||||||
|
+ (const char *)uniqueDispatchQueueNameWithSuffix:(NSString *)suffix;
|
||||||
|
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
+ (instancetype)new NS_UNAVAILABLE;
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#import "mediapipe/tasks/ios/common/sources/MPPCommon.h"
|
#import "mediapipe/tasks/ios/common/sources/MPPCommon.h"
|
||||||
#import "mediapipe/tasks/ios/common/utils/sources/MPPCommonUtils.h"
|
#import "mediapipe/tasks/ios/common/utils/sources/MPPCommonUtils.h"
|
||||||
|
#import "mediapipe/tasks/ios/common/utils/sources/NSString+Helpers.h"
|
||||||
|
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
|
|
||||||
|
@ -37,6 +38,8 @@ static const NSInteger kMPPOrientationDegreesDown = -180;
|
||||||
/** Rotation degrees for a 90 degree rotation to the left. */
|
/** Rotation degrees for a 90 degree rotation to the left. */
|
||||||
static const NSInteger kMPPOrientationDegreesLeft = -270;
|
static const NSInteger kMPPOrientationDegreesLeft = -270;
|
||||||
|
|
||||||
|
static NSString *const kTaskPrefix = @"com.mediapipe.tasks.vision";
|
||||||
|
|
||||||
@interface MPPVisionTaskRunner () {
|
@interface MPPVisionTaskRunner () {
|
||||||
MPPRunningMode _runningMode;
|
MPPRunningMode _runningMode;
|
||||||
}
|
}
|
||||||
|
@ -54,18 +57,21 @@ static const NSInteger kMPPOrientationDegreesLeft = -270;
|
||||||
if (packetsCallback) {
|
if (packetsCallback) {
|
||||||
[MPPCommonUtils createCustomError:error
|
[MPPCommonUtils createCustomError:error
|
||||||
withCode:MPPTasksErrorCodeInvalidArgumentError
|
withCode:MPPTasksErrorCodeInvalidArgumentError
|
||||||
description:@"The vision task is in image or video mode, a "
|
description:@"The vision task is in image or video mode. The "
|
||||||
@"user-defined result callback should not be provided."];
|
@"delegate must not be set in the task's options."];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MPPRunningModeLiveStream: {
|
case MPPRunningModeLiveStream: {
|
||||||
if (!packetsCallback) {
|
if (!packetsCallback) {
|
||||||
[MPPCommonUtils createCustomError:error
|
[MPPCommonUtils
|
||||||
|
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. An object must be set as the "
|
||||||
|
@"delegate of the task in its options to ensure asynchronous delivery of "
|
||||||
|
@"results."];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -197,4 +203,9 @@ static const NSInteger kMPPOrientationDegreesLeft = -270;
|
||||||
return [self sendPacketMap:packetMap error:error];
|
return [self sendPacketMap:packetMap error:error];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (const char *)uniqueDispatchQueueNameWithSuffix:(NSString *)suffix {
|
||||||
|
return [NSString stringWithFormat:@"%@.%@_%@", kTaskPrefix, suffix, [NSString uuidString]]
|
||||||
|
.UTF8String;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user