iOS APIとは?
Appleにより提供されている標準APIです。
意外と知られていない面白い機能などがたくさんあるので、今日はいくつかピックアップして紹介します。
環境
- Xcode11.1
- Swift5
Vision(Text Recognition)
概要:
・文字の領域を識別
・文字認識
※英数字の識別しか現状できない
技術資料:
How to use VNRecognizeTextRequest’s optical character recognition to detect text in an image
Text recognition on iOS 13 with Vision, SwiftUI and Combine
サンプルコード:
ScanningDocuments
Apple Document:
https://developer.apple.com/documentation/vision
VisionKit
概要:
・iOS13からNotesアプリに搭載されるOCRの機能を提供(文字認識)
・ドキュメントスキャン
・ドキュメント編集
技術資料:
VisionKitBasics
Scanning documents with Vision and VisionKit on iOS 13
サンプルコード:
VisionKit-Example
Apple Document:
https://developer.apple.com/documentation/visionkit
https://developer.apple.com/documentation/visionkit/vndocumentcameraviewcontrollerdelegate
Core NFC
概要:
・NFCタグ直接読み取り/書き込み(システムコード指定、暗号化通信可)
・カード固有IDの読み出し
・高機能/複雑な構造を持ったカード・タグの取り扱い
・交通系電子マネーの履歴読み取り
・会員カードの読み取り
・NDEFタグの作成・書き換え
・フィットネス機器などとの双方向の通信
・各種機器の設定
・各種機器のそれなりの容量のデータの読み取り
※ FeliCa Plug, FeliCa Linkその他など
技術資料:
iPhoneでFeliCaを読み取ってみた
iOS13 CoreNFCの使いみちとQRコード、BLEとの比較
サンプルコード:
vCardCoreNFCWriter
ライブラリ:
TRETJapanNFCReader
Apple Document:
https://developer.apple.com/documentation/corenfc
Portrait Effects Matte
概要:
・人物の矩形を背景から切り抜き
・人物の矩形と背景の深度測定
・AR表現における回り込み
※現状静止画のみ
※人物のみ
技術資料:
iOS 12のPortrait Matteがすごい/ #iOSDC 2018で登壇します
サンプルコード:
PortraitEffectsMatteSample
Apple Document:
https://developer.apple.com/documentation/avfoundation/avportraiteffectsmatte
Semantic Segmentation Matte
概要:
概要:
・人物の"髪", "肌", "歯"をセグメンテーションする
※現状静止画のみ
※人物のみ
技術資料:
Multi-cam support in iOS 13 allows simultaneous video, photo, and audio capture
Apple Document:
https://developer.apple.com/documentation/avfoundation/avsemanticsegmentationmatte?language=objc
補足:
Portrait Effects Matteと同様の方法でImageDataを操作するが、用意されているメソッドでは今の所実装出来なかった(動かなかった)。 Semantic Segmentation Matteの実装資料も見当たらない。 またApple公式でもSemantic Segmentation Matteの実装について言及している資料が見当たらない。
Core Haptic
概要:
・デバイスの振動制御が可能
・細かな振動制御まで可能
技術資料:
iOS13で公開予定の「Core Haptics」を使って、Haptic Feedback (触覚フィードバック) するコードを書いてみた
Apple Document:
https://developer.apple.com/documentation/corehaptics
デプス推定(Apple提供CoreML)
概要:
・iOS11以上であればどのデバイスでも測定可能
・静止画でも動画でも測定可能
・人間以外のオブジェクトも識別可能 ・Depth測定以外(セグメンテーション)なども可能
・Portrait Effects MatteやSemantic Segmentation Matteなど、iOS13以降の標準APIよりかは精度は荒い印象(学習モデルが強化されたら今後の期待大)
技術資料:
DepthPrediction-CoreML
Apple Document:
https://developer.apple.com/jp/machine-learning/models/