0
これは私のカスタムカメラでキャプチャ写真に使用したコードですが、写真を正しくキャプチャしていますが、ユーザがデバイスを回転させると思いますが(カメラはまだiphoneカメラのような肖像画になります)、写真を撮ってみましょう。それを行う?キャプチャ後の画像の向きを変更する方法は?
let stillImageOutput = self._getStillImageOutput()
if let videoConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) {
// videoConnection.videoOrientation = AVCaptureVideoOrientation.portrait
stillImageOutput.captureStillImageAsynchronously(from: videoConnection , completionHandler: { [weak self] sample, error in
if let error = error {
DispatchQueue.main.async(execute: {
self?._show(NSLocalizedString("Error", comment:""), message: error.localizedDescription)
})
imageCompletion(nil,error as NSError?)
return
}
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample)
var capturedImage = UIImage(data: imageData!)[![This how photo showing if i capture by rotating Device][1]][1]
可能な重複:// stackoverflowの.com/questions/24965638/how-to-flip-uiimage-horizontally-with-swift) –
いいえ、別の質問です。 –
これは役に立ちます。それはObjective-Cですが、あなたはそのアイディアを得ています。 http://stackoverflow.com/a/7932657/7005670 –