
[英]Camara preview not displayed in correct when developing a custom camera application for ios from av foundation frame work?
[英]Why is the preview displayed in my custom camera interface different from the one displayed in the system camera in iOS development?
self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
self.input = [[AVCaptureDeviceInput alloc]initWithDevice:self.device error:nil];
self.videoOutPut = [[AVCaptureVideoDataOutput alloc]init];
[self.videoOutPut setSampleBufferDelegate:self queue:dispatch_get_global_queue(0, 0)];
_ImageOutPut = [[AVCapturePhotoOutput alloc]init];
self.session = [[AVCaptureSession alloc]init];
if ([self.session canSetSessionPreset:AVCaptureSessionPreset1920x1080]) {
[self.session setSessionPreset:AVCaptureSessionPreset1920x1080];
}
if ([self.session canAddInput:self.input]) {
[self.session addInput:self.input];
}
if ([_session canAddOutput:_ImageOutPut]) {
[_session addOutput:_ImageOutPut];
}
if ([_session canAddOutput:self.videoOutPut]) {
[_session addOutput:self.videoOutPut];
}
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc]initWithSession:self.session];
self.previewLayer.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight - 164);
self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view.layer addSublayer:self.previewLayer];
[self.session startRunning];
if ([self.device lockForConfiguration:nil]) {
if ([self.device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeAutoWhiteBalance]) {
[self.device setWhiteBalanceMode:AVCaptureWhiteBalanceModeAutoWhiteBalance];
}
[self.device unlockForConfiguration];
}
为什么我的自定义相机界面中显示的预览与iOS开发中系统相机中显示的预览不一样? 以上是我设置的代码,我应该怎么做才能显示更多的内容在此处输入图像描述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.