码迷,mamicode.com
首页 > 其他好文 > 详细

AVCaptureDevice的几个属性

时间:2014-12-30 22:05:04      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

 

AVCaptureDevice.h,主要用来获取iphone一些关于相机设备的属性。

AVCaptureDevice.h,必须要引入AVFoundation.framework包。

1. 前置和后置摄像头
enum {
    AVCaptureDevicePositionBack = 1,
    AVCaptureDevicePositionFront = 2
};
typedef NSInteger AVCaptureDevicePosition;
2. 闪光灯开关
enum {
    AVCaptureFlashModeOff = 0,
    AVCaptureFlashModeOn = 1,
    AVCaptureFlashModeAuto = 2
};
typedef NSInteger AVCaptureFlashMode;
3. 手电筒开关
enum {
    AVCaptureTorchModelOff = 0,
    AVCaptureTorchModelOn = 1,
    AVCaptureTorchModeAuto = 2
};
typedef NSInteger AVCaptureTorchMode;
4. 焦距调整
enum {
    AVCaptureFocusModelLocked = 0,
    AVCaptureFocusModeAutoFocus = 1,
    AVCaptureFocusModeContinousAutoFocus = 2
};
typedef NSInteger AVCaptureFocusMode;
5. 曝光量调节
enum {
    AVCaptureExposureModeLocked = 0,
    AVCaptureExposureModeAutoExpose = 1,
    AVCaptureExposureModeContinuousAutoExposure = 2
};
typedef NSInteger AVCaptureExposureMode;
6. 白平衡
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的几个属性

标签:

原文地址:http://www.cnblogs.com/allanliu/p/4194620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!