在iOS升级从7.0.6升级到7.1.0之后,我们遇到了麻烦。我没有在iPhone 4s,5,5c上看到这个问题,也没有看到运行iOS 7.1的5s对所有非碎片化的讨论都有这么多的问题。我正在张贴相机初始化代码:
- (void)initCapture
{
//Setting up the AVCaptureDevice (camera)
AVCaptureDevice* inputDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError* cameraError;
if ([inputDevice lockForConfiguration:&cameraError])
{
if ([inputDevice isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus])
{
NSLog(@"AVCaptureDevice is set to video with continuous auto focus");
CGPoint autofocusPoint = CGPointMake(0.5f, 0.5f);
[inputDevice setFocusPointOfInterest:autofocusPoint];
[inputDevice setFocusMode:AVCaptureFocusModeContinuousAutoFocus];
}
[inputDevice unlockForConfiguration];
}
//setting up the input streams
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:nil];
//setting up up the AVCaptureVideoDataOutput
AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
captureOutput.alwaysDiscardsLateVideoFrames = YES;
[captureOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
//setting up video settings
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
//passing the settings to the AVCaptureVideoDataOutput
[captureOutput setVideoSettings:videoSettings];
//setting up the AVCaptureSession
captureSession = [[AVCaptureSession alloc] init];
captureSession.sessionPreset = AVCaptureSessionPresetMedium;
[captureSession addInput:captureInput];
[captureSession addOutput:captureOutput];
if (!prevLayer)
{
prevLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
}
NSLog(@"initCapture preview Layer %p %@", self.prevLayer, self.prevLayer);
self.prevLayer.frame = self.view.bounds;
self.prevLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view.layer addSublayer: self.prevLayer];
[self.captureSession startRunning];
}任何帮助都将不胜感激.
发布于 2014-04-10 20:39:05
为了关闭这个线程,除了libzxing之外,我们还使用相机扫描QR代码。我们决定实现本机iOS 7.0 AVCaptureMetadataOutputObjectsDelegate,而不是旧的AVCaptureVideoDataOutputSampleBufferDelegate。元数据委托更简单、更简洁,我们发现http://nshipster.com/ios7/中的示例非常有用。
发布于 2014-04-08 17:14:17
你正在使用的苹果公司提供的代码已经过时了--他们现在已经完全重写了。我会试试运气,开始新的工作流程。
看看这里。
发布于 2014-04-08 19:11:49
以下是诊断您的问题的一些想法:
if ([inputDevice lockForConfiguration:&cameraError]),您没有其他的理由。再加一个。cameraError中包含的错误。if ([inputDevice isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]),您没有其他的理由。添加一个;记录它,或者在那里添加一个断点,以便在调试中进行测试。focusPointOfInterestSupported之前,不要检查属性setFocusPointOfInterest的返回值。考虑在setFocusMode之前调用setFocusPointOfInterest (不确定这是否重要,但这就是我所拥有的)https://stackoverflow.com/questions/22943718
复制相似问题