Log in or register to post comments

Access camera parameters on iOS

October 24, 2017 - 9:34am #1

Hi everyone,

Excuse me if this is a newbie or straightforward question. I've been working with Unity and deploying for Android for a while, and I've successfully used CameraDevice read/write accessors for the camera fields to make modifications to the camera exposure (I need this control to get good results of some image processing algorithms I run on the background). In particular I do this by modifying the "camera-exposure-compensation" parameter.

I've now deployed my project for iOS, but found that CameraDevice.GetCameraFields() does not return any fields on iPad Mini 2. Is this an expected result? On the Unity API documentation there's no mention that this camera functionality is specifically for Android, so perhaps I'm missing something. 

Thanks a lot, I really appreciate your help.


Access camera parameters on iOS

October 27, 2017 - 10:24am #5

Please ignore my last post - I've just discovered that the issue was that I was installing the app on a device with a version of iOS that was too old (iOS 8). It works fine on iOS 10.

Many thanks all for your help.

Access camera parameters on iOS

October 27, 2017 - 10:19am #4

Hi everyone again,

I've tried dpizzle's suggestion but the app freezes during the device discovery session, ultimately giving me an EXC_BAD_ACCESS error on Xcode. I've also tried with the following code: 


AVCaptureDevice * capDevice = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInWideAngleCamera mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionBack];


With the same results. I wonder whether I'm trying to do something that it's not permitted because Vuforia has the control of the camera.


Could someone from Vuforia be so kind to confirm this? 


Many thanks in advance!

Access camera parameters on iOS

October 27, 2017 - 10:15am #3

Thanks a million for giving me some pointers dpizzle! I guess it's time to learn some Objective-C... 

Access camera parameters on iOS

October 24, 2017 - 11:09am #2

Yes, i think what you're trying to do is android only.  For iOS you'll have to write a native plugin to modify any camera parameters not found in the API .  Here's some code I pulled from a project to get you started.  There are probably better ways to do this, but this worked for me.

NSArray *captureDeviceType = @[AVCaptureDeviceTypeBuiltInWideAngleCamera];

AVCaptureDeviceDiscoverySession *captureDevice = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:captureDeviceType mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];

AVCaptureDevice *c = captureDevice.devices.firstObject;

[c lockForConfiguration:nil];

[c setFocusMode:AVCaptureFocusModeAutoFocus];

[c setExposureMode:AVCaptureExposureModeContinuousAutoExposure];

[c unlockForConfiguration];


Log in or register to post comments