4

My camera has different resolutions 1280*480 640*240 320*120

I have used the algorithm of Opencv3 to calibrate the camera with the resolution of 1280*480 and I have got the camera matrix (fx fy cx cy)and the distortion matrix (k1 k2 p1 p2 k3)for this resolution.

But now I want to use these camera matrix and distortion matrix to calibrate the camera with the resolution of 320*120. I don't know how to apply these two matrix of the resolution 1280*480 to the resolution of 320*120. PS I haven't calibrated the camera with the resolution of 320*120 directly because the image is too small and the algorithm of Opencv can't find the chessboard.

I want to know how the camera matrix (fx fy cx cy)and the distortion matrix (k1 k2 p1 p2 k3) will change if i change the resolution 1280*480 to 320*120.

The algorithm of opencv is the following one: http://docs.opencv.org/3.0-beta/doc/tutorials/calib3d/camera_calibration/camera_calibration.html

Cœur
  • 37,241
  • 25
  • 195
  • 267
Meng
  • 89
  • 1
  • 7
  • Could you please attach: 1) your calibration parameters for 1280x480 2) undistorted image at 1280x480 3) undistored image of the same scene at 320x120. – Dan Mašek Jul 03 '17 at 22:44
  • [This seems relevant](http://ksimek.github.io/2013/08/13/intrinsic/) (and I just noticed they even discuss this problem in the comments). I haven't fully verified this, but it seems to me that it should scale linearly, so divide `fx`, `fy`, `cx`, and `cy` by 4 (since each dimension is now 1/4 scale of the original). – Dan Mašek Jul 03 '17 at 22:55
  • It will take a bit more work to write a good enough answer, but my line of thinking is as follows: Assuming the camera bins 2x2 and 4x4 to get the lower resolutions, the FOV stays the same, and the (virtual) pixels become bigger. `cx` and `cy` are coordinates of the centerpoint -- linear scaling applies. | `fx` and `fy` are focal lengths in pixels units -- let's stick with `fx` since the same principle applies to both. The relationship to real focal length is `Fx = fx * (W / w)` where `W` is sensor width in real units, `w` is sensor width in pixels. ... (cont) – Dan Mašek Jul 04 '17 at 01:40
  • In our case the real focal length `Fx` remains constant (there is no change to the optics) and the real unit sensor width `W` also remains constant. Therefore `fx` is directly proportional to `w` (e.g. 1/4 as many pixels wide, 1/4 the `fx`). – Dan Mašek Jul 04 '17 at 01:43
  • For 1280*480 Camera_Matrix ( 3*3 ) 4.1609688662292331e+02; 0.; 2.8905731584063523e+02; 0.; 4.1454707445301574e+02; 2.3874261375252598e+02; 0.; 0.; 1.; Distortion_Coefficients ( 5*1 ) -3.6288473454524128e-01; 1.5078686499416877e-01; 5.7904052666320714e-04; 1.3434936135297517e-05; -3.1521081637626687e-02; – Meng Jul 04 '17 at 08:08
  • What are you talk about is real focal length fx fy and real Principal Point Offset cx cy. But i want to know is the focal length and the principal point offset in pixel, I am not sure how they will change. – Meng Jul 04 '17 at 09:46
  • You can check this post for more detail, not from me but the author's explanation is very clear. https://dsp.stackexchange.com/questions/6055/how-does-resizing-an-image-affect-the-intrinsic-camera-matrix – willSapgreen Nov 13 '17 at 22:52

1 Answers1

6

You don't need to change the distortion matrix. As for the camera matrix (the one containing fx, fy, cx, cy), you just need to divide them by 4 in your case. The general formula is:

fx' = (dimx' / dimx) * fx 
fy' = (dimy' / dimy) * fy

fx' is the value for your new resolution, fx is the value you already have for your original resolution, dimx' is the new resolution along the x axis, dimx is the original one. The same applies to fy.

cx and cy are calculated analogically because all these values are expressed in pixel coordinates.

As per the OpenCV docs regarding the camera matrix:

if an image from the camera is scaled by a factor, all of these parameters should be scaled (multiplied/divided, respectively) by the same factor.

KjMag
  • 2,650
  • 16
  • 16
  • Thanks for your answer. I want to know if the matrix of camera will change when i change the resolution? That means the fx,fy,cx and cy. Waiting for you answer. – Meng Jul 03 '17 at 15:35
  • @KjMag It seems you misread the question. He's talking about the same camera, just set to a different resolution. That would mean all the optics stay the same, and given ratio of the resolutions, I'd say it's likely that the camera does 2x2 and 4x4 binning. | Discussing the camera matrix, the tutorial mentions "While the distortion coefficients are the same regardless of the camera resolutions used, these should be scaled along with the current resolution from the calibrated resolution." IMHO this is what the OP is curious about. – Dan Mašek Jul 03 '17 at 22:37
  • @Dan Mašek Thanks. I talk about the same camera with the different resolution. what i don't understand is "While the distortion coefficients are the same regardless of the camera resolutions used, these should be scaled along with the current resolution from the calibrated resolution.". How I can change the matrix of camera fx fy cx cy and the matrix of distortion k1 k2 p1 p2 k3. – Meng Jul 04 '17 at 08:06
  • That is true, apparently I've misread the question. I'll update the answer accordingly. – KjMag Jul 04 '17 at 11:59
  • Do you knwn how to solve this problem? https://stackoverflow.com/questions/45215145/in-stereo-calibration-how-the-extrinsic-matrix-changes-if-i-change-the-resoluti – Meng Jul 20 '17 at 13:13