3

I want to get the HVA and VVA (Horizontal View Angle and Vertical View Angle) of the Camera of an iOS device. (using Swift) How do you do this?

In Android I can use the following functions for this:

public double getHVA() {
   return camera.getParameters().getHorizontalViewAngle();
}
public double getVVA() {
   return camera.getParameters().getVerticalViewAngle();
}

Is there something similar for Swift?

1 Answer 1

3

It amazes me that there's no good solution to this. I have been able to successfully get the HVA programmatically, but it seems there is currently no way to get the VVA (If anyone knows otherwise, please correct me).

Here is how I did it:

    let devices = AVCaptureDevice.devices()
    var captureDevice : AVCaptureDevice?
    for device in devices {
        if (device.hasMediaType(AVMediaTypeVideo)) {
            if(device.position == AVCaptureDevicePosition.Back) {
                captureDevice = device as? AVCaptureDevice
            }
        }
    }
    if let retrievedDevice = captureDevice {
        println("HFOV is \(retrievedDevice.activeFormat.videoFieldOfView)")
    }

For more reading about AVCaptureDevices, and to view my code source, click here

Sign up to request clarification or add additional context in comments.

1 Comment

By the way you can also calculate the VVA if you know the aspect ratio of the device. For 16:9 AR: VVA = (HVA/16)*9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.