Added MPPBaseOptions helpers
This commit is contained in:
parent
8ba81de20b
commit
e6657dc8c1
27
mediapipe/tasks/ios/core/utils/BUILD
Normal file
27
mediapipe/tasks/ios/core/utils/BUILD
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Copyright 2022 The MediaPipe Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
package(default_visibility = ["//mediapipe/tasks:internal"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
objc_library(
|
||||
name = "MPPBaseOptionsHelpers",
|
||||
srcs = ["sources/MPPBaseOptions+Helpers.mm"],
|
||||
hdrs = ["sources/MPPBaseOptions+Helpers.h"],
|
||||
deps = [
|
||||
"//mediapipe/tasks/ios/core:MPPBaseOptions",
|
||||
"//mediapipe/tasks/cc/core/proto:base_options_cc_proto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2023 The MediaPipe Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "mediapipe/tasks/cc/core/proto/base_options.pb.h"
|
||||
#import "mediapipe/tasks/ios/core/sources/MPPBaseOptions.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MPPBaseOptions (Helpers)
|
||||
|
||||
- (void)copyToProto:(mediapipe::tasks::core::proto::BaseOptions *)baseOptionsProto;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2023 The MediaPipe Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "mediapipe/tasks/ios/core/utils/sources/MPPBaseOptions+Helpers.h"
|
||||
|
||||
namespace {
|
||||
using BaseOptionsProto = ::mediapipe::tasks::core::proto::BaseOptions;
|
||||
}
|
||||
|
||||
@implementation MPPBaseOptions (Helpers)
|
||||
|
||||
- (void)copyToProto:(BaseOptionsProto *)baseOptionsProto {
|
||||
if (self.modelAssetPath) {
|
||||
baseOptionsProto->mutable_model_asset()->set_file_name(self.modelAssetPath.UTF8String);
|
||||
}
|
||||
|
||||
switch (self.delegate) {
|
||||
case MPPDelegateCPU: {
|
||||
baseOptionsProto->mutable_acceleration()->mutable_tflite();
|
||||
break;
|
||||
}
|
||||
case MPPDelegateGPU:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue
Block a user