Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

iOS 10 new Camera

550 Aufrufe

Veröffentlicht am

iOS 10 にて変更のあった Camera 周りの実装についてまとめました。

Veröffentlicht in: Mobil
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • Gehören Sie zu den Ersten, denen das gefällt!

iOS 10 new Camera

  1. 1. Copyright © Up-frontier, Inc. All rights reserved. iOS 10 new Camera 1
  2. 2. Copyright © Up-frontier, Inc. All rights reserved. ⽬次 1. カメラ機能について 2. AVCapturePhotoOutput 3. AVCapturePhotoSettings 4. 実装 5. iPhone7Plus のデュアルカメラ 2
  3. 3. Copyright © Up-frontier, Inc. All rights reserved. カメラ機能について 3
  4. 4. Copyright © Up-frontier, Inc. All rights reserved. 従来の⽅法 従来 iOS で写真撮影といえば UIImagePickerController AVFoundation を使⽤する⽅法の2つが良く使われる 4
  5. 5. Copyright © Up-frontier, Inc. All rights reserved. 従来の⽅法 従来 iOS で写真撮影といえば UIImagePickerController AVFoundation を使⽤する⽅法の2つが良く使われる 今回のメインはコレ 5
  6. 6. Copyright © Up-frontier, Inc. All rights reserved. iOS 10 は? iOS 10 では AVFoundation の中の AVCaptureStillImageOutput が deprecated に なった そのため別な⽅法として AVCapturePhotoOutput を使⽤する 6
  7. 7. Copyright © Up-frontier, Inc. All rights reserved. AVCapturePhotoOutput 7
  8. 8. Copyright © Up-frontier, Inc. All rights reserved. AVCapturePhotoOutput とは 静⽌画撮影をサポートする AVCaptureOutput のサブクラス AVCaptureStillImageOutput の代わりとして使⽤ 様々なインターフェースが実装されている 使⽤可能なのは iOS 10 から 8
  9. 9. Copyright © Up-frontier, Inc. All rights reserved. 撮影 AVCapturePhotoOutput の capturePhoto 呼ぶ際にデータを作成するための設定を渡す AVCapturePhotoSettings AVCapturePhotoCaptureDelegate 9
  10. 10. Copyright © Up-frontier, Inc. All rights reserved. 撮影 AVCapturePhotoOutput の capturePhoto 呼ぶ際にデータを作成するための設定を渡す AVCapturePhotoSettings AVCapturePhotoCaptureDelegate 画像効果等の設定 10
  11. 11. Copyright © Up-frontier, Inc. All rights reserved. 撮影 AVCapturePhotoOutput の capturePhoto 呼ぶ際にデータを作成するための設定を渡す AVCapturePhotoSettings AVCapturePhotoCaptureDelegate 画像効果等の設定 結果の返ってくる Delegate 11
  12. 12. Copyright © Up-frontier, Inc. All rights reserved. AVCapturePhotoSettings 12
  13. 13. Copyright © Up-frontier, Inc. All rights reserved. AVCapturePhotoSettings とは 写真のキャプチャに関する設定を記述する 画像に対しての効果などもここに記述 フラッシュのモード ハイレゾの使⽤ 13
  14. 14. Copyright © Up-frontier, Inc. All rights reserved. AVCapturePhotoSettings とは このインスタンスは使い回しができない 使い回しをしようとすると例外が発⽣ 再利⽤するためのメソッドが⽤意してある init(from:) に使い回したい settings を渡す 14
  15. 15. Copyright © Up-frontier, Inc. All rights reserved. 実装 15
  16. 16. Copyright © Up-frontier, Inc. All rights reserved. AVCaptureSession の設定 基本的なコードは従来と変わらない session = AVCaptureSession() session?.sessionPreset = AVCaptureSessionPresetPhoto videoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) guard let _videoPreviewLayer = videoPreviewLayer else {return} _videoPreviewLayer.frame = self.view.frame _videoPreviewLayer.masksToBounds = true _videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill self.view.layer.addSublayer(_videoPreviewLayer) let device = AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.back) let input = try! AVCaptureDeviceInput(device: device) session?.addInput(input) photoOutput = AVCapturePhotoOutput() session?.addOutput(photoOutput) session?.startRunning() 16
  17. 17. Copyright © Up-frontier, Inc. All rights reserved. AVCaptureSession の設定 基本的なコードは従来と変わらない session = AVCaptureSession() session?.sessionPreset = AVCaptureSessionPresetPhoto videoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) guard let _videoPreviewLayer = videoPreviewLayer else {return} _videoPreviewLayer.frame = self.view.frame _videoPreviewLayer.masksToBounds = true _videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill self.view.layer.addSublayer(_videoPreviewLayer) let device = AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.back) let input = try! AVCaptureDeviceInput(device: device) session?.addInput(input) photoOutput = AVCapturePhotoOutput() session?.addOutput(photoOutput) session?.startRunning() AVCapture Session 
 の設定 17
  18. 18. Copyright © Up-frontier, Inc. All rights reserved. AVCaptureSession の設定 基本的なコードは従来と変わらない session = AVCaptureSession() session?.sessionPreset = AVCaptureSessionPresetPhoto videoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) guard let _videoPreviewLayer = videoPreviewLayer else {return} _videoPreviewLayer.frame = self.view.frame _videoPreviewLayer.masksToBounds = true _videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill self.view.layer.addSublayer(_videoPreviewLayer) let device = AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.back) let input = try! AVCaptureDeviceInput(device: device) session?.addInput(input) photoOutput = AVCapturePhotoOutput() session?.addOutput(photoOutput) session?.startRunning() AVCapture Session 
 の設定 プレビューを表⽰する⽤の
 レイヤー作成 18
  19. 19. Copyright © Up-frontier, Inc. All rights reserved. AVCaptureSession の設定 基本的なコードは従来と変わらない session = AVCaptureSession() session?.sessionPreset = AVCaptureSessionPresetPhoto videoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) guard let _videoPreviewLayer = videoPreviewLayer else {return} _videoPreviewLayer.frame = self.view.frame _videoPreviewLayer.masksToBounds = true _videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill self.view.layer.addSublayer(_videoPreviewLayer) let device = AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.back) let input = try! AVCaptureDeviceInput(device: device) session?.addInput(input) photoOutput = AVCapturePhotoOutput() session?.addOutput(photoOutput) session?.startRunning() AVCapture Session 
 の設定 プレビューを表⽰する⽤の
 レイヤー作成 デバイスの設定 19
  20. 20. Copyright © Up-frontier, Inc. All rights reserved. AVCaptureSession の設定 基本的なコードは従来と変わらない session = AVCaptureSession() session?.sessionPreset = AVCaptureSessionPresetPhoto videoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) guard let _videoPreviewLayer = videoPreviewLayer else {return} _videoPreviewLayer.frame = self.view.frame _videoPreviewLayer.masksToBounds = true _videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill self.view.layer.addSublayer(_videoPreviewLayer) let device = AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.back) let input = try! AVCaptureDeviceInput(device: device) session?.addInput(input) photoOutput = AVCapturePhotoOutput() session?.addOutput(photoOutput) session?.startRunning() 実際に変わるのはここ! 20
  21. 21. Copyright © Up-frontier, Inc. All rights reserved. コード func takePicture(){ let settingsForMonitoring = AVCapturePhotoSettings() settingsForMonitoring.flashMode = .auto settingsForMonitoring.isAutoStillImageStabilizationEnabled = true settingsForMonitoring.isHighResolutionPhotoEnabled = false // settings と delegate を渡す photoOutput?.capturePhoto(with: settingsForMonitoring, delegate: self) } extension ViewController:AVCapturePhotoCaptureDelegate{ func capture(_ captureOutput: AVCapturePhotoOutput, didFinishProcessingPhotoSampleBuffer photoSampleBuffer: CMSampleBuffer?, previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?) { /* ~~ ここでデータを保存したり画像の加⼯を⾏う ~~*/ } } 21
  22. 22. Copyright © Up-frontier, Inc. All rights reserved. コード func takePicture(){ let settingsForMonitoring = AVCapturePhotoSettings() settingsForMonitoring.flashMode = .auto settingsForMonitoring.isAutoStillImageStabilizationEnabled = true settingsForMonitoring.isHighResolutionPhotoEnabled = false // settings と delegate を渡す photoOutput?.capturePhoto(with: settingsForMonitoring, delegate: self) } extension ViewController:AVCapturePhotoCaptureDelegate{ func capture(_ captureOutput: AVCapturePhotoOutput, didFinishProcessingPhotoSampleBuffer photoSampleBuffer: CMSampleBuffer?, previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?) { /* ~~ ここでデータを保存したり画像の加⼯を⾏う ~~*/ } } ここでAVCapturePhotoSettings
 を設定している 22
  23. 23. Copyright © Up-frontier, Inc. All rights reserved. iPhone 7 Plus の デュアルカメラ 23
  24. 24. Copyright © Up-frontier, Inc. All rights reserved. デュアルカメラ • iPhone 7 plus には背⾯に 2 つのカメラがついて る • カメラアプリでそれらを指定して使⽤することが出 来るのかどうか確認した 24
  25. 25. Copyright © Up-frontier, Inc. All rights reserved. ⽚⽅のカメラの指定 AVCaptureDevice.defaultDevice(withDeviceType: mediaType: position:) 上記メソッドの withDeviceType に設定 builtInWideAngleCamera : 左カメラ builtInTelephotoCamera : 右カメラ 指定しない版のメソッドなら左カメラ 25

×