LoginSignup
0
0

More than 5 years have passed since last update.

Swift3 AVCapturePhotoOutputについて

Posted at

Swift初心者です。
初投稿ですので、上手い投稿方法が解らないですがよろしくお願いします!

問題点は、写真を撮るためのfuncを作成しているのですが、Swift3での記述の仕方がわかりません。。。

// AVCaptureStillImageOutput! → AVCapturePhotoOutput!にSwift3で変更
var stillImageOutput: AVCapturePhotoOutput!

func didTakePhoto() {

    if let videoConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) {
        videoConnection.videoOrientation = AVCaptureVideoOrientation.portrait
        stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: { (buffer, error) in
            if error == nil && buffer != nil {
                let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer)
                let image = UIImage(data: imageData)

                self.imageView.image = image
                self.isShowingPhoto = true
                self.captureSession.stopRunning()
            }
        })

    }
}

ここのcaptureStillImageAsynchronouslyFromConnectionが
/*
『Value of type 'AVCapturePhotoOutput' has no member'captureStillImageAsynchronouslyFromConnection'』
*/
とエラーになりまして、調べているとSwift3ではAVCapturePhotoOutputのメソッドにはないと言うことが理解できました。
改変の記述方法はどのようにすれば良いでしょうか??

0
0
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
0
0