3

ここで画像をキャプチャしようとしています:

var stillImageOutput = AVCaptureStillImageOutput()
stillImageOutput!.outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]

[...] 

if let videoConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo) {
     videoConnection.videoOrientation = AVCaptureVideoOrientation.Portrait
     println("enabled = \(videoConnection.enabled)") //enabled = true
     println("active = \(videoConnection.active)") //active = true
     stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {
          (sampleBuffer, error) in
          if error != nil {
               println(error)
          }
     })
}

ほとんどの場合、完全に機能します。

ただし、次の呼び出し時にエラーが発生することがありますcaptureStillImageAsynchronouslyFromConnection

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation couldn't be completed." 
UserInfo=0x14682110 {NSLocalizedDescription=The operation couldn't be completed., 
NSUnderlyingError=0x1676be30 "The operation couldn't be completed.
(OSStatus error -16400.)", 
NSLocalizedFailureReason=An unknown error has occured (-16400)}

このエラーが発生することを予想したいだけです。私はテストを試みましvideoConnection.enabledvideoConnection.activeが、どちらもエラーから独立しているようです...

写真を撮影する前に、すべてが問題ないことを確認するために何を確認する必要がありますか?

4

1 に答える 1

5

私もあなたと同じエラーメッセージを受け取りました。多くのデバッグを行った後、写真を撮る前にキャプチャ セッションを誤って停止していたことに気付きました。.runningのプロパティが でAVCaptureSessionあることを再確認してくださいtrue

于 2015-11-14T21:30:58.840 に答える