How to calculate FOV?

和自甴很熟 提交于 2019-11-30 01:35:11

In iOS 7 and above you can do something along these lines:

float FOV = camera.activeFormat.videoFieldOfView;

where camera is your AVCaptureDevice. Depending on what preset you choose for the video session, this can change even on the same device. It's the horizontal field-of-view (in degrees), so you'll need to calculate the vertical field-of-view from the display dimensions.

Here's Apple's reference material.

From the FOV equation, you need focal length and sensor dimensions. Exif data has focal length but not sensor dimensions. I have found only one camera vendor (Canon) that provides sensor dimensions in the metadata -- and that is in their CRW raw files. So you will have to have a table look-up for sensor dimensions based on the camera or smart phone. The following Wikipedia link lists sensor dimensions for numerous cameras and some newer iPhones. The list is near the end of the Wiki article. http://en.wikipedia.org/wiki/Image_sensor_format

Another source for this type of information might be various photography blogs. Hope this helps.

If digital zoom is used, multiply the focal length by the zoom value. The Exif data contains the zoom factor.

Photography blogs and web sites such as http://www.kenrockwell.com have lots of information on camera sensor dimensions.

A correction: actually there are Exif tags for Focal plane X resolution and Focal plane Y resolution (in pixels) and Focal plane resolution units, From those tags and the image dimensions, you can compute the sensor size. But not all cameras provide those Exif tags. For example iPhone 4 does not provide those tags.

To answer your question:

Do my method and my formula look right...?

Maybe, but they also look too complex.

...and if yes, which values do I pass to the function?

I don't know, but if the goal is to calculate HFOV and VFOV, here is a code example which programmatically finds the Horizontal Viewing Angle, which is the only viewing angle one can access in Swift currently, and then calculates the Vertical Viewing Angle based on the aspect ratio of the iPhone 6, 16:9.

    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 {
        var HFOV : Float = retrievedDevice.activeFormat.videoFieldOfView
        var VFOV : Float = ((HFOV)/16.0)*9.0
    }

Also remember to import AVFoundation if you want this to work!

Apple has also released a list with all camera specification details including FOV (Field of View).

https://developer.apple.com/library/ios/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Cameras/Cameras.html

The values match the values that can be retrieved using:

float FOV = camera.activeFormat.videoFieldOfView;

The diameter of the field of view is the diameter of the circle of light you can see when you look into a microscope.

If about ten round cells in a row could fit across the diameter of the field of view and if you know the diameter in millimeters then you can divide the total diameter by the number of cells that would fit to find the size of each cell.

total diameter divided by number of cells that would fit equals the size (diameter) of each cell

Example

If the diameter of the field of view is 1.5mm and ten cells would fit if they were arranged in a line, then each cell is:

1.5mm/10 = 0.15mm

0.15 millimeters

REMEMBER that every time you change the magnification, you change the diameter of the circle of light you can see. So each magnification will have its own diameter.

If you put a ruler under a microscope, the more you zoom in, the fewer the number of lines on the ruler you can see.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!