获取 AVCaptureSession
在获取
- (AVCaptureDevice*)backCamera
{
NSArray*devices = [AVCaptureDevicedevicesWithMediaType:AVMediaTypeVideo];
for(AVCaptureDevice*deviceindevices) {
if(device.position==AVCaptureDevicePositionBack) {
returndevice;
}
}
returnnil;
}
[_avSessionbeginConfiguration];
_avSession.sessionPreset=AVCaptureSessionPreset640x480;
//通过capture对象创建输入设备对象
NSError*error =nil;
_backCameraDevice= [selfbackCamera];
[_backCameraDevicelockForConfiguration:&error];
//_backCameraDevice.focusMode = AVCaptureFocusModeLocked;
[_backCameraDeviceunlockForConfiguration];
[_avSessioncommitConfiguration];
[_backCameraDevice setFocusModeLockedWithLensPosition:slider.value completionHandler:nil]; 此方法是设置对焦,position为0到1;
[_backCameraDevicelockForConfiguration:&error];
_backCameraDevice.videoZoomFactor= sender.value; 此方法可以实现镜头放大缩小,最小为1.0
[_backCameraDeviceunlockForConfiguration];
网友评论