LoginSignup
6
6

More than 3 years have passed since last update.

[Swift] iOS13以降で使用可能なAPIまとめ

Posted at

iOS APIとは?

Appleにより提供されている標準APIです。
意外と知られていない面白い機能などがたくさんあるので、今日はいくつかピックアップして紹介します。

環境

  • Xcode11.1
  • Swift5

Vision(Text Recognition)

68022429-9b05bc00-fce7-11e9-8337-fa71db61583a.gif

概要:
・文字の領域を識別
・文字認識

※英数字の識別しか現状できない

技術資料:
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

68005518-e05ec500-fcb8-11e9-802d-4f732efee9df.gif
概要:
・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

68223032-60758980-002f-11ea-8fb2-559f9c451b69.gif
概要:
・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

68223058-6c614b80-002f-11ea-8e2e-0600ab35794b.png
概要:
・人物の矩形を背景から切り抜き
・人物の矩形と背景の深度測定
・AR表現における回り込み

※現状静止画のみ
※人物のみ

技術資料:
iOS 12のPortrait Matteがすごい/ #iOSDC 2018で登壇します

サンプルコード:
PortraitEffectsMatteSample

Apple Document:
https://developer.apple.com/documentation/avfoundation/avportraiteffectsmatte

Semantic Segmentation Matte

68005658-4fd4b480-fcb9-11e9-800b-c6d109cf0387.jpg
概要:
概要:
・人物の"髪", "肌", "歯"をセグメンテーションする

※現状静止画のみ
※人物のみ

技術資料:
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

68066465-ef5a7b80-fd7b-11e9-8fad-812ae63b4af5.jpg
概要:
・デバイスの振動制御が可能
・細かな振動制御まで可能

技術資料:
iOS13で公開予定の「Core Haptics」を使って、Haptic Feedback (触覚フィードバック) するコードを書いてみた

Apple Document:
https://developer.apple.com/documentation/corehaptics

デプス推定(Apple提供CoreML)

68222674-b85fc080-002e-11ea-99f8-551d11973736.gif
概要:
・iOS11以上であればどのデバイスでも測定可能
・静止画でも動画でも測定可能
・人間以外のオブジェクトも識別可能 ・Depth測定以外(セグメンテーション)なども可能
・Portrait Effects MatteやSemantic Segmentation Matteなど、iOS13以降の標準APIよりかは精度は荒い印象(学習モデルが強化されたら今後の期待大)

技術資料:
DepthPrediction-CoreML

Apple Document:
https://developer.apple.com/jp/machine-learning/models/

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6