iPhone SDK - get/calculate camera field of view (F

2019-02-07 01:32发布

问题:

Is there a way to find out or calculate the field of view (FOV) an iPhone camera has through calls to the APIs? Or is it something you have to physically and manually find out for yourself?

If it cannot be fetched or calculated with the APIs, but instead has to be hard-coded into an app, then what's the best way to find out what kind of device an app is running on? Different devices have different FOV (iPhone 4 has larger FOV than previous versions.) Also, how big are the FOVs of each device, exactly?

I'm asking because I'm thinking of making an augmented reality app, and knowing the FOV is essential.

回答1:

I took a photo of a piece of paper that i had measured from a distance that i also measured. I then looked at the ratio of the size of the piece of paper to its image in the photo.

My values were at 56 cm you can fully photograph (i.e. so that it takes up exactly the screen size) an object that is about 40cm x 60cm

Using that i did some simple trig and arrived at: Vertical FOV: 2*atan(58.5/2 / 56.5) -> ~55 degrees Horizontal FOV: 2*atan(21.5/2 /56.5) -> 42 degrees



回答2:

This answer uses some math and camera info to determine a value.

Looking at ARKit it hardcodes .7392 radians (42.35 degrees). When I was researching AR I just held the phone camera up and lined the edges up with some landmarks and then measured the angle. My estimation on a 3GS was 48 degrees in landscape and 39 degrees in portrait. My estimation on a iPhone 4 is 58 in landscape and 48 degrees in portrait.

Searching around on the internet there seem to be wildly varying claims. This might be explained by people having different models of the phone. I have found no official source of information on this topic from apple.

If I were to do this again I would borrow the various phone models and use a system of measuring against landmarks on the horizon. Nothing can beat hard numbers you measured yourself.

My method for estimation is as follows: Stand 10 feet from a wall and look at the image on screen. Note the points on the wall at the left and right side of the image and measure the distance. Then use trigonometry to calculate the angle. If a is the distance from the wall and o is the length measured along the wall then tan(A) = (o/2)/a, which is half the angle.

UPDATE: I fixed some incorrect calculations and added the iPhone 4 and how I measured.



回答3:

I get 47.1539 degrees in the long dimension on an iPhone 3gs.



回答4:

You can simply ask:

AVCaptureDevice *device = [...]
NSLog(@"FOV: %lf", device.activeFormat.videoFieldOfView);

Remember this is the horizontal FOV and well now, for newcomers, you have the ARKit.