Ask Your Question
0

Problem when automatically calculating the intrinsic camera values for reduced camera resolutions

asked 2015-02-06 03:56:28 -0600

SimonH gravatar image

I have a problem automatically calculating the intrinsic camera values from the size of the frame and the fovY values the camera hardware tells me. It works fine for frames with full resolution and is nearly as good as a manually calibrated camera but if I set the resolution to 640x480 I get the following problem:

If I tell the OpenCV cam preview to use resolution 640x480 it provides frames in that resolution, the problem here is that the Android Camera class still tells me the same values for getHorizontalViewAngle() and getVerticalViewAngle() even if now the frames have a different aspect ratio and show not the same region as in the full resolution. So my problem is that instead of using the full frame from the sensor just in a smaller resolution the camera now gives me a cropped image but still the same values for fovY. is it possible to calculate the correct fovY based on the new resolution?

edit retag flag offensive close merge delete

Comments

Image resolution doesn't affect the field of view, it's only related to the sensor dimension and focal length. If you have these data you can get the field of view of your camera. Or maybe i didn't understand the question...

David_86 gravatar imageDavid_86 ( 2015-02-06 07:24:00 -0600 )edit

the problem ist that not only the resolution is changed but also the part of the image which is provided, there are parts cropped out when you pick the 640x480 resolution

SimonH gravatar imageSimonH ( 2015-02-09 04:50:34 -0600 )edit

I don't know about the cropping, but if you need to know the view angles you really don't need to change the resolution because you can manually calculate those data if the focal lenght of the lens and sensor width/height are known. Also with a quick search on the web i found out that those getViewAngle functions are not very reliable

David_86 gravatar imageDavid_86 ( 2015-02-09 05:21:06 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-02-10 06:31:23 -0600

Code snippet from here: http://stackoverflow.com/a/12118760/8... credits to original author.

Camera.Parameters p = camera.getParameters();
int zoom = p.getZoomRatios().get(p.getZoom()).intValue();
Camera.Size sz = p.getPreviewSize();
double aspect = (double) sz.width / (double) sz.height;
double thetaV = Math.toRadians(p.getVerticalViewAngle());
double thetaH = 2d * Math.atan(aspect * Math.tan(thetaV / 2));
thetaV = 2d * Math.atan(100d * Math.tan(thetaV / 2d) / zoom);
thetaH = 2d * Math.atan(100d * Math.tan(thetaH / 2d) / zoom);

Btw, what formula are you using to compute the focal pixel? Is it something like this:

focal pixel = (imageWidth/2) / tan(horizontalAngleInRadians/2)

Cheers!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-06 03:56:28 -0600

Seen: 878 times

Last updated: Feb 10 '15