相关疑难解决方法(0)

访问iOS 6新API,用于相机曝光和快门速度

在Apple的iOS 6.0功能页面上,它曾经说过

利用内置摄像头的高级功能.新的API可让您控制焦点,曝光和感兴趣的区域.您还可以使用面部检测API访问和显示面部,并利用支持硬件的视频稳定功能.

此文本已被删除,我无法在API中找到用于控制曝光的新方法.在AVCaptureDevice"曝光设置"下的课程中,没有针对iOS 6.0的新属性/方法.你知道在哪里可以找到API的新功能吗?

iphone camera ios avcapturedevice

11
推荐指数
2
解决办法
2万
查看次数

使用键值观察器锁定exposureMode会导致崩溃

我正在屏幕区域进行一些运动检测.在开始检测之前,我想设置焦距和曝光并锁定它们,这样它们就不会触发假动作.因此,我将AVCaptureFocusModeAutoFocus和AVCaptureExposureModeAutoExpose发送到设备并添加KeyvalueObserver.当观察者说它已完成聚焦并改变曝光时,它会锁定它们(并开始运动检测).一切都可以正常工作,但锁定曝光会在几秒钟内崩溃应用程序",尽管在两种情况下都有相同的代码.

static void * const MyAdjustingFocusObservationContext = (void*)&MyAdjustingFocusObservationContext;
static void * const MyAdjustingExposureObservationContext = (void*)&MyAdjustingExposureObservationContext;

-(void)focusAtPoint{

   CGPoint point;
   if(fromRight) point.x = 450.0/480.0;
   else point.x = 30.0/480.0;
   point.y = 245.0/320.0;

   AVCaptureDevice *device =[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

   if(device != nil) {
       NSError *error;
       if([device lockForConfiguration:&error]){

          if([device isExposureModeSupported:AVCaptureFocusModeContinuousAutoFocus] && [device isFocusPointOfInterestSupported]) {
             [device setFocusPointOfInterest:point];
             [device setFocusMode:AVCaptureFocusModeContinuousAutoFocus];
             [device addObserver:self forKeyPath:@"adjustingFocus" options:NSKeyValueObservingOptionNew context:MyAdjustingFocusObservationContext];
             NSLog(@"focus now");
          }

          if([device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure] && [device isExposurePointOfInterestSupported]) {
             [device setExposurePointOfInterest:point];
             [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
             [device addObserver:self forKeyPath:@"adjustingExposure" options:NSKeyValueObservingOptionNew context:MyAdjustingExposureObservationContext];
             NSLog(@"expose now");
          }

          [device unlockForConfiguration];
      }else{ …
Run Code Online (Sandbox Code Playgroud)

key-value-observing ios avcapturesession avcapturedevice

6
推荐指数
1
解决办法
3116
查看次数