ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
5

What does projection matrix provided by the calibration represent?

asked 2014-01-19 22:15:16 -0600

mateo_7_7 gravatar image

updated 2022-12-08 16:42:50 -0600

lucasw gravatar image

I'm using such a tool from ROS/OpenCV in order to perform the camera calibration. The procedure ends up providing: camera matrix, distortion parameters, rectification matrix and projection matrix. As far as I know the projection matrix contains the intrinsic parameter matrix of the camera multiplied by the extrinsic parameters matrix of the matrix. The extrinsic parameter matrix itself provides the roto-translation of the camera frame with respect to the world frame. If these assumptions are correct...how is the projection matrix computed by Opencv? I,m not defining any world frame!

camera matrix:

414.287922 0.000000 382.549277
0.000000 414.306025 230.875006
0.000000 0.000000 1.000000

distortion:

-0.278237 0.063338 -0.001382 0.000732 0.000000

rectification:

1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000

projection:

297.051453 0.000000 387.628900 0.000000
0.000000 369.280731 227.051305 0.000000
0.000000 0.000000 1.000000 0.000000
edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted
4

answered 2014-07-03 07:40:05 -0600

Malefitz gravatar image

updated 2016-11-04 11:32:29 -0600

lucasw gravatar image

The projection matrix P you get is computed by the OpenCV method getOptimalNewCameraMatrix() used in the camera calibration node.

This method is used to control the output of the OpenCV undistortion method initUndistortRectifyMap(). Normally after the remap() some pixels would be outside of your image boundaries and some pixel regions in your image would be invalid (black), depending on the correction of your lens distortion.

The method getOptimalNewCameraMatrix() takes the intrinsic matrix, the distortion coefficients and an alpha value specified by you with:

  • alpha = 1 -> the image is resized so all original pixels fit into the image plane, thus you will most likely get invalid pixels in your undistorted image
  • alpha = 0 -> the image is resized so there are no invalid pixels in the image plane, thus you will most likely lose valid pixels in your undistorted image

This gives you a new camera matrix (called P by the calibration node) that can be passed to initUndistortRectifyMap() which computes the correct remaps depending on your used alpha value.

You can see the differences in this image:

image description

(originally from http://i.imgur.com/bOZ4fKs.jpg )

The left one is with alpha = 0, the right one with alpha = 1 (note that this is not stereo, both images are the same, only "viewed" with a different camera matrix).

The camera calibration node does exactly that, with alpha = 0, and stores the new camera matrix as matrix P in the CameraInfo.

edit flag offensive delete link more

Comments

1

@Malefitz@lucasw but how can alpha be set when running the camera_calibration ros node? Seems odd they didn't provide an explicit alpha parameter to set doesn't it?

ia gravatar image ia  ( 2021-04-25 12:41:44 -0600 )edit
2

answered 2014-04-30 11:35:23 -0600

ssafarik gravatar image

If you are starting with image_raw, then use K and D. If you are starting with image_rect, then use P, with D=[0,0,0,0,0]. In other words, P is like K, but for image_rect.

Steve.

edit flag offensive delete link more

Comments

Hi, could you kindly elaborate on this? Why does image_rect have a different intrinsic matrix as P compared to image_raw's K? I thought focal length and principal points should not be changed with the rectifying in image_proc node, right?

HaFred gravatar image HaFred  ( 2022-01-11 04:12:25 -0600 )edit

According to this line in image_proc node: https://github.com/ros-perception/image_pipeline/blob/8f99f41786f907a8894478de9ba984d5f965049a/image_proc/src/nodelets/rectify.cpp#L154

HaFred gravatar image HaFred  ( 2022-01-11 04:15:20 -0600 )edit
1

answered 2016-11-04 08:01:24 -0600

martin90 gravatar image

The answer can be found here: https://github.com/dimatura/ros_vimdo...

edit flag offensive delete link more
0

answered 2014-04-25 05:03:33 -0600

Unfortunately I could not find an answer in the camera calibration page. There is no documentation as far as I see. So, it is dangerous to use it. But, after some investigation I found the following discussion: http://kinect-with-ros.976505.n3.nabb...

I think that this projection is related to the distance between the two cameras of Kinect, but still not very clear to me.

edit flag offensive delete link more
0

answered 2014-04-29 00:02:22 -0600

joanpau gravatar image

The CameraInfo contents are described in the image_pipeline wiki.

The rectification is used in stereo cameras to transform the image planes of a pair of cameras such that the epipolar lines become parallel. The parameters may be computed by the same calibration node, passing a stereo pair instead of a single camera.

When calibrating a monocular camera, as in your case, the rectification is the identity.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-19 22:15:16 -0600

Seen: 12,159 times

Last updated: Dec 08 '22