Ask Your Question

What is the focal length for computer generated pictures?

asked 2017-12-29 10:00:42 -0500

sarah1802 gravatar image

updated 2017-12-29 10:34:42 -0500

Hi there,

I am generated some rotated ArUco markers in MatLab and want to get the rotation as normal with OpenCV and C++. The detection algorithm needs of course the camera matrix and the distortion model. The distortion model is easy to have for a perfect camera should be k1,k2,p1,p2,k3 = 0, am I right? The camera matrix offers me a bigger problem... what ist the focal length f (I assume fx=fy). I set the displacements zero: c=cx=cy=0. Now my Camera Matrix should be something like that:

M= [ f, 0, 0;
0, f, 0;
0, 0, 1]

Can anybody tell me, what focal length should be used? In meanwhile I tried to calibrate it with a perfect picture of the (in my case) CharUco Board. (For the CharUco board is an additional avg_reprojection_error, I guess this should be also 0?)

I hope you can help me :) Greetings Sarah

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-12-29 14:36:10 -0500

Tetragramm gravatar image

Well, cx and cy should be width/2 and height/2 respectively.

How did you generate them? Is it just perfectly flat, square image? Or did you do any perspective transforms?

If you have a perfectly flat, square marker, then just figure out how wide the marker should be (in a length unit such as inches or meters), how wide it is (in pixels), and how far you want it to be from the camera (in the same length unit).

You use the distance and width to figure out what the angle of the markers is, then from there figure out what the whole camera Field of View (FOV) is. Then you use the equation HERE (The horizontal one if you're using width) with h = number of columns in the image. That gives you f.

edit flag offensive delete link more


Thank you very much!!! That is exactly what I am looking for and it worked perfectly :-). Do you know how to handle with a perspective transform? At the moment I only rotate the Z-Axis, but a rotation on the Y or X-Axis would be also interesting?

sarah1802 gravatar imagesarah1802 ( 2017-12-30 03:45:45 -0500 )edit

Well, the same deal. You figure out what angle it covers. The geometry gets more complicated since the triangle's base tilts relative to the camera.

Or better, you just keep the same focal length (since that typically doesn't change), and let the size of the marker determine the depth.

Tetragramm gravatar imageTetragramm ( 2017-12-30 09:59:43 -0500 )edit

Question Tools

1 follower


Asked: 2017-12-29 10:00:42 -0500

Seen: 562 times

Last updated: Dec 29 '17