Merge pull request #3974 from priankakariatyml:ios-task-updates

PiperOrigin-RevId: 500323180
This commit is contained in:
Copybara-Service 2023-01-06 20:53:33 -08:00
commit e11ba95adf
7 changed files with 36 additions and 36 deletions

View File

@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* @enum MPPTasksErrorCode
* This enum specifies error codes for Mediapipe Task Library.
* This enum specifies error codes for MediaPipe Task Library.
* It maintains a 1:1 mapping to MediaPipeTasksStatus of the C ++libray.
*/
typedef NS_ENUM(NSUInteger, MPPTasksErrorCode) {

View File

@ -18,7 +18,7 @@
NS_ASSUME_NONNULL_BEGIN
/** Error domain of Mediapipe Task related errors. */
/** Error domain of MediaPipe Task related errors. */
extern NSString *const MPPTasksErrorDomain;
/** Helper utility for the all tasks which encapsulates common functionality. */

View File

@ -96,7 +96,7 @@ NSString *const MPPTasksErrorDomain = @"com.google.mediapipe.tasks";
// The mapping to absl::Status::code() is done to generate a more specific error code than
// MPPTasksErrorCodeError in cases when the payload can't be mapped to
// MPPTasksErrorCode. This can happen when absl::Status returned by TFLite library are in turn
// returned without modification by Mediapipe cc library methods.
// returned without modification by MediaPipe cc library methods.
if (errorCode > MPPTasksErrorCodeLast || errorCode <= MPPTasksErrorCodeFirst) {
switch (status.code()) {
case absl::StatusCode::kInternal:

View File

@ -69,59 +69,59 @@ using ::mediapipe::InputStreamInfo;
}
- (CalculatorGraphConfig)generateGraphConfig {
CalculatorGraphConfig graph_config;
CalculatorGraphConfig graphConfig;
Node *task_subgraph_node = graph_config.add_node();
task_subgraph_node->set_calculator(self.taskGraphName.cppString);
[self.taskOptions copyToProto:task_subgraph_node->mutable_options()];
Node *taskSubgraphNode = graphConfig.add_node();
taskSubgraphNode->set_calculator(self.taskGraphName.cppString);
[self.taskOptions copyToProto:taskSubgraphNode->mutable_options()];
for (NSString *outputStream in self.outputStreams) {
auto cpp_output_stream = std::string(outputStream.cppString);
task_subgraph_node->add_output_stream(cpp_output_stream);
graph_config.add_output_stream(cpp_output_stream);
auto cppOutputStream = std::string(outputStream.cppString);
taskSubgraphNode->add_output_stream(cppOutputStream);
graphConfig.add_output_stream(cppOutputStream);
}
if (!self.enableFlowLimiting) {
for (NSString *inputStream in self.inputStreams) {
auto cpp_input_stream = inputStream.cppString;
task_subgraph_node->add_input_stream(cpp_input_stream);
graph_config.add_input_stream(cpp_input_stream);
auto cppInputStream = inputStream.cppString;
taskSubgraphNode->add_input_stream(cppInputStream);
graphConfig.add_input_stream(cppInputStream);
}
return graph_config;
return graphConfig;
}
Node *flow_limit_calculator_node = graph_config.add_node();
Node *flowLimitCalculatorNode = graphConfig.add_node();
flow_limit_calculator_node->set_calculator("FlowLimiterCalculator");
flowLimitCalculatorNode->set_calculator("FlowLimiterCalculator");
InputStreamInfo *input_stream_info = flow_limit_calculator_node->add_input_stream_info();
input_stream_info->set_tag_index("FINISHED");
input_stream_info->set_back_edge(true);
InputStreamInfo *inputStreamInfo = flowLimitCalculatorNode->add_input_stream_info();
inputStreamInfo->set_tag_index("FINISHED");
inputStreamInfo->set_back_edge(true);
FlowLimiterCalculatorOptions *flow_limit_calculator_options =
flow_limit_calculator_node->mutable_options()->MutableExtension(
FlowLimiterCalculatorOptions *flowLimitCalculatorOptions =
flowLimitCalculatorNode->mutable_options()->MutableExtension(
FlowLimiterCalculatorOptions::ext);
flow_limit_calculator_options->set_max_in_flight(1);
flow_limit_calculator_options->set_max_in_queue(1);
flowLimitCalculatorOptions->set_max_in_flight(1);
flowLimitCalculatorOptions->set_max_in_queue(1);
for (NSString *inputStream in self.inputStreams) {
graph_config.add_input_stream(inputStream.cppString);
graphConfig.add_input_stream(inputStream.cppString);
NSString *strippedInputStream = [MPPTaskInfo stripTagIndex:inputStream];
flow_limit_calculator_node->add_input_stream(strippedInputStream.cppString);
flowLimitCalculatorNode->add_input_stream(strippedInputStream.cppString);
NSString *taskInputStream = [MPPTaskInfo addStreamNamePrefix:inputStream];
task_subgraph_node->add_input_stream(taskInputStream.cppString);
taskSubgraphNode->add_input_stream(taskInputStream.cppString);
NSString *strippedTaskInputStream = [MPPTaskInfo stripTagIndex:taskInputStream];
flow_limit_calculator_node->add_output_stream(strippedTaskInputStream.cppString);
flowLimitCalculatorNode->add_output_stream(strippedTaskInputStream.cppString);
}
NSString *firstOutputStream = self.outputStreams[0];
auto finished_output_stream = "FINISHED:" + firstOutputStream.cppString;
flow_limit_calculator_node->add_input_stream(finished_output_stream);
auto finishedOutputStream = "FINISHED:" + firstOutputStream.cppString;
flowLimitCalculatorNode->add_input_stream(finishedOutputStream);
return graph_config;
return graphConfig;
}
+ (NSString *)stripTagIndex:(NSString *)tagIndexName {

View File

@ -25,7 +25,7 @@ NS_SWIFT_NAME(TaskOptions)
@interface MPPTaskOptions : NSObject <NSCopying>
/**
* Base options for configuring the Mediapipe task.
* Base options for configuring the MediaPipe task.
*/
@property(nonatomic, copy) MPPBaseOptions *baseOptions;

View File

@ -26,11 +26,11 @@ NS_SWIFT_NAME(TaskResult)
/**
* Timestamp that is associated with the task result object.
*/
@property(nonatomic, assign, readonly) long timestamp;
@property(nonatomic, assign, readonly) NSInteger timestampMs;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithTimestamp:(long)timestamp NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTimestampMs:(NSInteger)timestampMs NS_DESIGNATED_INITIALIZER;
@end

View File

@ -16,16 +16,16 @@
@implementation MPPTaskResult
- (instancetype)initWithTimestamp:(long)timestamp {
- (instancetype)initWithTimestampMs:(NSInteger)timestampMs {
self = [super init];
if (self) {
_timestamp = timestamp;
_timestampMs = timestampMs;
}
return self;
}
- (id)copyWithZone:(NSZone *)zone {
return [[MPPTaskResult alloc] initWithTimestamp:self.timestamp];
return [[MPPTaskResult alloc] initWithTimestampMs:self.timestampMs];
}
@end