First time here? Check out the FAQ!

Ask Your Question
0

How do I address rotation when using calibration?

asked Jul 11 '16

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)?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Jul 11 '16

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.

Preview: (hide)

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 (Jul 12 '16)edit

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

Tetragramm gravatar imageTetragramm (Jul 13 '16)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 (Jul 13 '16)edit

Question Tools

1 follower

Stats

Asked: Jul 11 '16

Seen: 1,679 times

Last updated: Jul 11 '16