gpt4 book ai didi

ios - 相机不聚焦在运行 iOS 7.1 的 iPhone 4 上

转载 作者:行者123 更新时间:2023-11-29 10:44:20 28 4
gpt4 key购买 nike

iOS 从 7.0.6 升级到 7.1.0 后,我们遇到了问题。我在运行 iOS 7.1 的 iPhone 4s、5、5c 和 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];
}

任何帮助将不胜感激......

最佳答案

您正在使用的 Apple 提供的代码已经过时 - 他们现在已经完全重写了它。我会试试运气并尝试新的工作流程。

检查一下 here .

关于ios - 相机不聚焦在运行 iOS 7.1 的 iPhone 4 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22943718/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com