Problem locking AVCamera custom Exposure for openCV image analysis

Hello,
I need to analyze video frames from AVCaptureDevice using opencv. Therefore the exposure must be set to custom values, in order to obtain an image as dark as possible.

This works well on Android, however with iOS the following code does only work for a second, after which the camera falls back to auto exposure values.

Is there a way to stop the camera from auto-setting exposure/ISO settings?

The relevant objective-C code for initializing the camera is:

Code Block
- (void) initCam
{
self.cam = [[CvVideoCamera alloc] init];
self.cam.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;
self.cam.defaultAVCaptureSessionPreset = AVCaptureSessionPreset640x480;
self.cam.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.cam.defaultFPS = 30;
self.cam.grayscaleMode = NO;
self.cam.delegate = self;
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
if ([device lockForConfiguration:&error])
{
[device setExposureModeCustomWithDuration:CMTimeMakeWithSeconds(CMTimeGetSeconds(device.exposureDuration) * 0.75, device.exposureDuration.timescale) ISO:AVCaptureISOCurrent completionHandler:nil];
}
else
{
NSLog(@"%@", error);
}
}


Problem locking AVCamera custom Exposure for openCV image analysis
 
 
Q