|
| 1 | +# Copyright 2019 The MediaPipe Authors. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_framework") |
| 16 | +load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") |
| 17 | +load( |
| 18 | + "//mediapipe/examples/ios:bundle_id.bzl", |
| 19 | + "BUNDLE_ID_PREFIX", |
| 20 | + "example_provisioning", |
| 21 | +) |
| 22 | + |
| 23 | +licenses(["notice"]) # Apache 2.0 |
| 24 | + |
| 25 | +MIN_IOS_VERSION = "11.1" |
| 26 | + |
| 27 | +IOS_FAMILIES = [ |
| 28 | + "iphone", |
| 29 | + "ipad", |
| 30 | +] |
| 31 | + |
| 32 | +# Build this .ipa with: |
| 33 | +# bazel build --config=ios_arm64 mediapipe/examples/facial_search/ios:FacialSearchGpuApp |
| 34 | +ios_application( |
| 35 | + name = "FacialSearchGpuApp", |
| 36 | + app_icons = ["//mediapipe/examples/ios/common:AppIcon"], |
| 37 | + bundle_id = BUNDLE_ID_PREFIX + ".FacialSearchGpu", |
| 38 | + families = IOS_FAMILIES, |
| 39 | + infoplists = [ |
| 40 | + "//mediapipe/examples/ios/common:Info.plist", |
| 41 | + "Info.plist", |
| 42 | + ], |
| 43 | + minimum_os_version = MIN_IOS_VERSION, |
| 44 | + provisioning_profile = example_provisioning(), |
| 45 | + deps = [":FacialSearchGpuAppLibrary"], |
| 46 | +) |
| 47 | + |
| 48 | +swift_library( |
| 49 | + name = "FacialSearchGpuAppLibrary", |
| 50 | + srcs = [ |
| 51 | + "AppDelegate.swift", |
| 52 | + "Cameras.swift", |
| 53 | + "DotDot.swift", |
| 54 | + "FacialSearchViewController.swift", |
| 55 | + ], |
| 56 | + data = ["Base.lproj/Main.storyboard"], |
| 57 | + deps = [ |
| 58 | + ":ObjcppLib", |
| 59 | + "@ios_opencv//:OpencvFramework", |
| 60 | + ], |
| 61 | +) |
| 62 | + |
| 63 | +FRAMEWORK_HEADERS = [ |
| 64 | + "FaceMeshIOSLib.h", |
| 65 | +] |
| 66 | + |
| 67 | +# Using Mediapipe in an iOS Swift app (without Tulsi) |
| 68 | +# Create new Swift app: XCode: File > New > Project... |
| 69 | +# Select iOS > "Single View App" > Next |
| 70 | +# Select Language: Swift > Next > Create |
| 71 | +# Delete these files from the new project: (Move to Trash) |
| 72 | +# * AppDelegate.swift |
| 73 | +# * ViewController.swift |
| 74 | +# Copy these files to your app: (if asked, do not create a bridging header) |
| 75 | +# * AppDelegate.swift |
| 76 | +# * Cameras.swift |
| 77 | +# * DotDot.swift |
| 78 | +# * FacialSearchViewController.swift |
| 79 | +# Edit your app's Info.plist: |
| 80 | +# * Create key "NSCameraUsageDescription" with value: "This app uses the camera to demonstrate live video processing." |
| 81 | +# Edit your Main.storyboard's custom class, setting it to FacialSearchViewController (in the Identity inspector) |
| 82 | +# Run: bazel build --copt=-fembed-bitcode --apple_bitcode=embedded --config=ios_arm64 mediapipe/examples/facial_search/ios:FacialSearch (replace FacialSearch path/framework name with framework name) |
| 83 | +# (some linker warnings about global C++ symbols may appear) |
| 84 | +# Run: ./mediapipe/examples/facial_search/ios/patch_ios_framework.sh bazel-bin/mediapipe/examples/facial_search/ios/FacialSearch.zip ObjcppLib.h |
| 85 | +# Note: append the contents of FRAMEWORK_HEADERS separated by spaces (here: ObjcppLib.h). |
| 86 | +# Run: open bazel-bin/mediapipe/examples/facial_search/ios and drag and drop |
| 87 | +# the FacialSearch.framework folder into your app files (check: Copy items if needed > Finish) |
| 88 | +# Make sure the framework gets embedded into the app: |
| 89 | +# In General > Frameworks, Libraries, and Embedded Content set FacialSearch.framework to "Embed & Sign". |
| 90 | +# Connect your device and run. |
| 91 | +ios_framework( |
| 92 | + name = "FaceMeshIOSLibFramework", |
| 93 | + hdrs = FRAMEWORK_HEADERS, |
| 94 | + bundle_id = BUNDLE_ID_PREFIX + ". FaceMeshIOSLibFramework", |
| 95 | + bundle_name = "FaceMeshIOSLibFramework", |
| 96 | + families = IOS_FAMILIES, |
| 97 | + infoplists = [ |
| 98 | + "//mediapipe/examples/ios/common:Info.plist", |
| 99 | +# "Info.plist", |
| 100 | + ], |
| 101 | + minimum_os_version = MIN_IOS_VERSION, |
| 102 | + visibility = ["//visibility:public"], |
| 103 | + deps = [ |
| 104 | + ":FaceMeshIOSLib", |
| 105 | + "@ios_opencv//:OpencvFramework", |
| 106 | + ], |
| 107 | +) |
| 108 | + |
| 109 | + |
| 110 | +# amalgamate stuff in from the facemeshgpu iOS example |
| 111 | +objc_library( |
| 112 | + name = "FaceMeshIOSLib", |
| 113 | + srcs = [ |
| 114 | + "FaceMeshIOSLib.mm", |
| 115 | + ], |
| 116 | + hdrs = FRAMEWORK_HEADERS, |
| 117 | + copts = ["-std=c++17"], # https://github.com/google/mediapipe/issues/2275#issuecomment-877145926 |
| 118 | + data = [ |
| 119 | + "//mediapipe/graphs/face_mesh:pure_face_mesh_mobile_gpu.binarypb", |
| 120 | + "//mediapipe/modules/face_detection:face_detection_short_range.tflite", |
| 121 | + "//mediapipe/modules/face_landmark:face_landmark.tflite", |
| 122 | + ], |
| 123 | + deps = [ |
| 124 | + "//mediapipe/objc:mediapipe_framework_ios", |
| 125 | + "//mediapipe/objc:mediapipe_input_sources_ios", |
| 126 | +# "//mediapipe/objc:mediapipe_layer_renderer", # no need for layer renderer since I don't render |
| 127 | + ] + select({ |
| 128 | +# "//mediapipe:ios_i386": [], |
| 129 | +# "//mediapipe:ios_x86_64": [], |
| 130 | + "//conditions:default": [ |
| 131 | + "//mediapipe/graphs/face_mesh:mobile_calculators", |
| 132 | + "//mediapipe/framework/formats:landmark_cc_proto", |
| 133 | +# "//mediapipe/examples/facial_search/graphs:gpu_calculators", |
| 134 | +# "//mediapipe/examples/facial_search:embeddings_database", |
| 135 | + ], |
| 136 | + }), |
| 137 | +) |
0 commit comments