How to calculate FOV?

后端 未结 5 1935
-上瘾入骨i
-上瘾入骨i 2020-12-25 12:10

Initial Context

I am developping an augmented reality application location based and I need to get the field of view [FOV] (I just update the value when the orient

相关标签:
5条回答
  • 2020-12-25 12:26

    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.

    0 讨论(0)
  • 2020-12-25 12:29

    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.

    0 讨论(0)
  • 2020-12-25 12:33

    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!

    0 讨论(0)
  • 2020-12-25 12:35

    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;

    0 讨论(0)
  • 2020-12-25 12:40

    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.

    0 讨论(0)
提交回复
热议问题