首页 > 代码库 > AVCaptureDevice的几个属性
AVCaptureDevice的几个属性
AVCaptureDevice.h,主要用来获取iphone一些关于相机设备的属性。
AVCaptureDevice.h,必须要引入AVFoundation.framework包。
1. 前置和后置摄像头
AVCaptureDevice.h,必须要引入AVFoundation.framework包。
1. 前置和后置摄像头
enum { AVCaptureDevicePositionBack = 1, AVCaptureDevicePositionFront = 2};typedef NSInteger AVCaptureDevicePosition;
2. 闪光灯开关
3. 手电筒开关
4. 焦距调整
5. 曝光量调节
6. 白平衡
enum { AVCaptureFlashModeOff = 0, AVCaptureFlashModeOn = 1, AVCaptureFlashModeAuto = 2};typedef NSInteger AVCaptureFlashMode;
enum { AVCaptureTorchModelOff = 0, AVCaptureTorchModelOn = 1, AVCaptureTorchModeAuto = 2};typedef NSInteger AVCaptureTorchMode;
enum { AVCaptureFocusModelLocked = 0, AVCaptureFocusModeAutoFocus = 1, AVCaptureFocusModeContinousAutoFocus = 2};typedef NSInteger AVCaptureFocusMode;
enum { AVCaptureExposureModeLocked = 0, AVCaptureExposureModeAutoExpose = 1, AVCaptureExposureModeContinuousAutoExposure = 2};typedef NSInteger AVCaptureExposureMode;
enum { AVCaptureWhiteBalanceModeLocked = 0, AVCaptureWhiteBalanceModeAutoWhiteBalance = 1, AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance = 2};typedef NSInteger AVCaptureWhiteBalanceMode;
开启闪光灯
AVCaptureDevice* d = nil; // find a device by position
NSArray* allDevices = [AVCaptureDevice devices];
for (AVCaptureDevice* currentDevice in allDevices)
{
if (currentDevice.position == AVCaptureDevicePositionBack)
{
d = currentDevice;
}
}
// at this point, d may still be nil, assuming we found something we like....
NSError* err = nil;
BOOL lockAcquired = [d lockForConfiguration:&err];
if (!lockAcquired) {
// log err and handle...
} else {
// flip on the flash mode
if ([d hasFlash] && [d isFlashModeSupported:AVCaptureFlashModeOn] )
{
[d setFlashMode:AVCaptureFlashModeOn];
}
[d unlockForConfiguration];
}
AVCaptureDevice的几个属性
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。