Ios6 相机从不激活弱光增强

Ios6 相机从不激活弱光增强,ios6,camera,Ios6,Camera,我的iPhone V上运行了以下代码: // Create the capture device camera = [CameraManager cameraWithPosition:AVCaptureDevicePositionBack]; if (camera.lowLightBoostSupported) { if ([camera lockForConfiguration:nil]) { camera.automaticallyEnablesLowLightBoo

我的iPhone V上运行了以下代码:

// Create the capture device
camera = [CameraManager cameraWithPosition:AVCaptureDevicePositionBack];
if (camera.lowLightBoostSupported) {
    if ([camera lockForConfiguration:nil]) {
        camera.automaticallyEnablesLowLightBoostWhenAvailable = YES;
        [camera unlockForConfiguration];
    }
}
但是lowLightBoost永远不会激活,即使我把设备的背面放在桌子上,这样预览图像就会变黑

- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
       fromConnection:(AVCaptureConnection *)connection
{

    NSLog(@"LowLight active: %@ Camera lowlightWhenAvailable: %@",camera.isLowLightBoostEnabled ? @"true": @"false",camera.automaticallyEnablesLowLightBoostWhenAvailable ? @"true": @"false");
给我

2013-10-25 10:21:53.179 aCoDriver[1019:668f]低光激活:假摄像机低光可使用时:真 2013-10-25 10:21:53.429 aCoDriver[1019:668f]低光激活:假摄像机低光可使用时:真 2013-10-25 10:21:53.679 aCoDriver[1019:668f]低光激活:假摄像机低光可使用时:真
2013-10-25 10:21:53.929 aCoDriver[1019:668f]LowLight active:错误摄像头LowLight When Available:正确根据您的代码,我不确定为什么这不起作用。如果有帮助的话,下面是我所做的-同时注册通知,以便您可以准确地看到微光增强开关何时打开/关闭(例如,如果您将相机指向强光,然后将其平放在桌子上,您应该会收到一条通知,指示微光增强开关已打开)。这在iOS 6/7中非常适合我:

AVCaptureDevice *device = _stillCamera.inputCamera;
NSError *error;

if(device.lowLightBoostSupported) {
    // NSLog(@"low light is supported");

    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    BOOL boostEnabled = [prefs boolForKey:@"lowLightBoostEnabled"];

    if ([device lockForConfiguration:&error]) {
        device.automaticallyEnablesLowLightBoostWhenAvailable = boostEnabled;

        [device unlockForConfiguration];
    }

    // register as an observer of changes to lowLightBoostEnabled
    [device addObserver:self forKeyPath:@"lowLightBoostEnabled" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:NULL];
}


// for observing changes to _stillCamera.inputCamera.lowLightBoostEnabled
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {

    if ([keyPath isEqual:@"lowLightBoostEnabled"]) {

        NSLog(@"lowLightBoostEnabled changed");

        NSNumber *boostIsActiveValue = [change objectForKey:NSKeyValueChangeNewKey];

        BOOL boostIsActive = boostIsActiveValue.boolValue;

        NSLog(@"is low light boost currently active: %d", boostIsActive);
    }
}

从你的代码来看,我不知道为什么那不起作用。如果有帮助的话,下面是我所做的-同时注册通知,以便您可以准确地看到微光增强开关何时打开/关闭(例如,如果您将相机指向强光,然后将其平放在桌子上,您应该会收到一条通知,指示微光增强开关已打开)。这在iOS 6/7中非常适合我:

AVCaptureDevice *device = _stillCamera.inputCamera;
NSError *error;

if(device.lowLightBoostSupported) {
    // NSLog(@"low light is supported");

    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    BOOL boostEnabled = [prefs boolForKey:@"lowLightBoostEnabled"];

    if ([device lockForConfiguration:&error]) {
        device.automaticallyEnablesLowLightBoostWhenAvailable = boostEnabled;

        [device unlockForConfiguration];
    }

    // register as an observer of changes to lowLightBoostEnabled
    [device addObserver:self forKeyPath:@"lowLightBoostEnabled" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:NULL];
}


// for observing changes to _stillCamera.inputCamera.lowLightBoostEnabled
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {

    if ([keyPath isEqual:@"lowLightBoostEnabled"]) {

        NSLog(@"lowLightBoostEnabled changed");

        NSNumber *boostIsActiveValue = [change objectForKey:NSKeyValueChangeNewKey];

        BOOL boostIsActive = boostIsActiveValue.boolValue;

        NSLog(@"is low light boost currently active: %d", boostIsActive);
    }
}

谢谢!不幸的是,它不能在我的设备上工作。lowLightBoostSupported为true,它会将automaticallyEnablesLowLightBoostWhenAvailable设置为true。但在那之后,即使我用毯子包裹设备,lowLightBoostEnabled仍然是假的。我想我试试你的应用。非常感谢!不幸的是,它不能在我的设备上工作。lowLightBoostSupported为true,它会将automaticallyEnablesLowLightBoostWhenAvailable设置为true。但在那之后,即使我用毯子包裹设备,lowLightBoostEnabled仍然是假的。我想我试试你的应用程序。你有解决办法吗?没有。我怀疑这是我从相机获取图像的方式。我得到你的格式。如果你得到RGB,我会检查是否发生这种情况。如果您了解更多,请让我知道。您是否尝试过像Jawboxer那样创建观察者?这可能会帮助你调试并找出lowLightBoost是否被激活过是的,我确实激活了。从来没有打过电话。你有解决办法吗?没有。我怀疑这是我从相机获取图像的方式。我得到你的格式。如果你得到RGB,我会检查是否发生这种情况。如果您了解更多,请让我知道。您是否尝试过像Jawboxer那样创建观察者?这可能会帮助你调试并找出lowLightBoost是否被激活过是的,我确实激活了。从来没有人打过电话。