Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Depth APIで簡易クロマキー合成 #geek_garage_ios/depth_api_...
Search
fromkk
June 27, 2017
Programming
3
1.9k
Depth APIで簡易クロマキー合成 #geek_garage_ios/depth_api_ios11_20170627
GEEK GARAGE iOS vol3で発表したiOS 11から利用出来るDepth APIについて
fromkk
June 27, 2017
Tweet
Share
More Decks by fromkk
See All by fromkk
note社の全員野球で品質向上活動について / note_qa_challenge #iOS_test_teatime
fromkk
3
1.8k
1年分のデータが見たいと言われてやったこと/yearly_data_with_note
fromkk
0
930
note iOSチームの自動化 ver.2021/automation_with_iOS_team_on_note_ver2021
fromkk
0
1.9k
Bitrise体験会説明資料/bitrise_explore
fromkk
1
1k
noteのiOSアプリで実装したアクセシビリティの全て #iosdc #a /a11y_with_iOS_App_on_note
fromkk
2
3.6k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
2.7k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
550
note社でのMagic Pod活用事例 #af_iosdc/magicpod_with_note
fromkk
2
11k
iOSには無いmacOS独自機能をCatalystで実装する #iosdc #d/make_macos_apps_with_catalyst
fromkk
9
2.1k
Other Decks in Programming
See All in Programming
『テスト書いた方が開発が早いじゃん』を解き明かす #phpcon_nagoya
o0h
PRO
9
2.5k
Drawing Heighway’s Dragon- Recursive Function Rewrite- From Imperative Style in Pascal 64 To Functional Style in Scala 3
philipschwarz
PRO
0
150
Expoによるアプリ開発の現在地とReact Server Componentsが切り開く未来
yukukotani
1
200
メンテが命: PHPフレームワークのコンテナ化とアップグレード戦略
shunta27
0
320
Visual StudioのGitHub Copilotでいろいろやってみる
tomokusaba
1
220
Serverless Rust: Your Low-Risk Entry Point to Rust in Production (and the benefits are huge)
lmammino
1
160
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
8
1.5k
CDKを使ったPagerDuty連携インフラのテンプレート化
shibuya_shogo
0
120
はじめての Go * WASM * OCR
sgash708
1
120
Datadog DBMでなにができる? JDDUG Meetup#7
nealle
0
160
Generating OpenAPI schema from serializers throughout the Rails stack - Kyobashi.rb #5
envek
1
420
楽しく向き合う例外対応
okutsu
0
730
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
Building Your Own Lightsaber
phodgson
104
6.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
Done Done
chrislema
182
16k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
How to Ace a Technical Interview
jacobian
276
23k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Documentation Writing (for coders)
carmenintech
68
4.6k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Transcript
Depth APIͰ؆қΫϩϚΩʔ߹ GEEK GARAGE iOS vol3 2017/06/27 1
Profile Kazuya Ueoka Timers inc.ͷiOSΤϯδχΞ Twitter: @fromkk Github: fromkk Qiita:
fromkk 2
WWDC 2017ʹߦͬͯདྷ·ͨ͠✈ ϒϩά͍͔ͭ͘ॻ͍ͨͷͰΑ͔ͬͨΒ؍ͯͶ! http://techblog.timers-inc.com/archive/category/ wwdc2017 3
ΫϩϚΩʔ߹ — ฐࣾͷݕ౼தࢪࡦͷதʹΫϩϚ Ωʔ߹͕ඞཁͳ͕͋ͬͨ — ࣸਅͷಛఆ৭ͷ෦ΛಁԽͯ͠എ ܠը૾ͱ߹(άϦʔϯόοΫ) — Ϣʔβʔ͕Ξοϓϩʔυ͢Δࣸਅ ͷഎܠ͕Ұ৭͚ͩͳΜͯ΄΅օແ
ը૾ૉࡐ:εϚʔτϑΥϯͰࠓͷҿ ΈձΛ༧ʢάϦʔϯόοΫʣ 4
ͦΜͳத 5
WWDC 2017ͰDepth Api͕ެ։͞Ε·ͨ͠! 6
Sessions — 507 Capturing Depth in iPhone Photography — 508
Image Editing with Depth 7
Depthͱ — iPhone 7 PlusͷϙʔτϨʔτϞʔυͰࡱӨͨࣸ͠ਅ͔Β Ͱऔಘग़དྷΔମͷڑ — ϙʔτϨʔτࡱӨͰԕ͘ʹ͍͘ʹ࿈Εͯڧ͍΅͔͠Τ ϑΣΫτΛೖΕ͍ͯΔ( CIDepthBlurEffect
) 8
Disparityͱ — ຊޠͰ֨ࠩ — ਂΛը૾Ͱදݱͨ͠ͱউखʹղऍ 9
͕ 10
ରԠ iPhone 7 Plus iOS 11Ҏ্ ͷΈ! 11
͍͔ͨͬͨͷͰ ϝΠϯ༻͍ͯ͠ΔiPhone 7 PlusʹiOS 11 betaΛΠϯε τʔϧ͠·ͨ͠! 12
ݪཧ — 2ͭͷΧϝϥͰࡱӨͨ͠ಛఆͷ2 ͷڑ͕͍ۙํ͕खલɾΕͯ Δํ͕Ԟ — σΟʔϓϥʔχϯάͷٕज़Λར༻ ͍ͯ͠ΔΒ͍͠ʢಛͷந ग़ʁʣ 13
੍ݶࣄ߲ — iOS 11ͰࡱӨͨ͠ը૾͔Β͔͠Disparity͕औಘग़དྷͳ͍ — HEIFϑΥʔϚοτͷΈରԠ 14
HEIF — iOS 11͔ΒରԠͨ͠৽͍͠ը૾ϑΥʔϚοτ — ͍ܰʂ — Alphaνϟϯωϧ/Depth/ΞχϝʔγϣϯରԠ — λΠϧಡΈࠐΈରԠ
— etc... 15
More info about HEIF — 503 Introducing HEIF and HEVC
— 513 High Efficiency Image File Format 16
Disparityը૾ͷऔಘ — طʹࡱӨͨࣸ͠ਅ͔Βऔಘ — PhotoKitΛར༻ let asset: PHAsset = ...
asset.requestContentEditingInput(with: nil) { (input, info) in guard let imageURL: URL = input?.fullSizeImageURL else { return } if let disparityImage: CIImage = CIImage(contentsOf: imageURL, options: [kCIImageAuxiliaryDisparity: true]) { self.disparityImageView.image = UIImage(ciImage: disparityImage) } } 17
ͪͳΈʹ self.asset.requestContentEditingInput(with: nil) { (input, info) in guard let imageURL:
URL = input?.fullSizeImageURL else { return } guard let source = CGImageSourceCreateWithURL(imageURL as CFURL, nil) else { return } guard let sourceProperties = CGImageSourceCopyProperties(source, nil) else { return } print(sourceProperties) } ͱ͢Ε 18
{ "{FileContents}" = { ImageCount = 1; Images = (
{ AuxiliaryData = ( { AuxiliaryDataType = kCGImageAuxiliaryDataTypeDisparity; Height = 768; Width = 576; } ); } ); }; } ͱ͍ͬͨใ͕औಘग़དྷΔ 19
ը૾߹ͯ͠ΈΔ let ciImage: CIImage = CIImage(image: image) let wallImage: UIImage
= #imageLiteral(resourceName: "wall") guard let wallCIImage: CIImage = CIImage(image: wallImage) else { return } let maskedImage: CIImage = ciImage.applyingFilter("CIBlendWithMask", withInputParameters: [ kCIInputBackgroundImageKey: wallCIImage, kCIInputMaskImageKey: disparityImage.applyingFilter("CIColorClamp", withInputParameters: nil), ]) self.disparityImageView.image = UIImage(ciImage: maskedImage) 20
ը૾ௐ CIColorMatrix Λར༻ͯ͠άϨʔͷೱ͞Λௐ let maskImage = disparityImage.applyingFilter("CIColorMatrix", withInputParameters: [ "inputRVector"
: CIVector(x: value, y: 0, z: 0, w: 0), "inputGVector" : CIVector(x: 0, y: value, z: 0, w: 0), "inputBVector" : CIVector(x: 0, y: 0, z: value, w: 0), "inputBiasVector" : CIVector(x: bias, y: bias, z: bias, w: 0)]) 21
Sample https://github.com/fromkk/DepthAPISampleForiOS11 22
ϋϚͬͨࣄ — ͦͦCIImageɺCIFilterશવΒͳ͔ͬͨ — kCIImageAuxiliaryDepth Ͱը૾͕औಘग़དྷΔͣͳͷ ʹग़དྷͳ͔ͬͨ — ճస͍ͯ͠Δը૾ʹରԠग़དྷͳ͔ͬͨʢৄ͍͠ਓ͍ͨΒڭ ͑ͯԼ͍͞!ʣ
— ֶͦͦతͳ͕ࣝແ͍ͷͰηογϣϯͷҙຯ͕͋· Γཧղग़དྷͳ͔ͬͨʢসʣ 23
Recap — ݸਓతʹҰ୴Disparityͷը૾͕औಘग़དྷͯ࠷ݶͷ߹ ͕ग़དྷͨͷͰຬ! — ݱ࣌ͰରԠ͕݅গͳ͔͘ͳΓχονͳػೳͳͷͰ͍ ಓ͕͍͠" — iOS 11Ҏ߱ͰࡱӨͨࣸ͠ਅ͔͠Disparityը૾͕औಘग़དྷ
ͳͯ͘൵͠Έ# 24
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠! 25