SlideShare a Scribd company logo
Depth in Depth
Shuichi Tsutsumi @shu223
iOSDC 2018
• Fyusion Inc. @ H-1B
• Senior Principal Software Engineer
• →
• @
• 8 IoT
Metal ARKit NFC etc...
• GitHub: shu223
• : Qiita Note
• :
Depth in Depth
1
RGB
✋
:
•
: 3D
• 3D
•
:
30
※
• iOS API
•
•
•
•
•
•
•
•
•
•
Disparity
iPhone 7/8 Plus, X
Focal Length
Disparity
Depth Disparity
Depth Disparity
• Depth(z) = Disparity(d)
Time of Flight (ToF)
• Depth
•
TrueDepth
iPhone X
• Proximity sensor ToF
• Dot projector ( ) 3
• Infrated camera ( )
→
•
•
•
•
AVDepthData
•
•
• @available(iOS 11.0, *)
AVDepthData
var depthDataMap: CVPixelBuffer { get }
•
• CVPixelBuffer Core Image
Metal
iOS
• 1:
• 2:
• 3: ARKit
1:
• ImageIO
• URL
Photos
URL CGImageSource
let source = CGImageSourceCreateWithURL(url as CFURL, nil)
CGImageSource Dictionary
let info = CGImageSourceCopyAuxiliaryDataInfoAtIndex(
source, 0,
kCGImageAuxiliaryDataTypeDisparity //
) as? [String : AnyObject]
// info CFDataRef
// CGImageMetadataRef
Dictionary AVDepthData
let depthData =
try! AVDepthData(fromDictionaryRepresentation: info)
2:
• AVFoundation
•
AVCaptureDevice
.builtInDualCamera, .builtInTrueDepthCamera
let device = AVCaptureDevice.DiscoverySession(
deviceTypes: [.builtInDualCamera],
mediaType: .video,
position: .back).devices.first
var supportedDepthDataFormats: [AVCaptureDevice.Format]
• AVCaptureDevice.Format
• AVCaptureDevice
activeDepthDataFormat
AVCaptureDepthDataOutput
let depthOutput = AVCaptureDepthDataOutput()
captureSession.addOutput(depthOutput)
depthOutput.setDelegate(
self, callbackQueue: dataOutputQueue)
• AVCaptureVideoDataOutput
AVCaptureAudio
AVCaptureDepthDataOutputDelegate didOutput
AVDepthData
func depthDataOutput(
_ output: AVCaptureDepthDataOutput,
didOutput depthData: AVDepthData,
timestamp: CMTime,
connection: AVCaptureConnection)
3:
ARKit
ARFrame capturedDepthData
var capturedDepthData: AVDepthData? { get }
⚠
• 1:
• 2:
• 3: ARKit
•
•
•
•
• chroma
CIBlendWithMask
Parameters
inputImage
inputBackgroundImage
inputMaskImage
•
• CIFilter Metal
OK!?
•
• CIFilter CIBlendWithMask
• Metal MTKView
•
•
2
• AVCaptureMetadataOutput
• +offset
cutOff
•
• cutOff
• cutOff
•
• "Holes"
•
• Holes RGB
isFilteringEnabled
• AVCaptureDepthDataOutput
•
• "Holes" RGB
•
•
Portrait Matte
Portrait Matte
•
• iOS 12
Portrait Matte
• CGImageSource
• PortraitEffectsMatte
• AVDapthData AVPortraitEffectsMatte
guard let info = CGImageSourceCopyAuxiliaryDataInfoAtIndex(
self, 0,
kCGImageAuxiliaryDataTypePortraitEffectsMatte
) as? [String : AnyObject] else { return }
let matte =
AVPortraitEffectsMatte(fromDictionaryRepresentation: info)
Portrait Matte
•
•
• iOS 12
•
•
•
•
• / / ARKit
• Dual / TrueDepth /
• /
• iOS 12 / 11 /
• / /
Photoshop
•
• Portrait Matte
• Portrait Matte
•
• Portrait Matte
• Disprity
•
•
ARKit
• OK
• NG
• ARFaceTrackingConfiguration
•
ARWorldTracking capturedDepth nil
•
•
•
•
• Twitter: https://twitter.com/shu223
• GitHub: https://github.com/shu223
• : http://shu223.hatenablog.com/
AVCaptureDataOutputSynchronizer
//
synchronizer = AVCaptureDataOutputSynchronizer(
dataOutputs: [videoOutput, depthOutput])
AVCaptureDataOutputSynchronizerDelegate
didOutput
AVCaptureSynchronizedDataCollection
• → AVCaptureSynchronizedDepthData
• → AVDepthData
// AVCaptureSynchronizedDepthData
if let syncedDepthData =
synchronizedDataCollection.synchronizedData(for: depthOutput)
as? AVCaptureSynchronizedDepthData,
!syncedDepthData.depthDataWasDropped
{
// AVDepthData
let depthData = syncedDepthData.depthData
...
}
Metal 3D
•
• z
•
• RGB

More Related Content

What's hot

組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門
Norishige Fukushima
 

What's hot (20)

Unicode文字列処理
Unicode文字列処理Unicode文字列処理
Unicode文字列処理
 
Cargo makeを使ってみた話
Cargo makeを使ってみた話Cargo makeを使ってみた話
Cargo makeを使ってみた話
 
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
 
ゲームAIとマルチエージェント(上)
ゲームAIとマルチエージェント(上)ゲームAIとマルチエージェント(上)
ゲームAIとマルチエージェント(上)
 
Pythonによる黒魔術入門
Pythonによる黒魔術入門Pythonによる黒魔術入門
Pythonによる黒魔術入門
 
正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?
 
Agile Quality アジャイル品質パターン (QA2AQ)
Agile Quality アジャイル品質パターン (QA2AQ)Agile Quality アジャイル品質パターン (QA2AQ)
Agile Quality アジャイル品質パターン (QA2AQ)
 
「日本語LaTeX」が多すぎる件について
「日本語LaTeX」が多すぎる件について「日本語LaTeX」が多すぎる件について
「日本語LaTeX」が多すぎる件について
 
C#でわかる こわくないMonad
C#でわかる こわくないMonadC#でわかる こわくないMonad
C#でわかる こわくないMonad
 
継承やめろマジやめろ。 なぜイケないのか 解説する
継承やめろマジやめろ。 なぜイケないのか 解説する継承やめろマジやめろ。 なぜイケないのか 解説する
継承やめろマジやめろ。 なぜイケないのか 解説する
 
GitLab から GitLab に移行したときの思い出
GitLab から GitLab に移行したときの思い出GitLab から GitLab に移行したときの思い出
GitLab から GitLab に移行したときの思い出
 
高速な倍精度指数関数expの実装
高速な倍精度指数関数expの実装高速な倍精度指数関数expの実装
高速な倍精度指数関数expの実装
 
関数プログラミング入門
関数プログラミング入門関数プログラミング入門
関数プログラミング入門
 
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
 
BoostAsioで可読性を求めるのは間違っているだろうか
BoostAsioで可読性を求めるのは間違っているだろうかBoostAsioで可読性を求めるのは間違っているだろうか
BoostAsioで可読性を求めるのは間違っているだろうか
 
【Unity】 Behavior TreeでAIを作る
 【Unity】 Behavior TreeでAIを作る 【Unity】 Behavior TreeでAIを作る
【Unity】 Behavior TreeでAIを作る
 
Self-Critical Sequence Training for Image Captioning (関東CV勉強会 CVPR 2017 読み会)
Self-Critical Sequence Training for Image Captioning (関東CV勉強会 CVPR 2017 読み会)Self-Critical Sequence Training for Image Captioning (関東CV勉強会 CVPR 2017 読み会)
Self-Critical Sequence Training for Image Captioning (関東CV勉強会 CVPR 2017 読み会)
 
ROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
ROS2勉強会@別府 第7章PythonクライアントライブラリrclpyROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
ROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
 
組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門
 
SAT/SMTソルバの仕組み
SAT/SMTソルバの仕組みSAT/SMTソルバの仕組み
SAT/SMTソルバの仕組み
 

Similar to Depth in Depth #iOSDC

콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석
Jaehyeuk Oh
 

Similar to Depth in Depth #iOSDC (20)

俺的Objective-C勉強法
俺的Objective-C勉強法俺的Objective-C勉強法
俺的Objective-C勉強法
 
Pythonistaで始めるiOSプロトタイプ開発
Pythonistaで始めるiOSプロトタイプ開発Pythonistaで始めるiOSプロトタイプ開発
Pythonistaで始めるiOSプロトタイプ開発
 
Xcodeを用いた iPhone/iPadアプリ開発
Xcodeを用いた iPhone/iPadアプリ開発Xcodeを用いた iPhone/iPadアプリ開発
Xcodeを用いた iPhone/iPadアプリ開発
 
Applebu
ApplebuApplebu
Applebu
 
Applebu
ApplebuApplebu
Applebu
 
Xcodeを用いたiPhone/iPadアプリ開発
Xcodeを用いたiPhone/iPadアプリ開発Xcodeを用いたiPhone/iPadアプリ開発
Xcodeを用いたiPhone/iPadアプリ開発
 
Introduction of Kinect Hacks
Introduction of Kinect HacksIntroduction of Kinect Hacks
Introduction of Kinect Hacks
 
Hello Flutter”の次におさえたい Flutterのポイント その5
Hello Flutter”の次におさえたい Flutterのポイント その5Hello Flutter”の次におさえたい Flutterのポイント その5
Hello Flutter”の次におさえたい Flutterのポイント その5
 
Games on AppleWatch
Games on AppleWatchGames on AppleWatch
Games on AppleWatch
 
WWW2019で見るモバイルコンピューティングの技術と動向 山本悠ニ
WWW2019で見るモバイルコンピューティングの技術と動向    山本悠ニWWW2019で見るモバイルコンピューティングの技術と動向    山本悠ニ
WWW2019で見るモバイルコンピューティングの技術と動向 山本悠ニ
 
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
 
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
 
ARToolKit to ARKit
ARToolKit to ARKitARToolKit to ARKit
ARToolKit to ARKit
 
iOS 11からのアプリ間ファイル共有_公開用
iOS 11からのアプリ間ファイル共有_公開用iOS 11からのアプリ間ファイル共有_公開用
iOS 11からのアプリ間ファイル共有_公開用
 
LTから入門するPython開発環境 #PyLadiesTokyo
LTから入門するPython開発環境 #PyLadiesTokyoLTから入門するPython開発環境 #PyLadiesTokyo
LTから入門するPython開発環境 #PyLadiesTokyo
 
[Google I/O 2018 Highlights] Flutter / WearOS
[Google I/O 2018 Highlights] Flutter / WearOS[Google I/O 2018 Highlights] Flutter / WearOS
[Google I/O 2018 Highlights] Flutter / WearOS
 
intern ppt.pptx
intern ppt.pptxintern ppt.pptx
intern ppt.pptx
 
NETConfAR v2017 Workshop Hololens
NETConfAR v2017 Workshop HololensNETConfAR v2017 Workshop Hololens
NETConfAR v2017 Workshop Hololens
 
"Hello Flutter"の次におさえたいFlutterのポイントその3
"Hello Flutter"の次におさえたいFlutterのポイントその3"Hello Flutter"の次におさえたいFlutterのポイントその3
"Hello Flutter"の次におさえたいFlutterのポイントその3
 
콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석
 

More from Shuichi Tsutsumi

More from Shuichi Tsutsumi (20)

Core MLのアップデートを3倍楽しむ方法 #wwdctokyo
Core MLのアップデートを3倍楽しむ方法 #wwdctokyoCore MLのアップデートを3倍楽しむ方法 #wwdctokyo
Core MLのアップデートを3倍楽しむ方法 #wwdctokyo
 
エンジニアという仕事を楽しみ続けるためのキャリア戦略
エンジニアという仕事を楽しみ続けるためのキャリア戦略エンジニアという仕事を楽しみ続けるためのキャリア戦略
エンジニアという仕事を楽しみ続けるためのキャリア戦略
 
UIImageView vs Metal [日本語版] #tryswiftconf
UIImageView vs Metal [日本語版] #tryswiftconfUIImageView vs Metal [日本語版] #tryswiftconf
UIImageView vs Metal [日本語版] #tryswiftconf
 
UIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconfUIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconf
 
飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC
 
Deep Learning on iOS #360iDev
Deep Learning on iOS #360iDevDeep Learning on iOS #360iDev
Deep Learning on iOS #360iDev
 
Client-Side Deep Learning
Client-Side Deep LearningClient-Side Deep Learning
Client-Side Deep Learning
 
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
 
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
 
Practical Core Bluetooth in IoT & Wearable projects @ UIKonf 2016
Practical Core Bluetooth in IoT & Wearable projects @ UIKonf 2016Practical Core Bluetooth in IoT & Wearable projects @ UIKonf 2016
Practical Core Bluetooth in IoT & Wearable projects @ UIKonf 2016
 
オープンソースエコシステム #demodaytokyo
オープンソースエコシステム #demodaytokyoオープンソースエコシステム #demodaytokyo
オープンソースエコシステム #demodaytokyo
 
Core Image Tips & Tricks in iOS 9
Core Image Tips & Tricks in iOS 9Core Image Tips & Tricks in iOS 9
Core Image Tips & Tricks in iOS 9
 
Core Graphics on watchOS 2
Core Graphics on watchOS 2Core Graphics on watchOS 2
Core Graphics on watchOS 2
 
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
 
iOS 9 の新機能 Core Image 編
iOS 9 の新機能 Core Image 編iOS 9 の新機能 Core Image 編
iOS 9 の新機能 Core Image 編
 
UI/UX に影響の大きい watchOS 2 の新機能 3つ
UI/UX に影響の大きい watchOS 2 の新機能 3つUI/UX に影響の大きい watchOS 2 の新機能 3つ
UI/UX に影響の大きい watchOS 2 の新機能 3つ
 
watchOS 2 新機能の細かい話
watchOS 2 新機能の細かい話watchOS 2 新機能の細かい話
watchOS 2 新機能の細かい話
 
Apple Watch 間通信
Apple Watch 間通信Apple Watch 間通信
Apple Watch 間通信
 
OpenCV 3.0 on iOS
OpenCV 3.0 on iOSOpenCV 3.0 on iOS
OpenCV 3.0 on iOS
 
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
 

Depth in Depth #iOSDC