How to get normalized pixel values
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Computer Vision Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!