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
2k
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.9k
1年分のデータが見たいと言われてやったこと/yearly_data_with_note
fromkk
0
980
note iOSチームの自動化 ver.2021/automation_with_iOS_team_on_note_ver2021
fromkk
0
2k
Bitrise体験会説明資料/bitrise_explore
fromkk
1
1.1k
noteのiOSアプリで実装したアクセシビリティの全て #iosdc #a /a11y_with_iOS_App_on_note
fromkk
2
4.1k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
3k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
600
note社でのMagic Pod活用事例 #af_iosdc/magicpod_with_note
fromkk
2
11k
iOSには無いmacOS独自機能をCatalystで実装する #iosdc #d/make_macos_apps_with_catalyst
fromkk
9
2.2k
Other Decks in Programming
See All in Programming
開発生産性を上げるための生成AI活用術
starfish719
3
1.1k
kiroとCodexで最高のSpec駆動開発を!!数時間で web3ネイティブなミニゲームを作ってみたよ!
mashharuki
0
570
登壇は dynamic! な営みである / speech is dynamic
da1chi
0
340
他言語経験者が Golangci-lint を最初のコーディングメンターにした話 / How Golangci-lint Became My First Coding Mentor: A Story from a Polyglot Programmer
uma31
0
180
ソフトウェア設計の実践的な考え方
masuda220
PRO
4
590
Android16 Migration Stories ~Building a Pattern for Android OS upgrades~
reoandroider
0
110
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
400
CSC305 Lecture 04
javiergs
PRO
0
270
Railsだからできる 例外業務に禍根を残さない 設定設計パターン
ei_ei_eiichi
0
920
Go言語はstack overflowの夢を見るか?
logica0419
0
350
(Extension DC 2025) Actor境界を越える技術
teamhimeh
1
260
『毎日の移動』を支えるGoバックエンド内製開発
yutautsugi
2
250
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
Statistics for Hackers
jakevdp
799
220k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Faster Mobile Websites
deanohume
310
31k
Building Adaptive Systems
keathley
44
2.8k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Optimizing for Happiness
mojombo
379
70k
Keith and Marios Guide to Fast Websites
keithpitt
411
23k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
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