后置摄像头的captureStillImageAsynchronouslyFromConnection问题 [英] Issue with captureStillImageAsynchronouslyFromConnection for Back camera

查看:93
本文介绍了后置摄像头的captureStillImageAsynchronouslyFromConnection问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

let VideoDevice = CameraWithPosition(AVCaptureDevicePosition.Back) // not working

let VideoDevice = CameraWithPosition(AVCaptureDevicePosition.Front) // working


if let stillOutput = self.stillImageOutput {

                if let videoConnection = stillOutput.connectionWithMediaType(AVMediaTypeVideo)
                {
                    println("stillOutput \(stillOutput)")

                        stillOutput.captureStillImageAsynchronouslyFromConnection(videoConnection){
                            (imageSampleBuffer : CMSampleBuffer!, _) in

                            println("imageSampleBuffer \(imageSampleBuffer)") //prints nil for back camera, works for front camera

...more code

我能够从前置摄像头捕获图像,但是相同的过程不适用于Iphone的后置摄像头,两个摄像头是否有不同的设置?

I am able to capture image from Front Camera but same process not working for Back Camera of my Iphone, Is there any different settings for both camera?

对于后置摄像头,将imageSampleBuffer接收为nil.

Receiving imageSampleBuffer as nil for Back camera..

错误日志:

错误域= AVFoundationErrorDomain代码= -11800操作无法完成" UserInfo = 0x1704682c0 {NSUnderlyingError = 0x170255d20操作无法完成.(OSStatus错误-16803.)",NSLocalizedFailureReason =发生未知错误(-16803),NSLocalizedDescription =操作无法完成}

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1704682c0 {NSUnderlyingError=0x170255d20 "The operation couldn’t be completed. (OSStatus error -16803.)", NSLocalizedFailureReason=An unknown error occurred (-16803), NSLocalizedDescription=The operation could not be completed}

推荐答案

检查 "...更多代码"

Check "...more code"

前置摄像头将更快地返回图像,因此,如果在captureStillImageAsynchronouslyFromConnection之后立即停止预览或对videoConnection进行其他更改,则前置摄像头可能适用于前置摄像头,而不适用于后置摄像头.

The frontcamera will return an image faster, so if you stop the preview or make other changes to videoConnection directly after captureStillImageAsynchronouslyFromConnection it might work for front camera but not for back camera.

这篇关于后置摄像头的captureStillImageAsynchronouslyFromConnection问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆