1

I am confused about the opencv camera calibration coordinate transformation. I used the example code to calibrate my camera, and I got this result:

enter image description here

When I use this camera matrix to multiply a point in camera coordinate system, say P = [50, 50, 1.35], the output result is too big which is impossible to be a pixel coordinate. What's is wrong here ? Did I miss something ?

The image is 1920 x 1080. This is the chessboard configuration file information:

enter image description here

Johnnylin
  • 507
  • 2
  • 7
  • 26
  • It is totally possible to project a point that will not be inside the image. You choose a ratio between X and Z (or Y and Z) that is very big. It is like I want to project a point that is 1.5 m away from the camera in Z but that is 50 m away in X and Y... – Catree Jul 21 '16 at 09:12
  • @Catree I don't quite understand what you say by "You choose a ratio between X and Z (or Y and Z) that is very big. " – Johnnylin Jul 21 '16 at 09:16
  • This post explain very well the process http://stackoverflow.com/questions/12299870/computing-x-y-coordinate-3d-from-image-point?rq=1 – damianodamiano Jul 21 '16 at 09:43
  • @DamianoDamiano, Thanks for the post. I understand's the process. But I cannot figure out why this multiplication fails to project P = [50, 50, 1.35] this point. I think something is missing. – Johnnylin Jul 21 '16 at 11:20
  • 1
    There is no problem with the multiplication, you can find here more information in the OpenCV [documentation](http://docs.opencv.org/2.4.13/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html). Your point P is X=50, Y=50, Z=1.35 in the camera frame. The Z axis is going forward, the X axis is going to the right and the Y axis is going to the down. Now read again my analogy. Again, there is no need for a mathematically projected point in the camera frame to be inside the image. It is the same like a camera and your point P is not visible by the camera. – Catree Jul 21 '16 at 17:43
  • @Catree Thanks for your explanation. I understands now. Can you put it in the answer so that I can close this thread. – Johnnylin Jul 22 '16 at 11:04

1 Answers1

5

You can find in the OpenCV documentation the different equations for the perspective projection model, also illustrated in the following pictures (thanks to this link).

Camera model

Assuming a point P=(X,Y,Z) in the camera frame Fc, its coordinate in the normalized camera frame is:

x' = X/Z
y' = Y/Z

And its projection onto the image plane (assuming no distortion):

u = fx * x' + cx
v = fy * y' + cy

With fx and fy the focal length in pixel and cx, cy the coordinate of the principal point in the image.

In your case, your Z is at 1.35 away from the camera but the 2 other coordinates are way too far compared to the Z coordinate.

There is no problem mathematically, it is just that your point P is not visible for your camera.

Community
  • 1
  • 1
Catree
  • 2,477
  • 1
  • 17
  • 24
  • Exactly, you can also compute the theoretical field of view needed and you should get something like 177° (`2*atan(50/1.35)`). – Catree Jul 22 '16 at 12:26
  • is there any relation between `f` and `fx and fy` ? Assuming f = 1, should the equation be u = 1 * x' + cx ? – infoclogged Apr 11 '18 at 14:41
  • @infoclogged See this [answer](https://stackoverflow.com/a/16330470/6055233) or [here](https://www.cc.gatech.edu/~afb/classes/CS4495-Fall2014/slides/CS4495-CameraModel.pdf) for more theoretical information. – Catree Apr 11 '18 at 15:15