How to get normalized pixel values

1 visualizzazione (ultimi 30 giorni)
I'm trying to manually calculate the reprojected points from worldPoints to imagePoints coordinates. Since I used certain settings in the estimateCameraParameters() I want to know how to correctly use the distortion coefficients found after calibration. In Matlab documentation, distorted pixels are found through normalized pixels obtained with:
This for example is the x value. My questions:
1) should f be the focal length in x for x value and the focal length in y for y value or is it the usual focal length in mm obtained from and ?
2) is the equation right?
3) for the final value in x that I should get in an image, is this the equation to use?
with being the first component of the projected vector divided by the third one (scale factor)
Here is the portion of code I'm using. Results are not the same as the ReprojectedPoint struct portion I get from calibration:
Q = [worldPoints(7,1);worldPoints(7,2);0;1];
Kaugm = [params.K(1,1),params.K(1,2),params.K(1,3),0; ...
params.K(2,1),params.K(2,2),params.K(2,3),0; ...
params.K(3,1),params.K(3,2),params.K(3,3),0; ...
];
q = Kaugm*params.PatternExtrinsics(5).A*Q
u = q(1,1)/q(3,1);
v = q(2,1)/q(3,1);
x = (u-params.PrincipalPoint(1))/params.Intrinsics.FocalLength(1);
y = (v-params.PrincipalPoint(2))/params.Intrinsics.FocalLength(2);
u_dist_rad = x*(1 + params.RadialDistortion(1,1)*(x^2+y^2) + ...
params.RadialDistortion(1,2)*(x^2+y^2)^2 + ...
params.RadialDistortion(1,3)*(x^2+y^2)^3);
v_dist_rad = y*(1 + params.RadialDistortion(1,1)*(x^2+y^2) + ...
params.RadialDistortion(1,2)*(x^2+y^2)^2 + ...
params.RadialDistortion(1,3)*(x^2+y^2)^3);
u_dist_tan = x + (2 * params.TangentialDistortion(1,1) * x * y + ...
params.TangentialDistortion(1,2) * ((x^2+y^2) + 2 * x^2));
v_dist_tan = y + (params.TangentialDistortion(1,1) * ((x^2+y^2) + 2 *y^2) +...
2 * params.TangentialDistortion(1,2) * x * y);
u_final = u + u_dist_rad + u_dist_tan
v_final = v + v_dist_rad + v_dist_tan

Risposta accettata

Giridharan Kumaravelu
Giridharan Kumaravelu il 7 Giu 2023
Here are the answers to your questions:
  1. f in that equation refers to fx in pixels
  2. That equation is incomplete as it is missing the removal of the skew factor. The effect of skew must be removed normalizing the x coordinates. The complete equation looks like x = (u - u0 - skew*y ) / fx where y = (v - v0) / fy
  3. Yes, the final equation looks correct.

Più risposte (0)

Categorie

Scopri di più su Computer Vision Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by