Ask Your Question
0

How do I address rotation when using calibration?

asked 2016-07-11 14:07:27 -0600

I'm using calibrateCameraCharuco to correct for radial distortion in mobile device cameras. If I have calibrated with images in landscape orientation, how should I undistort an image in portrait orientation? Can I use the calibration values as-is or do I need to rotate the camera matrix?

This brings up another question: can the calibration be used upside-down (i.e. calibration was performed with the camera in one landscape orientation and the image was taken with the camera rotated 180 degrees)?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-07-11 17:45:04 -0600

Tetragramm gravatar image

Take a look at THIS page, the calibrateCamera function. The distortion coefficients are (using default settings) all radial. So it only depends on the distance from the principal point, which is defined in the camera matrix.

To rotate, switch the f_x and f_y values, then alter the c_x and c_y values appropriately. The c_x and c_y store the location of the principal point, in pixels. So if the image is mirrored, then c_x = image.cols-c_x, flipping is rows and c_y.

That means if you rotate clockwise 90 degrees, then c_x = (old image rows)-c_y_old and c_y = c_x_old

Now, remember that you only do this if the actual pixels change. If the camera is held upside down, so the ground appears at the top of the image buffer, then you don't need to change anything. Only if you rotate the image manually or your camera automatically does it do you need to change anything.

edit flag offensive delete link more

Comments

We're working with mobile devices, not cameras, so if I get a landscape-orientation photo and I don't know if it was taken with top of the camera facing left or right, the calibration will be wrong if it had the top of the camera pointing the other way, right?

SSteve gravatar imageSSteve ( 2016-07-12 14:21:08 -0600 )edit

Correct. I think there's some tag in the image file, but I have no idea where or what.

Tetragramm gravatar imageTetragramm ( 2016-07-12 18:47:55 -0600 )edit

I'll have to dig it out of the EXIF data. But now I need an EXIF library. Oh well. Thanks for your help.

SSteve gravatar imageSSteve ( 2016-07-13 13:17:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-11 14:07:27 -0600

Seen: 1,674 times

Last updated: Jul 11 '16