Ask Your Question
0

Rotating Camera Intrinsics Matrix

asked 2019-11-18 05:27:56 -0500

igleer gravatar image

Hey everyone I was wondering if there is a way to rotate the Intrinsics matrix received by calibration. So if i calibrated on a mobile phone in landscape mode but now i change to portrait mode how will the Intrinsics (fx, 0, cx), (0,fy, cy), (0, 0, 1) change without having to recalibrate?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2019-11-20 14:52:43 -0500

updated 2019-11-21 14:57:57 -0500

Generally, you can rotate a portrait image into landscape or vice versa (remap pixels) prior to feeding it to the calibration algorithm and this will work fine, you'll only need the one K matrix, but the focal lengths need to be exchanged and the center point has to be remapped to the same point in the rotated view.

The same is not true of the distortion matrix (D) parameters which are not axially symmetric, which is a very important component of calibration for high accurate mapping of image pixels to rays in the camera's coordinate space.

The same is also not true of any camera pointing values (extrinsic calibration Rotation and Translation to a global coordinate system used in multicamera setups). Repointing a camera relative to the coordinate system always requires a recalibration.

Edit:

  • K0: For rotation 0, fx and fy are as is, cx and cy are as is.
  • KPI2: For rotation pi/2, fx and fy are switched, use xmax-cy and cx for cx and cy
  • KPI: For rotation pi, fx and fy are as is, use xmax - cx, ymax - cy for cx and cy
  • K3PI2: For rotation 3pi/2, fx and fy are switched, use cy, xmax - cx for cx and cy

Like this (generally, I made a drawing error in the fourth array) image description

Note: I may have the rotation backwards, in which case the second and fourth cases need switched (it's a sign reversal on the rotation amount).

edit flag offensive delete link more

Comments

1

Hey thank you for the answer,

I currently get the camera matrix from another library so thats already done but it is done on landscape mode, my question is more on how to manipulate the K matrix in order for it to work on portrait mode too. So essentially how would you change fx,fy,cx,cy

igleer gravatar imageigleer ( 2019-11-21 07:31:04 -0500 )edit
1

I have a question: does the camera switch between portrait mode and landscape on its own, and then you feed the resulting image into opencv? if this is the case, then it can be helpful to recognize whether it needs rotation and then rotate it into the preferred geometry where your image conversion to cv::Mat occurs. This simplifies the camera model opencv has to deal with. Calibrate using opencv from this canonicalized image format. If you need it changed back to the original orientation for presentation, you could do that at the output end. All this keeps the camera model and calibration model in the opencv code consistent, it handles intrinsic K and D matrices, extrinsic R and T matrices, one simple way with no complications.

opalmirror gravatar imageopalmirror ( 2019-11-21 14:24:44 -0500 )edit
1

To the point, I'd merely exchange fx and fy, for pi/2 and 3pi/2 rotations, and leave them as is for 0 and pi rotations.

For cx and cy, for 0 rotation, use cx, cy. For pi/2 rotation, use ymax-cy, cx. For pi rotation, use xmax-cx, ymax-cy. For 3pi/2 rotation, use cy, xmax-cx. If I understand the rotation angle correctly (the sign may be backward)

opalmirror gravatar imageopalmirror ( 2019-11-21 14:27:12 -0500 )edit

See edit to answer for details.

opalmirror gravatar imageopalmirror ( 2019-11-21 14:58:07 -0500 )edit

Yes thank you thats what i was looking for, the visuals really help :D

igleer gravatar imageigleer ( 2019-11-25 04:23:37 -0500 )edit

If it's the correct answer, please check the checkmark so it can be closed as solved! :-) Thank you.

opalmirror gravatar imageopalmirror ( 2019-11-27 19:20:43 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-11-18 05:27:56 -0500

Seen: 59 times

Last updated: Nov 21