1

I am using two cameras without lens or any other settings in webot to measure the position of an object. To apply the localization, I need to know the focus length, which is the distance from the camera center to the imaging plane center,namely f. I see the focus parameter in the camera node, but when I set it NULL as default, the imaging is still normal. Thus I consider this parameter has no relation with f. In addition, I need to know the width and height of a pixel in the image, namely dx and dy respectively. But I have no idea how to get these information. enter image description here

This is the calibration model I used, where c means camera and w means world coordinate. I need to calculate xw,yw,zw from u,v. For ideal camera, gama is 0, u0, v0 are just half of the resolution. So my problems exist in fx and fy.

Community
  • 1
  • 1

1 Answers1

1

First important thing to know is that in Webots pixels are square, therefore dx and dy are equivalent.

Then in the Camera node, you will find a 'fieldOfView' which will give you the horizontal field of view, using the resolution of the camera you can then compute the vertical field of view too:

 2 * atan(tan(fieldOfView * 0.5) / (resolutionX / resolutionY))

Finally, you can also get the near projection plane from the 'near' field of the Camera node.

Note also that Webots cameras are regular OpenGL cameras, you can therefore find more information about the OpenGL projection matrix here for example: http://www.songho.ca/opengl/gl_projectionmatrix.html

David Mansolino
  • 1,713
  • 7
  • 13
  • Thanks David. I have noticed that the field of view. When I do the measurement, I just use the camera Intrinsic and external matrix. I have read the openGL link you shared and I found it almost the same with ideal camera. The clipping only defined a range for the light to come in the camera but doesn't affect the camera parameters. Therefore, for the ideal camera intrinsic matrix, I need to know the value of fx=fy=f/dx=f/dy in our case. We have 2 * f * tan(fieldOfView * 0.5) / (resolutionX )=dx, then we have fx=resolution X/2/tan(fieldOfView * 0.5). Do you think it is correct? – Barry Liang May 05 '20 at 05:00
  • Actually, using this I still get wrong 3D position. I have checked several times that the rotation and translation of camera system have be correctly transformed to the external matrix. So I think problem still exists in the Intrinsic matrix, maybe the fx and fy. But I am not sure. Is it ok for me to apply ideal intrinsic and external matrix for openGL case? – Barry Liang May 05 '20 at 05:06
  • Yes using ideal intrinsic and external looks indeed right. – David Mansolino May 05 '20 at 05:40
  • 1
    Thanks a lot! I solved it just now. Problem exists in the rotation part. I was too stupid to check it out before. – Barry Liang May 05 '20 at 06:09